Generating histogram of a gradient image: histogram bar shows a white blank space within a histogram bar
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (2)
Sat m
le 3 Mar 2013
17 commentaires
Image Analyst
le 3 Mar 2013
Modifié(e) : Image Analyst
le 3 Mar 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
le 3 Mar 2013
Sat m
le 3 Mar 2013
Image Analyst
le 3 Mar 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
le 3 Mar 2013
Image Analyst
le 3 Mar 2013
Change these lines to this:
[pixelCounts, channels] = hist(sobelImage(:), 50); % hist, not imhist
bar(channels, pixelCounts);
% xlim([0 255]); % Comment out.
Sat m
le 3 Mar 2013
Sat m
le 3 Mar 2013
Image Analyst
le 3 Mar 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
le 3 Mar 2013
Image Analyst
le 3 Mar 2013
You need to put the subplot() before the call to bar().
Sat m
le 4 Mar 2013
Sat m
le 4 Mar 2013
Sat m
le 4 Mar 2013
Image Analyst
le 4 Mar 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
le 4 Mar 2013
Then call figure() instead of subplot().
Yahye abukar
le 11 Mai 2016
0 votes
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 commentaire
Image Analyst
le 12 Mai 2016
Yahye, simply use imgradient() - those methods are options for this function built-in to the Image Processing Toolbox.
Catégories
En savoir plus sur Contrast Adjustment dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!