Printing the pixel values of YUV image

When i convert a image to YUV from RGB I cant get a value of Y when I try printing the pixels. I get a value 377 and when I cast it with integer I get 255. WHich I presume is incorrect. Is there a better way or rather correct way to print the values of YUV image pixels.

Actually i am priting the values (int)<Vec3b>(j,i).val[0]= 255 and<Vec3b>(j,i).val[0] = 377

Also on that note, the Y is the combination of RGB calculated with some constants according to note. I am actually confused as how to get the value of Y.


This is a problem of OpenCV. OpenCV does not gracefully handle (scale) YUV or HSV color spaces for uchar format. With Vec3b you have effectively 3-channel uchar, and that ranges [0;255].

The solution is to use another matrix type. With cv::Mat3f you have a 3-channel floating point image. Then the values will be correctly converted by cvtColor function. You can get a Mat3f from a Mat3b by assignment.

Another solution that uses less memory may be Mat3s and Mat3w types, if supported by cvtColor.

Need Your Help

Send E-mail if date has passed using php

php sql email

I'm trying to make an online sign up sheet system. I was just wondering if when the date of the event had passed would I be able to send a list of all the people who have signed up to the event (fr...

Tab Bar controller in iPhone

iphone ios objective-c uitabbarcontroller

I have added Two Tabs in my app, to load two view controller using these tabs

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.