Filter löschen
Filter löschen

Change pixels to mm in axes in plot

3 Ansichten (letzte 30 Tage)
Eliska Paulikova
Eliska Paulikova am 3 Mär. 2023
Bearbeitet: Meet am 6 Mär. 2023
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.
  1 Kommentar
Eliska Paulikova
Eliska Paulikova am 3 Mär. 2023
I was using the plot, then the imshow.. Not working at all

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Meet
Meet am 6 Mär. 2023
Bearbeitet: Meet am 6 Mär. 2023
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])
Please refer the imref2d documentation for more details and examples.

Tags

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by