医站点医维基

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 361|回复: 0

[VTK] vtk-dicom-Image Orientation

[复制链接]

336

主题

411

回帖

2808

积分

管理员

积分
2808

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2024-2-29 14:21:59 | 显示全部楼层 |阅读模式

Medical image orientation in VTK.


Overview

When people use the term "image orientation" with respect to medical images, they usually mean one or more of the items listed below:

  • The order in which the pixels, rows, and slices are stored in the computer's memory.
  • The orientation of the image slices in a real-world coordinate system, for example the patient coordinate system as defined by the medical imaging equipment that generated the images.
  • The orientation of the subject (patient) with respect to the viewer when the images are viewed on a workstation.

The first of these, the way the data is stored in memory, should merely be an implementation detail, but unfortunately the vtkImageViewer class insists that the pixels must be arranged in memory such that the pixel at the bottom-left corner of the image is the pixel at the lowest address in memory. This is in conflict with DICOM, which stores the top-left pixel as the first pixel in the file. To provide compatibility with the vtkImageViewer, the default behavior of the vtkDICOMReader is to flip the image in memory while it is loading it from the file. This behavior can be turned off by calling reader->SetMemoryRowOrderToFileNative().

The second and third items in the list can be referred to as the real-world orientation, and the display orientation, respectively. Neither of these can be considered an implementation detail, as both of them are crucial to the user experience. Also, it is important not to confuse one with the other. An application that incorrectly manages the real-world orientation is seriously flawed, even if it manages to display the images to the user in the correct orientation.

The real-world orientation is provided by the GetPatientMatrix() method of the vtkDICOMReader. This method returns a vtkMatrix4x4 object that describes the coordinate transformation from the data coordinates of the vtkImageData that stores the image, to the real-world Patient Coordinate System defined in the DICOM standard. The matrix is used to correctly place the image in the VTK world coordinate system.

The PatientMatrix is constructed from the ImagePositionPatient and ImageOrientationPatient attributes in the series of DICOM files that are provided to the reader. Note that unless SetMemoryRowOrderToFileNative() has been called on the reader, the orientation of the matrix will be flipped with respect to ImageOrientationPatient in order to account for the fact that the image rows were flipped in memory.

  1. reader->SetMemoryRowOrderToFileNative(); // keep native row order
  2. reader->Update(); // update the reader
  3. vtkMatrix4x4 *matrix = reader->GetPatientMatrix();

  4. // create an image actor and specify the orientation.
  5. vtkNew<vtkImageActor> actor;
  6. actor->GetMapper()->SetInputConnection(reader->GetOutputPort());
  7. actor->SetUserMatrix(matrix);
复制代码

Setting the actor's UserMatrix will ensure that the real-world orientation of the image is correctly handled, as far as the VTK display pipeline is concerned. It does not, however, set the display orientation, which is the responsibility of the application. The display orientation can be set via manipulation of the VTK camera.

vtk-dicom: Image Orientation (dgobbi.github.io)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|关于我们|医维基|网站地图|Archiver|手机版|医疗之家 ( 沪ICP备2023001278号-1 )  

GMT+8, 2024-5-8 17:12 , Processed in 0.127565 second(s), 24 queries .

Designed by Medical BBS

快速回复 返回顶部 返回列表