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

4 views (last 30 days)
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......
  1 Comment
Brattv
Brattv on 12 Feb 2016
Hi, it would be easier to help if you provide the code you have written.

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 12 Feb 2016
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 Comments
Omokhadija
Omokhadija on 12 Feb 2016
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!!

Sign in to comment.


Omokhadija
Omokhadija on 12 Feb 2016
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 Comments
Brattv
Brattv on 12 Feb 2016
Edited: Brattv on 12 Feb 2016
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 on 12 Feb 2016
[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);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!