Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Matlab中找到图像的最亮点并进行标记?_Matlab_Image Processing_Find_Max_Brightness - Fatal编程技术网

如何在Matlab中找到图像的最亮点并进行标记?

如何在Matlab中找到图像的最亮点并进行标记?,matlab,image-processing,find,max,brightness,Matlab,Image Processing,Find,Max,Brightness,亲爱的, 我想请你帮我写代码。我的目标是找到图像中最亮的点并标记它 我使用下面的代码以灰度值->获取图像,并尝试根据我的意图对其进行扩展 然后我找到矩阵的最大值,并使用for循环函数突出显示最大点的坐标。不幸的是,我在这里开始挣扎 rgbImage = imread( 'Zoom1_WhiteImage.png' ); %imshow(rgbImage); [rows, columns, numberOfColorChannels] = size(rgbImage) if numberO

亲爱的, 我想请你帮我写代码。我的目标是找到图像中最亮的点并标记它
我使用下面的代码以灰度值->获取图像,并尝试根据我的意图对其进行扩展
然后我找到矩阵的最大值,并使用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

您能帮我完成代码吗?

您可以通过函数
find()
或函数
ind2sub()
实现您的目标:


嗨,我没有很好地表达自己。从上面的代码中,我可以检测到所有高于阈值的像素。我的目的是从整个矩阵中找到最亮的像素并将其高亮显示。第一步应该是将RGB转换为灰色值。如果我知道矩阵的大小和最大值,那么我想用循环函数检测点。提前谢谢。这正是我的代码所做的,我不明白你的意思。你说的最亮像素是指最亮的像素吗?
% Random 2D matrix
I = rand(10);

% First option with find
[x,y] = find(I == max(I(:)))

% Second option using ind2sub, a bit more efficient since we only read I once.
[~,ind] =   max(I(:))
[x,y] = ind2sub(size(I),ind)