how can I Rotate the image around the center using transformPointsForward and Getting the coordinates of the four corners of the changed image؟

1 view (last 30 days)
I want to rotate the image arround the center.I usesd transformPointForward function for do this.I want to getting the coordinate of the four corners of the changed image.in below you can see my code.thanks for your help.
theta=+50;
tform = affine2d([cosd(theta) -sind(theta) 0;sind(theta) cosd(theta) 0; 0 0 1]);
A = imread('pout.tif');
corners = [1,1;1,size(A,2);size(A,1),1;size(A,1),size(A,2)];
X = transformPointsForward(tform,corners);
Rin = imref2d(size(A))
Rin.XWorldLimits = Rin.XWorldLimits-mean(Rin.XWorldLimits);
Rin.YWorldLimits = Rin.YWorldLimits-mean(Rin.YWorldLimits);
[out,ref] = imwarp(A,Rin,tform);
figure,
subplot(1,2,1),imshow(A,[])
subplot(1,2,2),imshow(out,[])
X(:,1) = X(:,1) - ref.XWorldLimits(1);
X(:,2) = X(:,2) - ref.YWorldLimits(1);

Answers (0)

Community Treasure Hunt

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

Start Hunting!