Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Runtime error while conversion of color space from RGb to YCbCr

Hello,

I have Y, Cr, Cb channels which I need to combine together into one RGB image. Here is the code I'm using which is giving me run time error. Any help would be appreciated.

    CvMat finalLayer; //output to store the merged ycbcr image
    cvMerge(y_output, cr_output, cb_output, NULL, &finalLayer); //merging ycbcr
    cv::Mat finalLayer1 = cv::cvarrToMat(&finalLayer); //convert IplImage to cv::Mat
    cv::Mat finalLayer2; //store RGB output image
    cvtColor(finalLayer1, finalLayer2, CV_YCrCb2BGR); //convert from ycbcr to rgb

    //display
    namedWindow("Final Image",CV_WINDOW_AUTOSIZE);
    imshow("Final Image",finalLayer2);waitKey(0);
click to hide/show revision 2
retagged

updated 2014-08-16 00:29:44 -0600

berak gravatar image

Runtime error while conversion of color space from RGb to YCbCr

Hello,

I have Y, Cr, Cb channels which I need to combine together into one RGB image. Here is the code I'm using which is giving me run time error. Any help would be appreciated.

    CvMat finalLayer; //output to store the merged ycbcr image
    cvMerge(y_output, cr_output, cb_output, NULL, &finalLayer); //merging ycbcr
    cv::Mat finalLayer1 = cv::cvarrToMat(&finalLayer); //convert IplImage to cv::Mat
    cv::Mat finalLayer2; //store RGB output image
    cvtColor(finalLayer1, finalLayer2, CV_YCrCb2BGR); //convert from ycbcr to rgb

    //display
    namedWindow("Final Image",CV_WINDOW_AUTOSIZE);
    imshow("Final Image",finalLayer2);waitKey(0);