What could be the reason for bad dicom image plot

≡放荡痞女 提交于 2019-11-29 12:34:41

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))


UPDATE

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)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!