답변 (1개)

Image Analyst
Image Analyst 2021년 4월 20일

1 개 추천

What is a "punch" of images? And what is your definition of brightest for a color image? Do you just want to convert to gray scale and find the brightest? Something like (untested)
grayImage = rgb2gray(rgbImage);
maxValue = max(grayImage(:))
maxMap = grayImage == maxValue;
rgb2 = imoverlay(grayImage, maxMap);
imshow(rgb2);

댓글 수: 11

Mohamed Elbeialy
Mohamed Elbeialy 2021년 4월 20일
Just need to find the max value on each image, then imshow the result
Image Analyst
Image Analyst 2021년 4월 20일
OK, then you're all set. Did you try it?
Mohamed Elbeialy
Mohamed Elbeialy 2021년 4월 20일
I tried it and it marked the top of the image in some case and did not show any differencce in other cases. Is that the correct max value on an image. How about if I want to adjust the max value to specific number like 3?
Walter Roberson
Walter Roberson 2021년 4월 20일
편집: Walter Roberson 2021년 4월 20일
rgbImage = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/591002/image.jpeg');
grayImage = rgb2gray(rgbImage);
maxValue = max(grayImage(:))
maxValue = uint8 255
maxMap = grayImage == maxValue;
R = grayImage;
G = grayImage;
B = grayImage;
R(maxMap) = 255;
G(maxMap) = 0;
B(maxMap) = 0;
rgb2 = cat(3,R,G,B);
image(rgb2);
nnz(maxMap)
ans = 34
[r,c] = find(maxMap);
[r(1), c(1)]
ans = 1×2
328 39
figure
image(rgb2); hold on
scatter(c, r, 'b*')
hold off
Mohamed Elbeialy
Mohamed Elbeialy 2021년 4월 20일
Why should it be converted to grayimage, could I use it as colored ?
rgbImage = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/591002/image.jpeg');
grayImage = rgb2gray(rgbImage);
maxValue = max(grayImage(:))
maxValue = uint8 255
maxMap = grayImage == maxValue;
R = rgbImage(:,:,1);
G = rgbImage(:,:,2);
B = rgbImage(:,:,3);
R(maxMap) = 255;
G(maxMap) = 0;
B(maxMap) = 0;
rgb2 = cat(3,R,G,B);
image(rgb2);
nnz(maxMap)
ans = 34
[r,c] = find(maxMap);
[r(1), c(1)]
ans = 1×2
328 39
figure
image(rgb2); hold on
scatter(c, r, 'b*')
hold off
Mohamed Elbeialy
Mohamed Elbeialy 2021년 4월 20일
How to apply the code to number of images then save the new images in a new folder .
Also, remove the image scale
If you use imoverlay, and the max occurs only at a few isolated pixels, then it won't be very visible will it? You can put hold on and use a marker like s cross or spot to make it more visibile. Control the size of the spot with the 'MarkerSize' option
hold on
plot(c, r, 'r.', 'MarkerSize', 15); % Or whatever size you want.
Mohamed Elbeialy
Mohamed Elbeialy 2021년 4월 21일
How to classify images depending on the shape of each image's object
Image Analyst
Image Analyst 2021년 4월 21일
@Mohamed Elbeialy, I'll take a look at that when/if I get time. But did this answer solve this problem? If so, please accept it.

댓글을 달려면 로그인하십시오.

제품

릴리스

R2020a

질문:

2021년 4월 20일

댓글:

2021년 4월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by