how to sort histogram generated count and corresponding gray value.. pls help

6 vues (au cours des 30 derniers jours)
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..

Réponse acceptée

ARJUN K P
ARJUN K P le 20 Mai 2015
Modifié(e) : ARJUN K P le 20 Mai 2015
i got answer from :
https://www.facebook.com/thematrixcoded
the code is :
m=imread('ll.bmp');
>> [c,g]=imhist(m);
>> K=[c,g];
>> Ks=sortrows(K);
Ki=Ks(end:-1:1,:);
Ki(Ki(:,1)==0,:)=[];
>> Ki
Thanku all for supporting
  1 commentaire
Image Analyst
Image Analyst le 20 Mai 2015
It does the same thing that I did but combined the counts and gray level arrays into a single 2D array (which we didn't know you wanted to do).

Connectez-vous pour commenter.

Plus de réponses (2)

Image Analyst
Image Analyst le 18 Mai 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 commentaires
Image Analyst
Image Analyst le 18 Mai 2015
To sort in reverse order, simply use fliplr()
count = fliplr(count)
grayLevels = fliplr(grayLevels);
Image Analyst
Image Analyst le 19 Mai 2015
% Sort count in descending order.
[sortedCounts, sortIndexes] = sort(count, 'descend');
% Sort grayLevels the same way.
grayLevels = grayLevels(sortIndexes);

Connectez-vous pour commenter.


ARJUN K P
ARJUN K P le 19 Mai 2015
sir you mistaken, i want sort the count in decreasing order...
eg:
before sorting
after sorting
i want ans like
  2 commentaires
ARJUN K P
ARJUN K P le 19 Mai 2015
its not i want.. i want to sort the count in decreasing order and corresponding gray value.. that i show in above figure...

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by