question about maketform() & tformarray()

4 views (last 30 days)
hi all,
i met a problem understanding this 3D to 2D transformation by using tformarray() function. My question is why the translation is 68.5 to keep the array coordinates positive(shown in bold)? Is here any equation to get this critical value?
Many thanks!
Sherri
---------------------------------------------------------------------------------------------------
Here are some relevant codes, and you can also get the full info by clicking this:
---------------------------------------------------------------------------------------------------
Step 3: Extract Sagittal Slice from the Horizontal Slices Using TFORMARRAY
tformarray() applies 3-D to 2-D transformations.
And we want to create an image with:
Dimension 1: Superior to inferior (original dimension 4, reversed)
Dimension 2: Caudal to rostral (original dimension 1)
and extract just a single sagittal plane via the original dimension 2, we specify tdims_a = [4 1 2]. We create a tform via composition starting with a 2-D affine transformation T1 that scales the (new) dimension 1 by a factor of -2.5 and adds a shift of 68.5 to keep the array coordinates positive . The second part of the composite is a custom transformation T2 that extracts the 64th sagittal plane using a very simple INVERSE_FCN.
T1 = maketform('affine',[-2.5 0; 0 1; *68.5* 0]);
inverseFcn = @(X,t) [X repmat(t.tdata,[size(X,1) 1])];
T2 = maketform('custom',3,2,[],inverseFcn,64);
Tc = maketform('composite',T1,T2);
R3 = makeresampler({'cubic','nearest','nearest'},'fill');
tformarray transforms the three spatial dimensions of D to a 2-D output in a single step. Our output image is 66-by-128, with the original 27 planes expanding to 66 in the vertical (inferior-superior) direction.
M4 = tformarray(D,Tc,R3,[4 1 2],[1 2],[66 128],[],0);
The result is identical to the previous output of imtransform.
figure, imshow(M4,map);
title('Sagittal - TFORMARRAY');

Accepted Answer

Walter Roberson
Walter Roberson on 1 Aug 2015
As the dimension is scaled by -2.5, what was the "right" edge of the image will have a coordinate of -2.5 * the width of the image. But you need the final coordinate to be nonnegative so you need to more than (2.5 * width) to shift the result to the right so it is non-negative. I did not track through the sizes to figure out the exact final coordinate.
Adding a right shift was done in the case of multiplication by a negative factor.
  1 Comment
SHERRY
SHERRY on 2 Aug 2015
Thank u very much! maybe u r right cuz -2.5*27(frames)=-67.5, and we add a shift of 68.5 to make the final value 1(-67.5+68.5), which is positive.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!