c - how to convert pixels values to display image in opencv -


i'm unable process pixel values (unsigned int) convert image. want syntax converts pixel value image format. cvset (all type of commands) not working, i'm getting particular color image if red or green etc. please me syntax reconstructing pixel values image. i'm able convert image pixels i'm unable convert image these same pixel values.

how many channels there in image working with? important information. keep in mind grayscale images have typically 1 channel, while colored images loaded opencv have 3 channels (r, g , b).

to work 3-channel image in c, do:

iplimage* prgbimg = cvloadimage("img.png", cv_load_image_unchanged);  int width = prgbimg->width;  int height = prgbimg->height; int bpp = prgbimg->nchannels;   (int i=0; < width*height*bpp; i+=bpp)  {    prgbimg->imagedata[i] = r; // red pixel   prgbimg->imagedata[i+1] = g; // green   prgbimg->imagedata[i+2] = b; // blue  } 

for single-channel images, core of loop simpler need operate on img->imagedata[i].


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -