이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
how can i find more than one minimum points of the histogram??
조회 수: 2 (최근 30일)
이전 댓글 표시
Suppose I have a histogram and I want to find the minimum point of the histogram other than 0, then what procedure I should follow? In the histogram image below, the minimum point is approximately 10,15,17. Then how can I find this?
답변 (2개)
Image Analyst
2015년 2월 5일
Try this
% Get histogram
[pixelCounts, grayLevels] = imhist(grayImage);
% Find darkest bin with more than 15 pixels in it
darkestGL = find(pixelCounts > 15, 1, 'first');
댓글 수: 36
Image Analyst
2015년 2월 5일
OK.
But what does that mean?
You can adjust the 15 in my code to be whatever you want to select whatever x value (bin, gray level) you want. Attach your data if you want more help.
user06
2015년 2월 6일
편집: Image Analyst
2015년 2월 6일
Your code is just giving the continuous no...
I=imread('lena.jpg');
% Get histogram
[pixelCounts, grayLevels] = imhist(I);
% Find darkest bin with more than 15 pixels in it
darkestGL = find(pixelCounts > 12, 56, 'first');
%imhist(I);
fprintf('%d, ',darkestGL);
Image Analyst
2015년 2월 6일
That's not my code exactly - you modified it to take the first 56 gray levels after the count exceeded 12. The counts exceed 12 around maybe gray level 30 or so. So, since graylevels from 30 on up to about 240 are all above 12, you will get the first 56 of those, which would be gray levels of 30 to 30 + 56 -1 = 30 to 85. In other words, you'll get an array like [30,31,32,33,34,35,........84,85].
I have no idea why you changed my code to return 56 gray levels instead of 1 (the very first one only).
user06
2015년 2월 7일
i was jst checking that code thats why i modified it.but i want three minimum point as i explained in the ques with the help of a graph. plz help
Image Analyst
2015년 2월 7일
I'm having trouble with your English. You said "the minimum point is approximately 10,15,17." Well, point is singular but you list 3 gray levels, not one . So did you really mean "the minimum points are approximately 10,15, and 17." I have no idea .
And my code gave a single number so I don't understand what it means when you say my code is "giving the continuous no." Again, it's a single number , not a range of continuous anything .
And I don't understand how modifying the call to find to return 56 elements will get 3 of anything. I'm not sure how checking my code involved modifying it to return 56 elements instead of the one minimum element.
Like I asked you before to make it easier to help you "Attach your data if you want more help." Like the lena image or the histogram array. You are not attaching anything. I do not know why.
I really have no idea how to help you now, unless you attach data and clearly explain what gray levels or counts in your histogram you want to detect/extract/determine/find.
user06
2015년 2월 8일
this fig is histogram of lena image.and in this histogram i want to find 3 minimum points other than 0.
Image Analyst
2015년 2월 8일
You did not answer any of my questions at all - you just paraphrased the same unclear request. lena is not a standard image that ships with MATLAB, and neither is your code. Now, for the third time , I'm asking you to attach your data (image plus code). If you don't do that I'll assume you don't want anymore help.
Also again, explain if you want the minimum gray levels with non-zero counts or the minimum counts (at whatever gray level they happen to occur at).
user06
2015년 2월 9일
Image Analyst
2015년 2월 9일
편집: Image Analyst
2015년 2월 9일
% Check which bins, other than the first one at zero gray level,
% are not zero:
nonZeroBins = find(pixelCounts1(2:end) > 0);
% Add 1 to get bins referenced to the full array again.
nonZeroBins = nonZeroBins + 1;
% Extract only the 3 darkest gray levels.
darkest3GLs = grayLevels1(nonZeroBins(1:3));
Image Analyst
2015년 2월 10일
Look at the histogram and tell me what values (gray levels, bins) would you want it to return? Don't make me guess again.
user06
2015년 2월 11일
편집: Image Analyst
2015년 2월 11일
I have a doubt. If I write this, then I get an error.
a= imread('lena.jpg');
b=imresize(a,[256 256]);
imhist(b);
[pixelCounts, grayLevels] = imhist(b);
nonZeroBins = find(pixelCounts(2:end) > 0);
% Add 1 to get bins referenced to the full array again.
nonZeroBins=nonZeroBins+1;
% Extract only the 3 darkest gray levels.
darkest3GLs = grayLevels(nonZeroBins(1:3));
fprintf('%d ',darkest3GLs);
and the error is:
Attempt to call constructor image with incorrect letter case.
Error in ==> imhist>plot_result at 166
image(xdata,[0 1],repmat(C, [1 1 3]),'Parent',stripe_axes);
Error in ==> imhist at 90
plot_result(x, y, map, isScaled, class(a), range);
Error in ==> checking at 3
imhist(b);
and in the histogram i want 2 1 3 as the ans on the x axis.
Image Analyst
2015년 2월 11일
First of all, I ran your code and it works find and does not give an error in imhist and does not display an image like you just showed. This is what it displays:
Somehow you must have converted a or b to double.
But I really don't know what you mean when you say you want 2 1 3 on the x-axis. Why? Instead of all the gray levels that are normally placed by the x-axis tick marks?
user06
2015년 2월 11일
ok. i figured out that nw there is no error.. i need to find three minimum point or u can say 3 garay level with minimum value,they can be any where on the x axis.
Image Analyst
2015년 2월 11일
The three darkest gray levels are 0, 1, and 2. The 3 darkest gray levels that are present in the image can be gotten with the code I gave you that finds the 3 darkest bins that have at least one pixel counted in them. Bin 0 has 4 pixels in it. Bin 1 has 4 pixels in it, and bin 2 has 2 pixels in it. Therefore they are the three minimum gray levels. Do you have some different definition? If so, what?
user06
2015년 2월 12일
i m not getting what u r saying... actually i need to make a algorithm i.e i m going to attach...
Image Analyst
2015년 2월 12일
Oh, it's a homework problem, though I'd agree with you it's a very poorly written one with several notational errors and ambiguities. You were supposed to reveal it was homework in the beginning by tagging it as homework. I'll do that for you.
I've given you code to do much of your homework already. Which of the questions do you need a hint for? Or my guess at what the instructor is asking for (in an admittedly unclear manner in many of the questions)?
user06
2015년 2월 13일
actually i need to find the points which is described in the section b step 2 of the algorithm. or is there a way by that we can store the histogram values in array or we sort that array, by that 3 minimum points we can get easily?
Image Analyst
2015년 2월 13일
Try this:
grayImage = imread('lena.jpg');
% Get histogram
[h, grayLevels] = imhist(grayImage);
% Sort the counts to find the gray levels with the fewest counts
% Let's assume they don't really want to count bins with no pixels in them
% because those gray levels are not present in the actual image.
% So set those bins = inf so they won't be sorted
h(h == 0) = inf;
% Now do the sort in order of increasing count:
[sortedGLs, sortIndexes] = sort(h, 'ascend');
% Find the 3 bins with the fewest number of counts in them
darkestGLs = sortIndexes(1:3)
% Sort in increasing order of gray levels
% Because even though the counts are sorted,
% the bin numbers (gray levels) could be anywhere.
darkestGLs = sort(darkestGLs, 'Ascend');
% Get the "b"s
b1 = darkestGLs(1)
b2 = darkestGLs(2)
b3 = darkestGLs(3)
% Get the counts in those bins:
hb1 = h(b1)
hb2 = h(b2)
hb3 = h(b3)
Image Analyst
2015년 2월 15일
Yes. That's right. Because the three darkest bins each have one pixel in them. Do you not think that's right? Look at what your professor says:
"In the histogram, find three minimum point h(b1), h( b2), h(b3). Assume three of them satisfy the following condition: 0<b1<b2<b3<255."
So if the h array is the histogram, meaning that it is an array holding the counts of pixels having each gray level, then, assuming you don't want to consider gray levels that have no pixels with that intensity, the minimum h(bin) would be where h(bin) equals 1, meaning it has one pixel with that gray level in the image. Then I found three gray levels that had 1 count. Why are you uncertain about this?
user06
2015년 2월 16일
but it is showing 1 1 1 then by that b1=b2 =b3. and if this is the case then in the next step we have to determine maximum points between (0,b1) and(b3,255) then ??????
Image Analyst
2015년 2월 16일
Anamika, there are probably lots of bins that have only one count in them. Which three do you want?
Image Analyst
2015년 2월 16일
편집: Image Analyst
2015년 2월 17일
I did that. The lowest bin has one count in it and it occurs at bin 236. The second lowest bin also has only one pixel in it, and it occurs at gray level 237, and the third lowest bin also has only one count in it and it occurs at 247. In fact, there are 6 bins , not only 3, that have only one pixel counted in them.
user06
2015년 2월 18일
that is a hindi word, that i wrote in hurry...'how did i found that points as the answer?'.
Image Analyst
2015년 2월 20일
I'm afraid I don't know how to help any differently. I gave you code that will answer the homework question but, for some reason that you can't explain, you don't like it. You say it doesn't give the 3 lowest/shortest bins, but it actually does . So good luck with it - finding your own algorithm.
user06
2015년 2월 20일
and the code u have given is just giving the first 3 minimum points. i want overall 3 minimum points
Jos (10584)
2015년 2월 17일
You can sort the outcome of the histogram
data = ceil(10*rand(100,1))
values = 1:10
count = histc(data,values)
[SortedCount, idx] = sort(count)
SortedValues = values(idx)
disp([SortedValues(:) SortedCount(:)])
댓글 수: 6
Jos (10584)
2015년 2월 21일
Yes, because data is just an example containing values between 1 and 10. Then I sorted the count in ascending order, and sorted the values along with it. The first element of the sorted counts is belonging to the value that occurs least often (i.e., the minimum of the histogram!), the second element is the second minimum etc. If you run the code and look out the outputs you may see what happens.
user06
2015년 2월 21일
it is not sorting values as per the requirement. i want sorted values on x axis with respect to y. means the value on the x axis having the lowest value on the y axis, that should come first and so on.
Image Analyst
2015년 2월 21일
I did that in my code above. Like I said, "the lowest bin has one count in it and it occurs at bin 236. The second lowest bin also has only one pixel in it, and it occurs at gray level 237, and the third lowest bin also has only one count in it and it occurs at 247." Explain why 1 is not the lowest y value (count in the bin), and explain why 236,237,247 is not sorted.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)