Imref2d or 3d show wrong resolution
2 views (last 30 days)
Show older comments
Hello,
I am not sure what I am misunderstanding about the use of the Imref features. This came up when I was setting up some DICOM coordinates but can be shown with a simple example.
Let's say I know that the x and y direction coordinates for each voxel can be stated as
x_coord = 1:0.5:100;
and same for y. The first value is the first coordinate position, the middle is the pixel spacing, and last is the last coordinate given. This would give an image size of 199x199.
I then use imref2d:
R = imref2d([199 199], [1 100],[1 100])
which is giving the size, and the x/y world extents from min to maximum.
When this is inspected, it then says that the PixelExtentInWorldX is 0.4975 - obviously incorrect from what I stated above.
So my question is, are the world limits defined as inclusive for the minimum and exclusive for the maximum? To get the correct spacing I would have to specify:
R = imref2d([199 199], [1 100+0.5],[1 100+0.5])
i.e., add the pixel spacing to the end extent. This seems a bit messy when using imref3d, espcially when considering the use of it with imwarp.
Thanks, let me know if I should clarify anything
0 Comments
Accepted Answer
Julianna Mather
on 28 Sep 2020
Edited: Julianna Mather
on 28 Sep 2020
The "world limits" you provide in the 2nd and 3rd arguments to imref2d measure from the outside of the pixels, not the centers.
You stated that the pixels have a width of 0.5 units, so the image raster starts on the left edge at 0.75 = (1 - 0.5/2) and goes to 100.25 = (100 + 0.5/2) on the right.
So you would call imref2d this way: R = imref2d([199 199], [0.75 100.25], [0.75 100.25]);
More Answers (0)
See Also
Categories
Find more on 3-D Volumetric Image Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!