how to sort histogram generated count and corresponding gray value.. pls help
Mostrar comentarios más antiguos
m=imread('ll.bmp');
[count,gray]=imhist(m);
the answer is:

i want to sort the count and corresponding gray value..
and delete the zero count values answer like this..

Respuesta aceptada
Más respuestas (2)
Image Analyst
el 18 de Mayo de 2015
Don't use gray as a variable name - it's the name of a built in function that creates a colormap, and you just blew it away.
I don't know why you need to, but to get rid of array elements with zero counts
[count, grayLevels]=imhist(m);
rowsToDelete = count == 0;
count(rowsToDelete) = [];
grayLevels(rowsToDelete) = [];
5 comentarios
ARJUN K P
el 18 de Mayo de 2015
Image Analyst
el 18 de Mayo de 2015
They are already both sorted in terms of increasing gray level. There is a sort() command to use if you want some different kind of sorting, but you should probably take the sort order and apply it to both so that both arrays are always sorted in the same order.
Image Analyst
el 18 de Mayo de 2015
To sort in reverse order, simply use fliplr()
count = fliplr(count)
grayLevels = fliplr(grayLevels);
Image Analyst
el 19 de Mayo de 2015
% Sort count in descending order.
[sortedCounts, sortIndexes] = sort(count, 'descend');
% Sort grayLevels the same way.
grayLevels = grayLevels(sortIndexes);
ARJUN K P
el 19 de Mayo de 2015
0 votos
Categorías
Más información sobre Images en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

