Get RGB pixels from input image and reconstruct an output image in opencv

前端 未结 4 2013
灰色年华
灰色年华 2020-12-22 07:04

I want to load the image in opencv and split the image into channels(RGB) and i want to increase any one of the colors and getting that corresponding output image.is there a

4条回答
  •  太阳男子
    2020-12-22 07:31

    Well to add any scalar to an RGB image you can use cvAddS(srcImage, scalarToAdd, dstImage). Here is an example:

    int main(int argc, char** argv)
    
    {
    // Create a named window with the name of the file.
    cvNamedWindow( argv[1], 1 );
    // Load the image from the given file name.
    IplImage* img = cvLoadImage( argv[1] );
    //Make a scalar to add 30 to Blue Color and 20 to Red (BGR format)
    CvScalar colorAdd = cvScalar(30.0, 0, 20.0);
    cvAddS(img, colorAdd, img);
    // Show the image in the named window
    cvShowImage( argv[1], img );
    // Idle until the user hits the “Esc” key.
    while( 1 ) {
    if( cvWaitKey( 100 ) == 27 ) break;
    }
    cvDestroyWindow( argv[1] );
    cvReleaseImage( &img );
    exit(0);
    }
    

    Haven't tested the code, hope it helps.

提交回复
热议问题