Change pixels to mm in axes in plot

조회 수: 2 (최근 30일)
Eliska Paulikova
Eliska Paulikova 2023년 3월 3일
편집: Meet 2023년 3월 6일
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
Eliska Paulikova
Eliska Paulikova 2023년 3월 3일
I was using the plot, then the imshow.. Not working at all

댓글을 달려면 로그인하십시오.

답변 (1개)

Meet
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])
Please refer the imref2d documentation for more details and examples.

카테고리

Help CenterFile Exchange에서 Build Interactive Tools에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by