Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void invert_image( IplImage* source, IplImage* result )
- {
- //+ TO DO: Write code to invert all points in the source image (i.e. for each channel for each pixel in the result
- // image the value should be 255 less the corresponding value in the source image).
- int width_step=source->widthStep;
- int pixel_step=source->widthStep/source->width;
- int number_channels=source->nChannels;
- cvZero( result );
- unsigned char white_pixel[4] = {255,255,255,0};
- int row=0,col=0;
- for (row=0; row < result->height; row++)
- for (col=0; col < result->width; col++)
- {
- unsigned char* curr_point = GETPIXELPTRMACRO( source, col, row, width_step, pixel_step );
- char pixel[4]={curr_point[RED_CH]-255,curr_point[GREEN_CH]-255,curr_point[BLUE_CH]-255};
- PUTPIXELMACRO( result, col, row, white_pixel, width_step, pixel_step, number_channels );
- }
- }
Add Comment
Please, Sign In to add comment