Generating histogram of a gradient image: histogram bar shows a white blank space within a histogram bar
Ältere Kommentare anzeigen
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?
Akzeptierte Antwort
Weitere Antworten (2)
Sat m
am 3 Mär. 2013
17 Kommentare
Image Analyst
am 3 Mär. 2013
Bearbeitet: Image Analyst
am 3 Mär. 2013
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
am 3 Mär. 2013
Sat m
am 3 Mär. 2013
Image Analyst
am 3 Mär. 2013
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
am 3 Mär. 2013
Image Analyst
am 3 Mär. 2013
Change these lines to this:
[pixelCounts, channels] = hist(sobelImage(:), 50); % hist, not imhist
bar(channels, pixelCounts);
% xlim([0 255]); % Comment out.
Sat m
am 3 Mär. 2013
Sat m
am 3 Mär. 2013
Image Analyst
am 3 Mär. 2013
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
am 3 Mär. 2013
Image Analyst
am 3 Mär. 2013
You need to put the subplot() before the call to bar().
Sat m
am 4 Mär. 2013
Sat m
am 4 Mär. 2013
Sat m
am 4 Mär. 2013
Image Analyst
am 4 Mär. 2013
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
am 4 Mär. 2013
Then call figure() instead of subplot().
Yahye abukar
am 11 Mai 2016
0 Stimmen
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 Kommentar
Image Analyst
am 12 Mai 2016
Yahye, simply use imgradient() - those methods are options for this function built-in to the Image Processing Toolbox.
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!