【发布时间】:2021-07-13 11:51:53
【问题描述】:
亲爱的,
我想向您寻求代码方面的帮助。我的目标是找到图像的最亮点并标记它。
我使用以下代码以灰度值获取图像 -> How to find and highlight the brightest region an image in Matlab? 并尝试根据我的意图对其进行扩展。
然后我找到了矩阵的最大值并使用 for 循环函数来突出显示最大点的坐标。不幸的是,在这里我已经开始挣扎了。
rgbImage = imread( 'Zoom1_WhiteImage.png' );
%imshow(rgbImage);
[rows, columns, numberOfColorChannels] = size(rgbImage)
if numberOfColorChannels == 1
brightness = rgbImage; % For a 1 channel image, brightness is the same as the original pixel value.
else
% For an RGB image, the brightness can be estimated in various ways, here's one standard formula:
brightness = (0.2126*rgbImage(:, :, 1) + 0.7152*rgbImage(:, :, 2) + 0.0722*rgbImage(:, :, 3));
end
% Establish a brightness threshold - pixels brighter than this value will
% be highlighted
threshold = 105;
% Create a zero-filled mask of equal size to the image to hold the
% information of which pixels met the brightness criterion:
mask = zeros(rows, columns, 'logical');
% Assign "1" to any mask pixels whose corresponding image pixel met the
% brightness criterion:
mask(brightness > threshold) = 1;
[a,b] = size(brightness)
maxgrey = max(max(brightness));
aux=0;
for i=1:1:a;
for j=1:1:b;
if brightness(a,b)>brightness(a,b+1)
aux=brightness(a,b+1)
else aux
end
end
end
你能帮我完成代码吗?
【问题讨论】:
标签: matlab image-processing find max brightness