Generating histogram of a gradient image: histogram bar shows a white blank space within a histogram bar
이전 댓글 표시
I have generated a sobel gradient map of an image and now i have to generate the histogram of that gradient map. i did this
[rows, columns, numberOfColorBands] = size(sobelImage);
[pixelCounts, channels] = imhist(sobelImage, 256);
bar(channels, pixelCounts);
xlim([0 255]);
drawnow();
The sobel image is coming good, there is no error. but when i generate the histogram, i can only see a the color scale and a white blank space. can you please tell me how to work through this? and i am asked to only keep certain percentage of pixels from the histogram (e.g. 5% of the highest gradient values) as edge pixels (edgels) and then to use the percentage to find a threshold for the gradient magnitudes. can you please tell me how to solve this?
채택된 답변
추가 답변 (2개)
Sat m
2013년 3월 3일
댓글 수: 17
Image Analyst
2013년 3월 3일
편집: Image Analyst
2013년 3월 3일
You should have made this a comment, since it's not an answer to your original question. See my demo in my answer above.
Sat m
2013년 3월 3일
Sat m
2013년 3월 3일
Image Analyst
2013년 3월 3일
If you're going to want me to run custom code that does not use a standard demo image, then you should upload your violet.bmp image and let me know where it is.
Sat m
2013년 3월 3일
Image Analyst
2013년 3월 3일
Change these lines to this:
[pixelCounts, channels] = hist(sobelImage(:), 50); % hist, not imhist
bar(channels, pixelCounts);
% xlim([0 255]); % Comment out.
Sat m
2013년 3월 3일
Sat m
2013년 3월 3일
Image Analyst
2013년 3월 3일
You didn't change the code like I said. See where I commented out xlim()? Plus, your last subplot is not going to apply to anything since nothing comes after it.
Sat m
2013년 3월 3일
Image Analyst
2013년 3월 3일
You need to put the subplot() before the call to bar().
Sat m
2013년 3월 4일
Sat m
2013년 3월 4일
Sat m
2013년 3월 4일
Image Analyst
2013년 3월 4일
Well what frame do you want them in? In a 2 by 2 array, you can put them into 1-4.
subplot(2,2,1); % Third arg can be 1 - 4. 1-2 is first row, 3-4 is second row.
If you want more, do a 2 by 3 array and you can have up to 6 simultaneously:
subplot(2,3,1); % Third arg can be 1 - 6. 1-3 is first row, 4-6 is second row.
Image Analyst
2013년 3월 4일
Then call figure() instead of subplot().
Yahye abukar
2016년 5월 11일
0 개 추천
hellow sir i run your code it works fine, but i need to change this code into Prewitt's and Roberts Operators, how i can change this code? thanks
댓글 수: 1
Image Analyst
2016년 5월 12일
Yahye, simply use imgradient() - those methods are options for this function built-in to the Image Processing Toolbox.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!