how to re-find the landmark locations after imcrop !!

3 次查看(过去 30 天)
In my gray scale image, I have a set of landmark points that i know their positions(xi,yi). I calculate my rectangular region then i use imcrop to extract the ROI from the original image then I use imresize to [120*120]. The problem is that I need again the locations of my Landmark for further treatment.After these transformation(imcrop-imresize) I can not understand how to find their new coordinatess!!? Any Help Please......

回答(2 个)

Image Analyst
Image Analyst 2016-2-12
First subtract the leftX and topY from the x and y values you have, then multiply them by the scaling factors you used in the resize.
  2 个评论
Omokhadija
Omokhadija 2016-2-12
This is my code:
[I, rect]=imcrop(Image); %%top left point x1=rect(1); y1=rect(2); %%Height+Width x2=rect(1)+rect(3); y2=rect(2)+rect(4); [A]=imresize(I,[96 96],'bilinear'); %%List of Landmarks point L=[305 264;343 263;327 280;326 302]; %%Translation T=[ rect(1) rect(2)]; %%Sclae sc1=96/rect(3); sc2=96/rect(4);
XXL=[]; for i=1:size(L,1) XXL(i,:)=L(i,:)-T; XXL(i,1)=sc1*XXL(i,1); XXL(i,2)=sc2*XXL(i,2); end
figure(5), imshow(A);hold on, plot( XXL(:,1),XXL(:,2) ,'r.','markersize',15);
When i plot the new points they didn't match with the supposed locations ...I think i have some error when applying sclae!!Can youhelp please!!

请先登录,再进行评论。


Omokhadija
Omokhadija 2016-2-12
This is my code:
[I, rect]=imcrop(Image); %%top left point x1=rect(1); y1=rect(2); %%Height+Width x2=rect(1)+rect(3); y2=rect(2)+rect(4); [A]=imresize(I,[96 96],'bilinear'); %%List of Landmarks point L=[305 264;343 263;327 280;326 302]; %%Translation T=[ rect(1) rect(2)]; %%Sclae sc1=96/rect(3); sc2=96/rect(4);
XXL=[]; for i=1:size(L,1) XXL(i,:)=L(i,:)-T; XXL(i,1)=sc1*XXL(i,1); XXL(i,2)=sc2*XXL(i,2); end
figure(5), imshow(A);hold on, plot( XXL(:,1),XXL(:,2) ,'r.','markersize',15);
When i plot the new points they didn't match with the supposed locations ...I think i have some error when applying sclae!!
  2 个评论
Brattv
Brattv 2016-2-12
编辑:Brattv 2016-2-12
Please copy the code to the commentary field, mark the code and then press the {}Code button
The result will be much easier to read
for i=1:end
do something
do something 1
looks much better
end
Omokhadija
Omokhadija 2016-2-12
[I, rect]=imcrop(Image);
%%top left point %%
x1=rect(1); y1=rect(2);
%%Height+Width %%
x2=rect(1)+rect(3);
y2=rect(2)+rect(4);
[A]=imresize(I,[96 96],'bilinear');
%%List of Landmarks point %%
L=[305 264;343 263;327 280;326 302];
%%Translation%%
T=[ rect(1) rect(2)]; %%Sclae sc1=96/rect(3); sc2=96/rect(4);
XXL=[]; %% for i=1:size(L,1)
XXL(i,:)=L(i,:)-T;
XXL(i,1)=sc1*XXL(i,1);
XXL(i,2)=sc2*XXL(i,2); end
figure(5), imshow(A);hold on, plot(XXL(:,1),XXL(:,2),'r.','markersize',15);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Feature Detection and Extraction 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by