how to sort histogram generated count and corresponding gray value.. pls help
조회 수: 7 (최근 30일)
이전 댓글 표시
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..
댓글 수: 0
채택된 답변
ARJUN K P
2015년 5월 20일
편집: ARJUN K P
2015년 5월 20일
댓글 수: 1
Image Analyst
2015년 5월 20일
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).
추가 답변 (2개)
Image Analyst
2015년 5월 18일
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
Image Analyst
2015년 5월 18일
To sort in reverse order, simply use fliplr()
count = fliplr(count)
grayLevels = fliplr(grayLevels);
Image Analyst
2015년 5월 19일
% Sort count in descending order.
[sortedCounts, sortIndexes] = sort(count, 'descend');
% Sort grayLevels the same way.
grayLevels = grayLevels(sortIndexes);
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!