0

I have pictures in .dcm format. From Dicominfo I learned that the pixel spacing is [0.9,0.9] mm and the slice thickness is 1.98 mm.

My task: I should get the picture size in real (world) coordinates and then display the pictures in all three projections in matlab.

I had an idea that I would create a matrix in matlab, but it is difficult for me to create the pixel size spacing. I mean that the pixel in the matrix is like a square and is 0.9mm * 0.9mm. I don't know if my approach is correct and if there is an easy way to solve the problem. Thank you very much for every answer

Amit Joshi
  • 15,448
  • 21
  • 77
  • 141

1 Answers1

1

several plotting functions allow you to specify x/y/z positions of each pixel/voxel, including imagesc, pcolor, here is an example using imagesc.

% vol stores your dicom volume
vol=rand(40,50,30);
dx=[0.9,0.9,1.98];
imagesc((0:size(vol,1)-1)*dx(1), (0:size(vol,2)-1)*dx(2), vol(:,:,1))
FangQ
  • 1,444
  • 10
  • 18
  • Thank you for your answer Could it be with imshow the picture displayed without imagesc? – Natali Graß Apr 03 '21 at 20:06
  • `imshow` does not directly accept x/y positions, but you can set the `xdata` and `ydata` properties of the plotted object, like this: `ss=imshow(vol(:,:,1));; set(ss,'xdata',(0:size(vol,1)-1)*dx(1), 'ydata',(0:size(vol,2)-1)*dx(2));` – FangQ Apr 03 '21 at 20:09
  • I generally avoid using imshow because it requires the image processing toolbox; in comparison, `imagesc` is supported in matlab core, so everyone has matlab has it. – FangQ Apr 03 '21 at 20:11
  • Yes, it worked with imshow, but I also used zdata with imshow, but it didn't work. Isn't zdata defended at imshow? – Natali Graß Apr 03 '21 at 20:50