Change pixels to mm in axes in plot
7 次查看(过去 30 天)
显示 更早的评论
Hello, I have a table, I know that 1 pixel is 0.14mm. But if I plot some points from the table. The axes is in pixels. But I would like to have it in mm. How can I do it?
I was trying to use imred2D function, but as you can see I have a problem here.
Thank you so much for your answer.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1313330/image.png)
回答(1 个)
Meet
2023-3-6
编辑:Meet
2023-3-6
Hi,
Assuming that you are using the imshow method as shown in the code snippet, then that may not be the correct way of using it. You need to pass two arguments in the imshow function like imshow(A,RA) where A is the original image and RA is imref2d object.
Please refer the below example:
Create 2-D Spatial Referencing Object Knowing Image Size and Resolution
Read a 2-D grayscale image into the workspace.
m = dicominfo('knee1.dcm');
A = dicomread(m);
Create an imref2d object, specifying the size and the resolution of the pixels. The DICOM file contains a metadata field PixelSpacing that specifies the image resolution in each dimension in millimeters per pixel.
RA = imref2d(size(A),m.PixelSpacing(2),m.PixelSpacing(1))
RA =
imref2d with properties:
XWorldLimits: [0.1562 160.1562]
YWorldLimits: [0.1562 160.1562]
ImageSize: [512 512]
PixelExtentInWorldX: 0.3125
PixelExtentInWorldY: 0.3125
ImageExtentInWorldX: 160
ImageExtentInWorldY: 160
XIntrinsicLimits: [0.5000 512.5000]
YIntrinsicLimits: [0.5000 512.5000]
Display the image, specifying the spatial referencing object. The axes coordinates reflect the world coordinates.
figure
imshow(A,RA,'DisplayRange',[0 512])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1315470/image.png)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!