Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

point format in VTK coordinate system #156

Closed
Borda opened this issue Jun 20, 2019 · 20 comments
Closed

point format in VTK coordinate system #156

Borda opened this issue Jun 20, 2019 · 20 comments

Comments

@Borda
Copy link

Borda commented Jun 20, 2019

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 ^^

@YuchuanQiao
Copy link

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"

@Borda
Copy link
Author

Borda commented Jun 20, 2019

@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

@Borda
Copy link
Author

Borda commented Jun 21, 2019

@kaspermarstal it may be good to add such information also here - SuperElastix/SimpleElastix#305

@YuchuanQiao
Copy link

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.

@Borda
Copy link
Author

Borda commented Jun 24, 2019

@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...

@Borda
Copy link
Author

Borda commented Jul 4, 2019

@mstaring
Copy link
Member

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?

@Borda
Copy link
Author

Borda commented Jul 16, 2019

@mstaring thank you, I think that I found it now and I will check it if it works for me...
image
anyway, may I recommend to refer this figure also in manual, sec 4.2 as it is focusing on point warping...

@Borda
Copy link
Author

Borda commented Jul 17, 2019

@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)

@mstaring
Copy link
Member

Did you recreate the affine transformation model precisely the same? including center of rotation. The precise mechanism can be found in the source code

@Borda
Copy link
Author

Borda commented Jul 18, 2019

I used the generated transformation produced by the elastix image registration. See e.g.
TransformParameters.0.txt

@mstaring
Copy link
Member

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)

@Borda
Copy link
Author

Borda commented Jul 18, 2019

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

@mstaring
Copy link
Member

ok so you do use transformix, but the problem is how to define the pts file?

@mstaring
Copy link
Member

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?

@mstaring
Copy link
Member

the origin etc are the same as that of the fixed image

@Borda
Copy link
Author

Borda commented Jul 18, 2019

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
registration_visual_landmarks
and with the one I use elsewhere (numpy indexing) I got what I expected
registration_visual_landmarks
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...

@mstaring
Copy link
Member

Ok, this is hard for me to debug from here. You are sure the registration went well?

@Borda
Copy link
Author

Borda commented Jul 18, 2019

yes, here is overlap between reference and warped moving image...
image_refence-warped

@Borda
Copy link
Author

Borda commented Jul 20, 2019

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants