luminance component of an image

Hi, I have a frame of a vedio sequence I which is a 288*532 double. How can I extract only the luminance component? Thanks.

 Accepted Answer

Run the following:
I = imread('test.png');
J = rgb2gray(I);
rgb2gray uses the same formual which is used to calculate luminance (to 3 decimal places the formula is):
0.299 * R + 0.587 * G + 0.114 * B

4 Comments

I1 = vcif2('b_cif.yuv',1);
Thank you Mark,
this is my Image which is a frame of a yuv vedio file. now how can I comvert it to png first?
The example I posted is just for one image. If you have a video it would look something like this:
v = VideoReader('someVideo.mp4');
while hasFrame(v)
video = readFrame(v);
J = rgb2gray(video);
end
I am not familiar with that vcif2 (is it a custom function?) but if you have read in an image already you could directly apply:
J = rgb2gray(I2);
It looks like you might be in a different colorspace so try applying this first:
I2 = ycbcr2rgb(I2)
Thank you this is what I got. Please see the attachment.
please provide the original image, video, and any given functions.

Sign in to comment.

More Answers (3)

az
az on 30 Nov 2018
Hello Mark I trief to sent you the tennis_cif.yuv but the file is more than 30 K even in zipped condition. is there any way I can attach that big file? Thank you for your efforts.

1 Comment

Image Analyst
Image Analyst on 30 Nov 2018
Edited: Image Analyst on 30 Nov 2018
Just attach the one frame, not the entire video. One frame will certainly be small enough to attach!
And explain why using rgb2gray() on the RGB image did not work.

Sign in to comment.

az
az on 30 Nov 2018
All I can say you need to have this file to the vedio file path to open that in mathlab. Thanks.
az
az on 30 Nov 2018
Hello Mark, this the 'I_1' the one frame of the vedio. Thank you.

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Products

Asked:

az
on 30 Nov 2018

Answered:

az
on 30 Nov 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!