MATLAB: Find luminance vector in an image

colorcolormapdigital image processingrgb

yi = 0.299ri +0.587gi +0.114bi i=1,2,.M
Let Y the luminance vector computed starting from the palette P of the image
I.
Palette consist of RGB value...
What is the matlab code to find Yi value

Best Answer

If Im is your nxmx3 rgb image
yi=Im(:,:,1)*0.299+Im(:,:,2)*0.587+Im(:,:,3)*0.114