question about maketform() & tformarray()
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
SHERRY
am 1 Aug. 2015
Kommentiert: SHERRY
am 2 Aug. 2015
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');
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!