Plotting a histogram against the width of a connected component (Using hist as plot)
2 views (last 30 days)
Show older comments
Hi.
The concept of the paper is to plot the intensity of a grayscale image at a selected threshold against the width or area of the connected components.
I've been trying to figure out how to do this in Matlab. One of my implementations was to use the plot command and to plot the area of the connected components against the threshold level of the image. But it did not produce a similar result. Also my plot is the area against the threshold level. It should be area against the intensity.
Here is my attempt at it:
img = rgb2gray(imread('urdu.jpg'));
for k = 1:-0.01:0
bw_normal = im2bw(img, k);
bw = imcomplement(bw_normal);
[label,n] = bwlabel(bw);
stats = regionprops(label, 'Area');
plot([stats.Area],k);
axis([0 350 0 1.1])
hold on;
end
Here is what it produces:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156353/image.jpeg)
According to the paper this is what it should look like:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156354/image.jpeg)
As can be seen to the left are the intensity levels of the grayscale image (0 - 255). The only way I can see this happening is to combine histograms. But then again histograms can only be plotted against number of bins not any property of a connected component, and also I do not know how to add histograms like this.
Some insight would be appreciated.
Thank you
0 Comments
Answers (0)
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!