fitgeotrans does not align my image

1 view (last 30 days)
Context: I am trying to use the Image Processing toolbox to find damage in materials. I first take a picture of my material before damaging it. I draw some markers on the material for alignment in MATLAB. Then I damage the material and I take a picture again.
Problem: I align two images of the same material by markers (see attachment). I first align them and then I want to see the difference (=damage) between the images. Unfortunately, the images do not align after fitgeotrans, as evident by the overlay image in imshowpair (in attachment). My second problem has to do with imabsdiff. After transformation, my images obviously have a slightly different size (due to the rotation). This impedes imabsdiff from working. Is there an easy solution to disregard the section where my fixed image is smaller than the warped one?
Do I make some basic error or is something else going on?
pre = imread('predamage');
post = imread('postdamage');
imwrite(pre, 'pret.tiff');
imwrite(post, 'postt.tiff');
moving = imread('postt.tiff');
fixed = imread('pret.tiff');
[moving_out,fixed_out] = cpselect(moving,fixed,'Wait', true);
match = fitgeotrans(moving_out,fixed_out, 'Similarity');
warped = imwarp(moving,match);
imshowpair(fixed,warped)
diff = imabsdiff(fixed,warped).*32; %Amplify the differences
imshow(diff)
Thanks in advance!
PS: I first convert from .JPG to .TIFF because I will possibly use a raw image format in the future.

Accepted Answer

Alex Taylor
Alex Taylor on 2 Jun 2014
Use the 'outputView' name/value option when calling imwarp, as is shown in the examples for fitgeotrans. This will fix the issue.

More Answers (1)

Yannick
Yannick on 3 Jun 2014
Problem solved, thanks!

Community Treasure Hunt

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

Start Hunting!