imtransform had shift my center
Afficher commentaires plus anciens
Hi, I had 3 images which size 200*200. I would want to aggregate those image with same center after they have been imtransform. Those 3 images are eye scanning. so let's say there is a optic disc, assume it is a circle and I had it's center coordinate. So for example the first image center is 100,100 (this is perfect),2nd is 101,101(so I had to shift -1,-1 to aggregate the 2nd image with the 1st), the last one is 130,130. However, I had calculate that even the optic disc(the circle) had it own center, the image is not scan properly. Therefore I had to rotate my images. I had a Tform and tried to use imtransform. It look okay after the images transform, and I know the image will have difference size, since the I don't want any information lose. Then I change the image size to 300,300. Since I need to aggregate those 3 images to center 150,150 which is the middle of the images. I had try to use imtranslate, which should be fine. However, everytime I try to aggregate the image, the shifting/center is not correct. Below is the code which I had tried.
for n=1:no_of_pics
temp_recover=cell2mat(T(n,1));
%if it is left eye, it need to be fliped
if analyzingEye=='OS'
temp_recover=flipdim(temp_thickness,2);
end
temp_recover(isnan(temp_recover))=0;
%peaks is the center detected by hough method
temp_xcenter=ceil(peaks(1,n)*200/668);
temp_ycenter=ceil(peaks(2,n)*200/668);
% matrix below is trying to rotate the image about the certain center not the origin
temp_tocenter=[1 0 0;0 1 0;-(150-temp_xcenter) -(150-temp_ycenter) 1];
temp_back=[1 0 0;0 1 0;150-temp_xcenter 150-temp_ycenter 1];
temp_recover=imtransform(temp_recover,maketform('affine',temp_tocenter*cell2mat(TTFORM(n,1))*temp_back),'XData',[1 301],'YData',[1 301]);
end
However by using this method, the center is shifted to somewhere I don't know. Therefore, I had use another code;
for n=1:no_of_pics
temp_recover=cell2mat(T(n,1));
if analyzingEye=='OS'
temp_recover=flipdim(temp_thickness,2);
end
temp_recover(isnan(temp_recover))=0;
temp_xcenter=ceil(peaks(1,n)*200/668);
temp_ycenter=ceil(peaks(2,n)*200/668);
temp_recover=imtransform(temp_recover,maketform('affine',cell2mat(TTFORM(n,1))));
%I am trying to expand the matrix to 300*300 so that I can aggregate the center and no information lost
temp_recover(300,300)=0;
temp_recover=imtranslate(temp_recover,[151-temp_xcenter,151-temp_ycenter],'fillvalue',0);
end
It did better, but still the circle is not perfectly match. I am very frustrated on this. Can someone point out where I had done wrong? Thank you very much
Réponse acceptée
Plus de réponses (1)
Marco Yu
le 9 Août 2016
Catégories
En savoir plus sur Simulink dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!