Note that there are some explanatory texts on larger screens.

plurals
  1. POImage translation in MATLAB
    text
    copied!<p>After registering two images in <a href="http://en.wikipedia.org/wiki/MATLAB" rel="nofollow noreferrer">MATLAB</a> (R2010a) (Image1, and Image2), I cannot seem to figure out how to get the translation correct. The algorithm has been tested and works with other programs. Here are some relevant snippets.</p> <pre><code>TForm = maketform('affine', Transform); info = imfinfo('Image1.bmp'); Reg = imtransform(Image1, TForm,... 'XData', [1 (size(Image1,2)+Transform(3,1))],... 'YData', [1 (size(Image1,1)+Transform(3,2))],... 'FillValues', 255); figure('Name', 'Reg'),... imshow(Reg, 'InitialMagnification', 250); imwrite(Reg, 'Reg.bmp', 'bmp'); hold on H = imshow(Image2, gray(256)); set(H, 'AlphaData', 0.6) </code></pre> <p>This does not happen when I register Image1 to Image1, only when I try registering Image1 to Image2 (or the other way around). I have the same code made in C which seems to work fine. I believe it has something to do with my <code>imtransform</code> function.</p> <p>Well, I believe it has to do something with the way the transformation is being applied. I did a direct registration with Image1 to Image1 (rotated 15 degrees about the <a href="http://en.wikipedia.org/wiki/Center_of_mass" rel="nofollow noreferrer">center of mass</a>), and it does not do the correct transformation. The transformation output is:</p> <pre><code>Transform = 0.9676 -0.2557 0 0.2596 0.9694 0 32.7217 -25.5110 1.0000 </code></pre> <p>Which if I input this into an image registration program, it works just fine. Here is an example image I did just now,</p> <p><img src="https://i.stack.imgur.com/MS7dr.jpg" alt="Example of strange MATLAB registration"></p> <p>A = Original Image, B = Rotated Original Image, C = Original Image Transformed.</p> <p>Again the transformation is correct (tested using FMRIB's-FLIRT registration software). MATLAB must be doing something different when applying it to the image.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload