How to find the highest gray value in a color image?

How do we find the highest gray values in a color image. If this highest gray value in certain channel, for example, further, how do we find out other locations which have highest gray value?

 Respuesta aceptada

grayimage = rgb2gray(YourRGBImage);
maxgray = max(grayimage(:));
grayidx = find(grayimage == maxgray);
These are the linear indices. If you want row and column instead then use
[grayidxrow, grayidxcol] = find(grayimage == maxgray);

4 comentarios

matlabgeek
matlabgeek el 20 de En. de 2016
Thanks. This is what I want
matlabgeek
matlabgeek el 20 de En. de 2016
If [grayidxrow, grayidxcol] has only one value individual, so this means there is only one location has maxgray?
Correct.
If by "highest gray value in certain channel" then you mean the highest red value, the highest green value, and the highest blue value, then you'd to that on each color channel independently.
maxR = mean2(rgbImage(:,:,1));
maxG = mean2(rgbImage(:,:,2));
maxB = mean2(rgbImage(:,:,3));
Of course the highest in each channel may not all lie at the very same pixel. The brightest red value may lie at a different place than the highest blue value.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Modify Image Colors en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 20 de En. de 2016

Comentada:

el 20 de En. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by