If I have an B/W image and need to find the brightest pixel how would I do so?

3 views (last 30 days)
This is the question I'm having problems with, could someone please help with how I would locate the brightest pixels and change their value?
Block out the bright sun in the grayscale images sun01.png and sun02.png by first finding the row and column position of the brightest pixel in each image. Then set pixels to zero values in a 20-pixel radius centered on the bright point. Display both images with the removed sun in different figures (see example below) without hardcoding the location with the brightest pixel.

Answers (1)

Image Analyst
Image Analyst on 23 Oct 2018
Find the brightest value
maxGrayLevel = max(grayImage(:));
% Find where it occurs
[rows, columns] = find(grayImage == maxGrayLevel);
Next, use the FAQ https://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F to create a circular mask and zero it out
for k = 1 : length(rows)
% code from faq goes here...... Use rows(k) and columns(k).
% Now mask it
grayImage(circlePixels) = 0; % Blacken circle around it.
end
Should be really easy for you now.
  2 Comments
Cody Cox
Cody Cox on 23 Oct 2018
Thank you! I really appreciate it. When it comes to setting the row and column values of the png image I have how do I incorporate all the x,y values? Like I just have the image, I need to set the values for the image correct?
Image Analyst
Image Analyst on 24 Oct 2018
I'm not sure what that means. You don't do it to all pixels, just to a circle around the very brightest pixel. I'm not sure what "incorporate" means to you. Maybe if you attached your image and your desired result image it would help.

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!