this is the code with nested loop for pdf. How can i use pdf function here instead of loop?
이전 댓글 표시
It divides image into 2 subimage based on mean. How I use pdf function instead of loop to get
1) pdf1 from (1 <= mean) & for
2) pdf2 from (mean+1 > last value)
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
댓글 수: 8
Jan
2021년 2월 5일
See also your other question: https://www.mathworks.com/matlabcentral/answers/736892-how-to-create-nested-loop-for-following-equation#comment_1309417
The code stops with an error in value1=I1(i,j); , because after I1=(I(r,c)<=Im); I1 is a scalar.
Jagdeep S
2021년 2월 6일
Again: The posted code does not run. Then it is impossible to decide, if another function creates the same output.
The description "divide an image into two subimages based on mean" is not unqiue. Then it is your turn either to provide running code or an exhaustive and clear definition of what you want to achieve. What exactly do you call "image"? The "mean" of what? What is a "subimage"? How do you "add subimages"?
Jagdeep S
2021년 2월 7일
Jan
2021년 2월 7일
It is getting less clear for me with every additional comment. You ignore my message, that the code you have posted does not run and my suggestion how to fix it. Just repeating your statements without answering my questions for clarifications does not allow to reconsider, what you are trying to do. I give up at this point.
Aswini B
2021년 5월 26일
did you get the code?
Jan
2021년 5월 26일
Did who get which code?
I still do not understand, what your question is.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Univariate Discrete Distributions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

