Cropping an image in MATLAB !

1 view (last 30 days)
Amir
Amir on 26 Mar 2014
Edited: Image Analyst on 26 Mar 2014
Hello my dear friends,
I have a problem which might be solved by your help ;)
I have 2 images which are identical but there is some different between them such as the orientation of the images or scale of them. Through these codes %%
clear all
close all
clc
image1 = imread(image1);
image2 = imread(image2);
[input_points,base_points] = cpselect(image2,image1,'Wait',true);
TransForm = cp2tform(input_points,base_points,'similarity');
registered = imtransform(image2,TransForm,'XData',[1 size(image1,1)],'YData',[1 size(image1,2)]);
u = [0 1];
v = [0 0];
[x, y] = tformfwd(TransForm, u, v);
dx = x(2) - x(1);
dy = y(2) - y(1);
angle = (180/pi) * atan2(dy, dx)
scale = 1 / sqrt(dx^2 + dy^2)
subplot(2,2,1),imshow(image1)
title('Image 1')
subplot(2,2,2),imshow(image2)
title('Image 2')
subplot(2,2,3),imshow(registered)
title('Registered image')
figure
C = imfuse(image1,registered,'falsecolor','Scaling','joint','ColorChannels',[1 2 0]);
imshow(C)
As you have realised, I do some image registration. Now, I want to do some cropping in the 'registered' image and the exact related part in the image1 and image2 be cropped also. Do you have any idea about this issue ?
I appreciate your help in advance
Have a nice time

Answers (0)

Community Treasure Hunt

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

Start Hunting!