How to convert a point in image imrotated with loose option to a point in image imrotated with crop option in Matlab? -
how find relation between image imrotated
loose option image 1 , image imrotated
crop option image 2 ? angle of rotation not necessary -45° ...
i = imread('cameraman.tif'); im1 = imrotate(i,-45); % bbox option sets 'loose' default im2 = imrotate(i,-45,'nearest','crop'); % bbox option sets 'crop' figure(1); subplot(2,1,1), imagesc(im1), axis image; subplot(2,1,2), imagesc(im2), axis image;
i mean if choose point (x1,y1) im1 equation of relation (x2,y2) in im2 ?? looking loose2crop()
equation ?
i found solution , please feel free check fun :)
i = imread('cameraman.tif'); im1 = imrotate(i,-45); % image imrotated loose option im2 = imrotate(i,-45,'nearest','crop');% image imrotated crop option % draw image 1 loose figure(1); subplot(2,1,1), imagesc(im1), axis image; drawnow; %%get point title('select point'); hold on; [p1] = ginput; plot (p1(1),p1(2),'k*'); drawnow; % convert loose p1 crop image p2 = loose2crop(im1,im2,p1) % draw image 2 cropped subplot(2,1,2), imagesc(im2), axis image, hold on; plot (p2(1),p2(2),'r*'); drawnow; function p2 = loose2crop(im1, im2, p1) [h1,w1] = size(im1); [h2,w2] = size(im2); shift_h = (h1 - h2)/2 ; shift_w = (w1 - w2)/2 ; p2(1) = p1(1) - shift_h ; p2(2) = p1(2) - shift_w ;
Comments
Post a Comment