[vtkusers] DICOM image rendered incorrectly
Fahlgren, Eric
eric.fahlgren at smith-nephew.com
Thu Jan 9 18:29:55 EST 2014
O learned denizens of VTK land,
I have been presented with a wacky DICOM image, which fails to render properly in vtk (looks like banded noise instead of a shin bone). I have produced a gdcmdump of the file, which uncovers what appears to me to be a conflict in the pixel format. Here are what I believe to be the salient parts of the dump, note that in the main metadata the pixels are claimed to be 10-bit in 16-bit allocation, but in the image data metadata, it is shown to be 8-bit pixels in 8-bit boxes.
(0028,0100) US 16 # 2,1 Bits Allocated
(0028,0101) US 10 # 2,1 Bits Stored
(0028,0102) US 9 # 2,1 High Bit
...
(0089,1010) SQ (Sequence with undefined length) # u/l,1 Stamp Image Sequence
(fffe,e000) na (Item with undefined length)
...
(0028,0100) US 8 # 2,1 Bits Allocated
(0028,0101) US 8 # 2,1 Bits Stored
(0028,0102) US 7 # 2,1 High Bit
Now ImageMagick identify and convert appear to have no problems whatsoever with the file, in fact if I use convert to spit out a jpg/png/whatever, that renders properly. I've included a single image, which contains small snapshots of the DICOM on the left and the ImageMagick-extracted png on the right. (I have tried to use gdcmconv and raw to reformat the file, but have failed thus far to get any effect.)
[cid:image001.png at 01CF0D4C.E0BCD120]
Here's the code that produces the DICOM rendering.
#!/usr/bin/env python
import vtk
reader = vtk.vtkDICOMImageReader()
reader.SetFileName("IM3")
ia = vtk.vtkImageActor()
ia.GetMapper().SetInputConnection(reader.GetOutputPort())
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.Initialize()
ren.AddActor(ia)
ren.SetBackground(1.0, 1.0, 1.0)
renWin.SetSize(400, 800)
renWin.Render()
iren.Start()
What I suspect is happening, is that the VTK DICOM reader is using the numbers from the main metadata to interpret the pixel data, thus resulting in bit shifts that cause the banding in the image.
Has anyone seen this sort of problem before? Even better, if you have seen it, how did you cure it? (I've anonymized the x-ray headers, so if anyone would like a copy of the offending image file, it's ok to distribute.)
Thanks in advance,
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140109/db15b187/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 169536 bytes
Desc: image001.png
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140109/db15b187/attachment-0001.png>
More information about the vtkusers
mailing list