Dicom 窗口宽度和宽度水平公式不给出灰度值
我正在尝试在我的应用程序中实现 de Dicom 规范中的窗口宽度和级别公式。只是目前它没有返回任何灰度。 dicom 指定的公式如下:
根据以下伪代码应用这些属性,其中 x 是输入值,y 是输出值,范围从 ymin 到 ymax,c 是窗口中心 (0028,1050),w 是 窗口宽度 (0028,1051):
if (x <= c - 0.5 - (w-1)/2), then y = ymin
else if (x > c - 0.5 + (w-1)/2), then y = ymax,
else y = ((x - (c - 0.5)) / (w-1) + 0.5) * (ymax - ymin)+ ymin
所以我将其翻译成以下 c# 语法:
if (pixelData[i] <= wLevel - 0.5 - (wWidth - 1) / 2)
oColor = 0;
else if (pixelData[i] > wLevel - 0.5 + (wWidth - 1) / 2)
oColor = 255;
else
oColor = (int)((pixelData[i] - (wLevel - 0.5)) / (wWidth - 1) + 0.5) * (255 - 0) + 0;
但是,公式的最后一部分
oColor = (int)((pixelData[i] - (wLevel - 0.5)) / (wWidth - 1) + 0.5) * (255 - 0) + 0;
Only 似乎返回 0
有人知道这是怎么可能的吗?
I'm trying to implement the Window Width and level formula from de Dicom specification in my application. Only it's not returning any grayscales at the moment. The dicom specifies the formula as following:
These Attributes are applied according to the following pseudo-code, where x is the input value, y
is an output value with a range from ymin to ymax, c is Window Center (0028,1050) and w is
Window Width (0028,1051):
if (x <= c - 0.5 - (w-1)/2), then y = ymin
else if (x > c - 0.5 + (w-1)/2), then y = ymax,
else y = ((x - (c - 0.5)) / (w-1) + 0.5) * (ymax - ymin)+ ymin
So i've translated this into the following c# syntax:
if (pixelData[i] <= wLevel - 0.5 - (wWidth - 1) / 2)
oColor = 0;
else if (pixelData[i] > wLevel - 0.5 + (wWidth - 1) / 2)
oColor = 255;
else
oColor = (int)((pixelData[i] - (wLevel - 0.5)) / (wWidth - 1) + 0.5) * (255 - 0) + 0;
Howevery, the last part of the formula
oColor = (int)((pixelData[i] - (wLevel - 0.5)) / (wWidth - 1) + 0.5) * (255 - 0) + 0;
Only seems to return 0
Anyone sees how this is possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
VOI LUT 的含义是将给定的像素范围映射到可显示的值(通常为 0..0xFF),对超出范围的像素值使用钳位。
这意味着对于给定的窗口/级别,我们可以计算可显示范围:
level-window/2 , level + window/2 。
对于该范围内的像素值,使用线性变换:
((pixel - lower_window_limit) / window) * displayable_range
,其中
lower_window_limit
是level - window/2
您的公式中缺少此
-window/2
。The meaning of VOI LUT is to map a given pixel range to displayable values (usually 0..0xFF), using clamping for out of range pixel values.
This means that for a given window/level we can compute the displayable range:
level-window/2 , level + window/2
.For pixel values that are in that range, linear transformation is used:
((pixel - lower_window_limit) / window) * displayable_range
where
lower_window_limit
islevel - window/2
This
-window/2
is missing in your formula.