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!