如何在dicom中绘制侦察/参考线 [英] How to draw scout/reference lines in dicom

查看:189
本文介绍了如何在dicom中绘制侦察/参考线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是dicom开发小组的初学者。我需要在dicom图像上创建一个定位器图像线。那么,有什么好主意吗?任何极客。

I am a beginner to dicom development group . I need to create a localizer image line on dicom image . So, is there any good ideas . Any Geeks .

推荐答案

David Brabant让你已经朝着正确的方向前进了(如果你想与DICOM合作,你一定要阅读和宝贝 dclunie的医学图片常见问题)。让我们看看我是否可以详细说明它并让你更容易实现。

David Brabant put you already in the right direction (if you want to work with DICOM you should definitely read and treasure dclunie's medical image FAQ). Let's see if I can elaborate on it and make it easier for you to implement.

我假设你有一个工具/库从DICOM文件中提取标签(Offis' DCMTK?)。为了举例说明,我将参考CT扫描(许多切片,即许多图像)和侦察图像,您要在其上显示定位器线。每个DICOM图像,包括您的CT切片和您的侦察,都包含有关它们在太空中的位置的完整信息,在这两个标记中:

I assume you have a tool/library to extract tags from a DICOM file (Offis' DCMTK?). For the sake of exemplification I'll refer to a CT scan (many slices, i.e. many images) and a scout image, onto which you want to display localizer lines. Each DICOM image, including your CT slices and your scout, contain full information about their location in space, in these two tags:


Group,Elem  VR Value                           Name of the tag   
---------------------------------------------------------------------
(0020,0032) DS [-249.51172\-417.51172\-821]  # ImagePositionPatient
                X0         Y0         Z0

(0020,0037) DS [1\0\0\0\1\0]                 # ImageOrientationPatient
                A B C D E F


ImagePositionPatient具有全球性发送的第一像素的毫米坐标(左上角像素,待清晰)表示为(x,y,z)。我把它们标记为X0,Y0,Z0。 ImageOrientationPatient包含两个向量,三个组件,指定第一行像素的方向余弦和图像的第一列像素。了解方向余弦不会造成伤害(参见例如 http://mathworld.wolfram.com/DirectionCosine.html),但dclunie建议的方法直接与它们一起工作,所以现在让我们说它们给你在图像平面的空间方向。我将它们标记为AF以使公式更容易。

ImagePositionPatient has the global coordinates in mm of the first pixel transmitted (the top left-hand corner pixel, to be clear) expressed as (x,y,z). I marked them X0, Y0, Z0. ImageOrientationPatient contains two vectors, both of three components, specifying the direction cosines of the first row of pixels and first column of pixels of the image. Understanding direction cosines doesn't hurt (see e.g. http://mathworld.wolfram.com/DirectionCosine.html), but the method suggested by dclunie works directly with them, so for now let's just say they give you the orientation in space of the image plane. I marked them A-F to make formulas easier.

现在,在dclunie给出的代码中(我相信它的目的是C,但它很简单它应该也可以使用如Java,C#,awk,Vala,Octave等)约定如下:

Now, in the code given by dclunie (I believe it's intended to be C, but it's so simple it should work as well as Java, C#, awk, Vala, Octave, etc.) the conventions are the following:


scr_ * =指的是图像,即CT切片

scr_* = refers to the soruce image, i.e. the CT slice

dst_ * =指目标图像,即侦察兵

dst_* = refers to the destination image, i.e. the scout

* _ pos_x, * _pos_y,* _pos_z =上面的X0,Y0,Z0

*_pos_x, *_pos_y, *_pos_z = the X0, Y0, Z0 above

* _ row_dircos_x,* _row_dircos_y,* _row_dircos_z =上面的A,B,C

*_row_dircos_x, *_row_dircos_y, *_row_dircos_z = the A, B, C above

* _ col_dircos_x,* _col_dircos_y,* _col_dircos_z =上面的D,E,F

*_col_dircos_x, *_col_dircos_y, *_col_dircos_z = the D, E, F above

设定后正确的值只适用于:

After setting the right values just apply these:

dst_nrm_dircos_x = dst_row_dircos_y * dst_col_dircos_z 
                   - dst_row_dircos_z * dst_col_dircos_y; 
dst_nrm_dircos_y = dst_row_dircos_z * dst_col_dircos_x 
                   - dst_row_dircos_x * dst_col_dircos_z; 
dst_nrm_dircos_z = dst_row_dircos_x * dst_col_dircos_y 
                   - dst_row_dircos_y * dst_col_dircos_x; 

src_pos_x -= dst_pos_x;
src_pos_y -= dst_pos_y;
src_pos_z -= dst_pos_z;

dst_pos_x = dst_row_dircos_x * src_pos_x
          + dst_row_dircos_y * src_pos_y
          + dst_row_dircos_z * src_pos_z;

dst_pos_y = dst_col_dircos_x * src_pos_x
          + dst_col_dircos_y * src_pos_y
          + dst_col_dircos_z * src_pos_z;

dst_pos_z = dst_nrm_dircos_x * src_pos_x
          + dst_nrm_dircos_y * src_pos_y
          + dst_nrm_dircos_z * src_pos_z;

或者,如果您有一些花哨的矩阵类,您可以构建此矩阵并将其与您的点相乘坐标。

Or, if you have some fancy matrix class, you can build this matrix and multiply it with your point coordinates.


    [ dst_row_dircos_x  dst_row_dircos_y  dst_row_dircos_z  -dst_pos_x ] 
M = [ dst_col_dircos_x  dst_col_dircos_y  dst_col_dircos_z  -dst_pos_y ]
    [ dst_nrm_dircos_x  dst_nrm_dircos_y  dst_nrm_dircos_z  -dst_pos_z ]
    [ 0                 0                 0                 1          ]


这将是这样的:


Scout_Point(x,y,z,1) = M * CT_Point(x,y,z,1)


说我们所有的,哪些点我们应该转换为在侦察线上创建一条线?同样对于这个dclunie已经建议了一个通用的解决方案:

Said all that, which points of the CT should we convert to create a line on the scout? Also for this dclunie already suggests a general solution:

我的方法是投影作为源图像的边界框的正方形(即连接的线条切片的TLHC,TRHC,BRHC和BLHC。

如果投影CT切片的四个角点,你将有一条线对于垂直于侦察的CT切片,以及在非垂直切片的情况下的梯形。现在,如果您的CT切片与坐标轴对齐(即ImageOrientationPatient = [1 \\\\\\\ 0]),则这四个点是微不足道的。您可以使用行/列数和沿x / y方向的像素距离计算图像的宽度/高度(以mm为单位),并相应地进行求和。如果你想实现通用案例,那么你需要一点三角函数......或者可能不需要。如果你还没有读到方向余弦的定义,也许是时候了。

If you project the four corner points of the CT slice, you'll have a line for CT slices perpendicular to the scout, and a trapezoid in case of non perpendicular slices. Now, if your CT slice is aligned with the coordinate axes (i.e. ImageOrientationPatient = [1\0\0\0\1\0]), the four points are trivial. You compute the width/height of the image in mm using the number of rows/columns and the pixel distance along x/y direction and sum things up appropriately. If you want to implement the generic case, then you need a little trigonometry... or maybe not. It's maybe time you read the definition of the direction cosines if you haven't yet.

我会试着让你走上正轨。例如。在TRHC上工作,您知道体素在图像平面中的位置:

I'll try to put you on track. E.g. working on the TRHC, you know where the voxel is in the image plane:


# Pixel location of the TRHC
x_pixel = number_of_columns-1 # Counting from 0
y_pixel = 0
z_pixel = 0 # We're on a plane!


DICOM中的像素距离值是指图像平面,因此,您可以简单地将x和y乘以这些值,使其位置以mm为单位,而z为0(像素和mm)。我在谈论这些价值观:

The pixel distance values in DICOM are referred to the image plane, so you can simply multiply x and y by those values to have their position in mm, while z is 0 (both pixels and mm). I am talking about these values:


(0028,0011) US 512                       #   2, 1 Columns
(0028,0010) US 512                       #   2, 1 Rows
(0028,0030) DS [0.9765625\0.9765625]     #  20, 2 PixelSpacing


上面的矩阵M是从全局到图像坐标的通用变换,具有可用的方向余弦。您现在需要的是执行逆作业(图像到全局)和源图像(CT切片)的操作。我会让你去深入挖掘几何书,但我觉得它应该是这样的(旋转部分是转置的​​,翻译没有符号变化,当然我们使用src_ *值):

The matrix M above, is a generic transformation from global to image coordinates, having the direction cosines available. What you need now is something that does the inverse job (image to global) and on the source images (the CT slices). I'll let you go and dig in the geometry books to be sure, but I think it should be something like this (the rotation part is transposed, translation has no sign change and of course we use the src_* values):


     [src_row_dircos_x  src_col_dircos_x  src_nrm_dircos_x  src_pos_x ]
M2 = [src_row_dircos_y  src_col_dircos_y  src_nrm_dircos_y  src_pos_y ]
     [src_row_dircos_z  src_col_dircos_z  src_nrm_dircos_z  src_pos_z ]
     [0                 0                 0                 1         ]


将CT切片中的点(例如四个角)转换为毫米,然后应用M2将它们置于全局坐标中。然后你可以将它们提供给dclunie报告的程序。在使用之前交叉检查我的数学,例如用于患者诊断! ;-)

Convert points in the CT slice (e.g. the four corners) to millimeters and then apply M2 to have them in global coordinates. Then you can feed them to the procedure reported by dclunie. Cross-check my maths before using it e.g. for patient diagnostics! ;-)

希望这有助于理解更好的dclunie方法。干杯

Hope this helps understanding better dclunie's method. Cheers

这篇关于如何在dicom中绘制侦察/参考线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆