Hi vtkusers,<br><br>I want to read some DICOM files into one vtkImageData. To read the pixel data from the DICOM files I want to use the DCMTK libraries. The vtkImageData object will contain several DICOM images so I want to load the pixel data into vtkImageData file by file. 
<br><br>First I allocate the vtkImageData and then I load the files in a bucle from dcmtk (DicomImage class) to the vtkImageData object. The images are loaded correctly by dcmtk ( I dumped the images in a png file and they&#39;re ok ) but when I want to view the images with vtkImageViewer2 they are completely dark, so it seems no data is loaded at all. Following there&#39;s the code snippet I use to do that. I also tried to read the pixel data with DcmDataset::findAndGetUint16Array(DCM_PixelData,..) instead of DicomImage, but with no success.
<br><br>Has anyone any suggestions of what I&#39;m probably missing or doing wrong?<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">// first we allocate the data</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">m_imageDataVTK = vtkImageData::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
 m_imageDataVTK-&gt;SetOrigin( origin );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">m_imageDataVTK-&gt;SetSpacing( spacing );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">m_imageDataVTK-&gt;SetDimensions( rows, columns, slices );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">m_imageDataVTK-&gt;SetScalarTypeToUnsignedShort(); // the data will be 16 bit
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">m_imageDataVTK-&gt;SetNumberOfScalarComponents(1);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
m_imageDataVTK-&gt;AllocateScalars();</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">// now we load all the images</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">int zSlice = 0;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp; foreach( Image *image, m_imageSet )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DicomImage *dicomImage = new DicomImage( qPrintable( image-&gt;getPath() ) ); // we load a new Image</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( dicomImage != NULL )
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( dicomImage-&gt;getStatus() == EIS_Normal )
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dicomImage-&gt;setMinMaxWindow();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( dicomImage-&gt;getOutputData(16) != NULL )</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // we copy the data in the dcmtk buffer to the vtkImageData one
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memcpy((unsigned short *)m_imageDataVTK-&gt;GetScalarPointer(0,0,zSlice), (unsigned short *)dicomImage-&gt;getOutputData(16), dicomImage-&gt;getOutputDataSize() );
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dicomImage-&gt;deleteOutputData();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_imageDataVTK-&gt;Modified();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zSlice++;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; }</span><br style="font-family: courier new,monospace;"><br>Thanks in advance!<br style="font-family: courier new,monospace;">