Closed Borda closed 5 years ago
The points to be transformed should be with the same origin from the image. You could use the following format: "point 1 -40.940000 -47.022000 -1169.500000"
@YuchuanQiao sorry it does not answer my question... the format is clear, it is written in the manual.
<index, point>
<number of points>
point1 x point1 y [point1 z]
point2 x point2 y [point2 z]
. . .
But, where are the origin and orientation? see my sample image with landmarks and registration results - elastix-results.zip
@kaspermarstal it may be good to add such information also here - https://github.com/SuperElastix/SimpleElastix/pull/305
As I say "The points to be transformed should be with the same origin from the image." This information is in the output file "TransformParameters.0.txt" after you perform the image registration. "(Origin 0.0000000000 0.0000000000) (Direction 1.0000000000 0.0000000000 0.0000000000 1.0000000000)" Not explicitly shown in the point.txt. The landmarks in your csv file look like in image space, maybe you should convert them to physical space. All points here are in physical space.
@YuchuanQiao sorry, but still I don't know what is the coordinates points in image, for example, four image corners (top-left, top-right, bottom-right, bottom-left) for an image with height 600px and width 800px...
(Transform "AffineTransform")
(NumberOfParameters 6)
(TransformParameters 0.999892 0.000142 0.000006 0.999862 91.981900 19.050974)
(InitialTransformParametersFileName "NoInitialTransform")
(HowToCombineTransforms "Compose")
// Image specific
(FixedImageDimension 2)
(MovingImageDimension 2)
(FixedInternalImagePixelType "float")
(MovingInternalImagePixelType "float")
(Size 800 600)
(Index 0 0)
(Spacing 1.0000000000 1.0000000000)
(Origin 0.0000000000 0.0000000000)
(Direction 1.0000000000 0.0000000000 0.0000000000 1.0000000000)
(UseDirectionCosines "true")
// AdvancedAffineTransform specific
(CenterOfRotationPoint 399.5000000000 299.5000000000)
// ResampleInterpolator specific
...
// Resampler specific
...
Yes, there is a position of origin, but where is it in the image plane, where is the (0, 0) in centre, corner, which corner? and direction... is positive up, down is fist vertical o horizontal direction...?
In my case the pixel and physical space should be the same, using the same units since I am using PNG images and there is no other information about the conversion...
any idea? @stefanklein @N-Dekker @FBerendsen @kaspermarstal
We use the ITK coordinate system, so the origin is in the lower left. Please see the manual, where we copied some information from the ITK guide on this matter. Does this help?
@mstaring thank you, I think that I found it now and I will check it if it works for me... anyway, may I recommend to refer this figure also in manual, sec 4.2 as it is focusing on point warping...
@mstaring it is strange because implementing this change does not help... Then I use the very same coordinate system as I have from the beginning and it gives expected transformed location... any idea why? (I used [row, column] and origin in the top left corner)
Did you recreate the affine transformation model precisely the same? including center of rotation. The precise mechanism can be found in the source code
I used the generated transformation produced by the elastix
image registration. See e.g.
TransformParameters.0.txt
Yes but if you do not use transformix for creating and executing the affine transformation, you have to be sure you are doing the exact same thing. (just looking for potential sources of bugs)
I was running following two commands, for registration
/home/jb/Applications/elastix/bin/elastix \
-f /home/jb/Dropbox/Workspace/BIRL/data_images/images/artificial_reference.jpg \
-m /home/jb/Dropbox/Workspace/BIRL/data_images/images/artificial_moving-affine.jpg \
-out /home/jb/Desktop/BmElastix_20190717-135929/1 \
-p /home/jb/Desktop/BmElastix_20190717-135929/elastix_affine.txt
and transformation
/home/jb/Applications/elastix/bin/transformix \
-tp /home/jb/Desktop/BmElastix_20190717-135929/1/TransformParameters.0.txt \
-out /home/jb/Desktop/BmElastix_20190717-135929/1 \
-in /home/jb/Dropbox/Workspace/BIRL/data_images/images/artificial_moving-affine.jpg \
-def /home/jb/Desktop/BmElastix_20190717-135929/1/artificial_reference.pts
ok so you do use transformix, but the problem is how to define the pts file?
reading above, you seem to know how to define the pts. Then I assume the problem is how to view the result. can you confirm?
the origin etc are the same as that of the fixed image
yes, my main concern was about used a coordinate system which was referred to VTK but until you pointed the figure in manual it was hard to find it anywhere else... What puzzles me no that when use the coordinate system defined in Fig.2.3 I got following transformation
and with the one I use elsewhere (numpy
indexing) I got what I expected
The expected transformation was just translation in both axes. and you can see that image registration would be almost perfect but the points did not match...
Ok, this is hard for me to debug from here. You are sure the registration went well?
yes, here is overlap between reference and warped moving image...
@mstaring you may run this script with default parameters to get the images/results I am showing here https://github.com/Borda/BIRL/blob/master/bm_experiments/bm_elastix.py
Hello, I am experimenting with image registration and later on transforming/warping some points (see manual, sec 4.2). It says that the points are from VTK, but so far I was not able to warp my points properly probably due to a different coordinate system. Mine has origin [0, 0] in the top left corner of the image and increasing in direction to the bottom right corner... What is the VTK coordinate frame? Thx @stefanklein @N-Dekker @FBerendsen @kaspermarstal ^^