clustering using rosette sampling
이전 댓글 표시
Hello guys. I have written this code for clustering a sampled image using a rosette pattern, but the results are confusing. please advise. thank you all in advance. use any image of your choice
a = imread('any_image');% original image
b = im2bw(a);
p = zeros();
b = zeros();
f1 = 165;
f2 = 155;
f = gcd(f1,f2);
T = 1/f;
N1 = f1/f;
N2 = f2/f;
N = N1+N2;
for t = 0.0001:0.00005:T;%picking random samples to test the code
tpif1 = 2*pi*f1*t;
tpif2 = 2*pi*f2*t;
% sig is the refractive index
sig = 1.5;
x = sig/2*(cos(tpif1) + cos(tpif2)); % rosette pattern equations.
y = sig/2*(sin(tpif1) - sin(tpif2));
%imagesc([min(x) max(x)],[min(y) max(y)],b);
if size(b,1)>size(b,2)
L = 0.5*size(b,2);
else
L = 0.5*size(b,1);
end
X = L + L*x/sig; % mapping the rosette pattern to the image
Y = L + L*y/sig;
if((round(Y)>0)&&(round(X)>0))
d(round(Y),round(X)) = b(round(Y),round(X));
end
% d is a sampled image
A = pi*(f1-f2)*t; % rosette pattern angle (polar form)
if (A>=0)
i = (A*N/pi)+1;
else
i = (A*N/pi)+(2*pi)+1;%rows or no of half petals
end
Np = 1/(2*f*N*t);%the number of samples in each half of a petal
NT = 2*N*Np;%total number of samples in all petals of the rosette pattern
for Nj= 1:NT;%desired no of samples
D = Nj/Np;
if(mod(D,2)==1)
j = Nj -(Np*D);%doesnot make sense
else
j = (1+D)*Np - Nj+1;% or Np + 1 but makes sense
end
end
j1 = round(j); % coordinates of the rosette in 2D space (rows and columns)
i1 = round(i);
%if(j1<2)
%break;
%end
disp('j1');
disp(j1);
disp('i1')
disp(i1);
%plot(j1,i1);
if((round(Y)>0)&&(round(X)>0))
p(i1,j1) = d(round(Y),round(X)); % appearance of the image in 2D space
imshow(p);
end
end
댓글 수: 2
Image Analyst
2012년 7월 6일
Where did you upload your image to? You forgot to tell us, so we can't run your code with your image.
Henry Kato
2012년 7월 9일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!