Closed gfotedar closed 5 years ago
Yes, the Grid
class has a grid
attribute that has the coordinates scaled between zero and one. You can multiply them by the size of the image using the scaled_to()
method to get the exact locations:
grid = gryds.Grid(image_shape)
transformed_grid = grid.transform(some_transform, ...)
resized_grid = transformed_grid.scaled_to(image_shape)
The locations in image coordinates are in resized_grid.grid
That is not actually what I am looking for. Like in your example on your home page, in this part of code:
# Define a random 3x3 B-spline grid for a 2D image:
random_grid = np.random.rand(2, 3, 3)
random_grid -= 0.5
random_grid /= 5
You define a random_grid of size 3x3. I am looking for locations of these 9 points in [row,column] format, before and after the deformation. I can find their locations after the deformation, using what you told me above, but I need to know the locations before deformation to do that.
If I understand you correctly you are looking for the coordinates of the B-spline transformation's control points before the transformation.
These are never explicitly computed in the code. Instead the grid (like the random_grid
in the code you reference) is resized to the size of the image you want to transform using B-spline interpolation.
Therefore, you can assume the B-spline control points are evenly distributed over the image's domain, i.e. in 2D
Is there a way to get the exact location of sampling grid points so I can display the grid before and after BSpline deformation superimposed on the image?