histogram by not using the default imhist
Ältere Kommentare anzeigen
I1 = imread('RDL.jpg');
raw = im2double(I1(:,:,1));
m=max(max(raw));
m1=min(min(raw));
binsize=(m-m1)/10;
for i=1:1:size(raw,1)
for j=1:1:size(raw,2)
value=raw(i,j); %read input image level
if value >= min(min(raw)) && value <= max(max(raw))
for i=1:1:10
if value <= i*binsize+min(min(raw))+ value > (i-1)*binsize+min(min(raw))
% original histogram in pixels
imhist(i)=imhist(i)+1;
% normalized histogram pdf
%InputIm_normalized_histogram(i)=InputIm_histogram(i)/resolution;
end
end
end
end
end
imhist(i)
I have used the code to plot a histogram from the image below. I want the graph similar to the attached image. But I am not able to get it. Kindly let me know where have I made the mistake.

3 Kommentare
Jan
am 13 Mär. 2021
You forgot to mention, why you assume, that there is a mistake.
Vaswati Biswas
am 13 Mär. 2021
Jan
am 13 Mär. 2021
imhist(i) is a scalar, because you have defined it as a vector. Your code does not contain a command to dispaly a graph.
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 14 Mär. 2021
1 Stimme
Then why not simply use histogram() or histcounts()? Why do you want to write (buggy) code yourself?
3 Kommentare
Vaswati Biswas
am 14 Mär. 2021
Bearbeitet: Vaswati Biswas
am 14 Mär. 2021
Image Analyst
am 14 Mär. 2021
That doesn't explain why you don't use the built-in histogram functions.
Vaswati Biswas
am 15 Mär. 2021
Bearbeitet: Vaswati Biswas
am 15 Mär. 2021
Kategorien
Mehr zu Image Arithmetic 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!

