How to write the code for the average luminance of input image?
12 views (last 30 days)
Show older comments
Jayzel Castro
on 13 Dec 2013
Commented: Jayzel Castro
on 13 Dec 2013
I'm having a trouble for coding the average luminance of the image. This the formula for that
Yaveg =Yi,j (1) where Yi,j = 0.3R + 0.6G + 0.1B, Yi,j is normalized to the range (0,255), and i, j are the index of pixel.
Please help this is for my thesis, its my first time to use matlab :(
0 Comments
Accepted Answer
Image Analyst
on 13 Dec 2013
Why not use
grayImage = rgb2gray(rgbImage);
meanGrayLevel = mean2(grayImage);
That's how most people would do it. If you have special coefficients you want to use for some reason then you can do
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Combine separate color channels into weighted average to get the gray scale image.
grayImage = 0.3 * redChannel + 0.6 * greenChannel + 0.1 * blueChannel;
meanGrayLevel = mean2(grayImage);
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!