Ask Your Question
0

Y channel of Ycbcr not dispalyed correctly

asked 2015-11-13 18:46:53 -0600

elp14sma gravatar image

I set up ROI for eye region . I converted this region to ycbcr channel , and I splitted Y channel from it.

when I show the ycbcr channel the eye area is showed in normal ycbcr colors,

My problem is that when I show Y channel it doesn't show the ROI Y channel which it should be the same as ycbcr but in grey

this is the output image for Ycbcr and Y channel . any I idea why this happening ?

My code :

for (i = 0; i < faces.size(); i++) // Iterate through all current elements (detected faces)

{

    Point pt1(faces[i].x, faces[i].y); // Display detected faces on main window 
    Point pt2((faces[i].x + faces[i].height), (faces[i].y + faces[i].width));
    rectangle(frame, pt1, pt2, Scalar(0, 255, 0), 2, 8, 0);

    // set ROI for the eyes

    Rect Roi = faces[i];

    Roi.height = Roi.height / 4;

    Roi.y = Roi.y + Roi.height;

    cv::Mat crop = frame(Roi);

    cvtColor(crop, ycbcr, CV_BGR2YCrCb);

    imshow("ROI                   ",ycbcr);

    vector<Mat> channels;

    split(ycbcr, channels);

    medianBlur(channels[0], channels[0], 3);

    Mat eye_region_Ychannel = channels[0].clone();

   imshow("Y", channels[0]);
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-11-13 20:53:40 -0600

i tested your code. it works without problem with latest OpenCV 3.0.0-dev. try changing vector<Mat> channels; to Mat channels[3]; may be this change solve your problem.

edit flag offensive delete link more

Comments

I used Mat channels[3]; , the output is black image

elp14sma gravatar imageelp14sma ( 2015-11-14 04:15:27 -0600 )edit

what is your OpenCV version?

sturkmen gravatar imagesturkmen ( 2015-11-14 07:14:07 -0600 )edit

it is 2.4.10

elp14sma gravatar imageelp14sma ( 2015-11-14 07:41:41 -0600 )edit

i think you have to update your OpenCV version

sturkmen gravatar imagesturkmen ( 2015-11-14 08:46:52 -0600 )edit

Ok , I will try the new version. Thanks

elp14sma gravatar imageelp14sma ( 2015-11-14 09:27:36 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-13 18:46:53 -0600

Seen: 265 times

Last updated: Nov 13 '15