MATLAB: How to find the brightest spot in an image using the Image Processing Toolbox

brightbrightesthsvilluminanceimageImage Processing Toolboxrgbspot

I want to be able to do this programmatically and not by using PIXVAL or IMPIXEL functions.

Best Answer

The following piece of user-contributed code finds the brightest spot in an image:
% Assume I is the image you have with RGB values.
% Assume I is a matrix of [row,col, 3] of RGB values.
% First, convert it to HSI space
hsv = rgb2hsv(I);
%get the illuminance channel
v = hsv(:,:,3);
%find the max pixel value
max_v = max(max(v));
% find the position of pixels having this value.
[r, c] = find(v == max_v);
% here, r are rows, c are columns.
Related Question