简体   繁体   中英

Find what is the maximum intensity pixel in an image

I have a tif file and I need to find the coordinates of the maximum intensity pixel. How would you solve this?

Thanks!

You can get the max value and it's index in the image with just max :

[maxVal,maxInd] = max(img(:));

If you are working with a RGB image, convert it to HSV and use the value component:

imgHSV = rgb2hsv(imgRGB);
img = imgHSV(:,:,3);

Also note that if there are multiple locations with the maximum value, max returns the index of the first occurrence. To get all indexes with the maximum value,

allMaxValsMask = img==maxVal;

The simplest way is:

% Find max value
maxValue = max(max(image));
% Find the pixel idx corresponding to that value
idx = find(image == maxValue);

If you have more than one value at maxValue , idx will be a vector containing all indexes at maxValue .

Also, the indexes in idx will be linear (not x,y coordinates). Depending on what you what, you might need to convert it back.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM