How to run nested loop (from 1 to mean value) & (from mean value to last value) of an image?
1 view (last 30 days)
Show older comments
I divide an image(I) into two subimages (I1 & I2) based on mean value. Now i want to access values of I1 (from 1 to mean value) & I2 (from mean value to last value) to get PDF of image, How to do it?
I = imread('f16.tif');
r=size(I,1);
c=size(I,2);
h1=uint8(zeros(r,c));
h2=uint8(zeros(r,c));
n1=r*c;
n2=r*c;
R=uint8(zeros(r,c));
f1=zeros(256,1);
f2=zeros(256,1);
pdf1=zeros(256,1);
pdf2=zeros(256,1);
cdf1=zeros(256,1);
cdf2=zeros(256,1);
cum1=zeros(256,1);
out1=zeros(256,1);
cum2=zeros(256,1);
out2=zeros(256,1);
Im=mean2(I);
I1=(I(r,c)<=Im);
I2=(I(r,c)>Im);
for i=1:r
for j=1:c
value1=I1(i,j);
f1(value1+1)=f1(value1+1)+1;
pdf1(value1+1)=f1(value1+1)/n1;
end
end
for i=1:r
for j=1:c
value2=I2(i,j);
f2(value2+1)=f2(value2+1)+1;
pdf2(value2+1)=f2(value2+1)/n2;
end
end
0 Comments
Answers (1)
KALYAN ACHARJYA
on 18 Jan 2021
Is this?
mean_val=mean2(grayImage);
Image_I1=grayImage(grayImage>mean_val);
Image_I2=grayImage(grayImage<=mean_val);
subplot(211),imhist(Image_I1);
subplot(212),imhist(Image_I2);
Or
Get the PDF of Image_I1 and I2
https://in.mathworks.com/help/stats/prob.normaldistribution.pdf.html
3 Comments
KALYAN ACHARJYA
on 24 Jan 2021
Edited: KALYAN ACHARJYA
on 24 Jan 2021
If you have checked the Histo distribution map, you can get the answer from there also?? Probability distribution map of pixels onthe particular subimage??
Otherwise, can you define the problem again, what do you have and what are you looking for (as a minimal as possible with necessity information)?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!