dicom图像图不良的原因可能是什么 [英] What could be the reason for bad dicom image plot
问题描述
此常见X射线的dicom文件以混乱的方式绘制的原因可能是什么:
What could be the reason that the dicom file of this usual x-ray is getting plotted in a messed up manner:
使用的算法如下:
原始图像矩阵是3d:
int [1:2014, 1:2014, 1:3] 110 51 99 113 52 101 111 53 102 110 ...
此rgb已转换通过公式转换为灰度:
This rgb is converted to gray scale by formula:
gray = 0.3*mat[,,1] + 0.59*mat[,,2] + 0.11*mat[,,3] ;
然后将颜色指定为:
grey(0:64/64)
错误可能在哪里?
我在R中使用oro.dicom软件包,其功能为:
I am using oro.dicom package in R with function:
jj = readDICOMFile(fname, endian = "little", flipud = TRUE, DICM = TRUE, skipSequence = FALSE, pixelData = TRUE, warn = -1, debug = FALSE)
,它返回一个矩阵jj $ img,其结构为:
and it returns a the matrix jj$img whose structure is:
int [1:2014, 1:2014, 1:3] 110 51....
然后我将其转换为灰色并进行绘制。如果是rgba,矩阵将是2014 * 2014 * 4而不是* 3。 dicom图像的标题将 PhotometricInterpretation称为 RGB。标头还提到行和列分别为2014。可能与位问题有关:leadtools.com/sdk/medical/dicom-spec17.htm
I then convert it to gray and plot it. If it was rgba, the matrix would have been 2014*2014*4 rather than *3. The header of dicom image mentions "PhotometricInterpretation" as "RGB". The header also mentions rows and columns as 2014 each. Could it be related to bit problem: leadtools.com/sdk/medical/dicom-spec17.htm
编辑:分配的位为8,存储的位为8,highBit为7。
Bits allocated is 8, bits stored is 8 and highBit is 7.
以下是示例dicom图像的链接,该图像具有相似的图像矩阵并给出相似的错误: http://www.barre.nom.fr/medical/samples/files/US-RGB-8-esopecho .gz
Following is the link of sample dicom image which has similar image matrix and give similar error: http://www.barre.nom.fr/medical/samples/files/US-RGB-8-esopecho.gz
推荐答案
readDICOMFile
可能有错误。您可以通过重新排列图像数组来解决:
The readDICOMFile
might have a bug. You can fix by rearrange the image array:
jj = readDICOMFile(fname, flipud = FALSE, DICM = TRUE, skipSequence = FALSE, pixelData = TRUE, warn = -1, debug = FALSE)
img <- jj$img # extract image part
img <- aperm(array(c(aperm(img, c(2, 1, 3))), c(3, 256, 120)), c(3, 2, 1)) # rearrange dimension
img <- img[120:1,,] # flip ud
grid::grid.raster(scales::rescale(img))
更新
readDICOMFile
还有另一个错误。这就是你想要的。
您最好将其报告,但要报告给 oro.dicom
。
readDICOMFile
has another bug. This is what you want.
You may be better to report this but to the authors of oro.dicom
.
img <- jj$img # extract image part
img <- aperm(array(c(aperm(img, c(2, 1, 3))), c(3, 256, 120)), c(3, 2, 1)) # rearrange dimension
# conversion b/w unsigned and signed
img <- ifelse(img > 0, img, 256+img)
# window-ing
wc <- 127
ww <- 255
ymin <- 0
ymax <- 1
img2 <- ifelse(img <= wc - 0.5 - (ww-1)/2, ymin,
ifelse(img > wc - 0.5 + (ww-1)/2, ymax,
((img - (wc - 0.5)) / (ww - 1) + 0.5) * (ymax - ymin) + ymin
))
grid::grid.raster(img2)
这篇关于dicom图像图不良的原因可能是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!