Finding the Brightest Pixel in an Image
Show older comments
I have an RGB image, but its mostly black with different areas of shining light. I want my code to find the pixel where the light is shining brightest and mark that pixel but I'm not sure how.
Any help is appreciated. Thanks.
Accepted Answer
More Answers (1)
Image Analyst
on 26 Oct 2012
An alternative is to convert your image to monochrome by using rgb2gray() or taking just one of the color channels,
% Convert to gray with a weighted average of the R, G, and B channels.
grayImage = rgb2gray(rgbImage);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
Then using imregionalmax() on whichever monochrome image you create. This will find ALL of the shiny peaks of light, with the brightest of those being just one of the peaks that it finds. But in general to find the brightest spot, use the method Sean gave. If you want to go further and find the one pixel that is the centroid of that spot, then you need to call regionprops(). See my Image Segmentation Tutorial if you want an example.
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!