I just realized the problem wasn&#39;t in copying the data, I missed some parameters for the vtkImageViewer camera in my test program :/ <br>Now I can load the images, but they don&#39;t look very well, maybe it&#39;s about the bytes I&#39;m allocating for the image and the buffers, or something related with the window level functions.
<br><br>Thanks for your reply<br><br><div><span class="gmail_quote">On 8/16/07, <b class="gmail_sendername">Mark Wyszomierski</b> &lt;<a href="mailto:markww@gmail.com">markww@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Jesus, I always use DcmFileFormat and haven&#39;t had problems with it and<br>vtkImageData. I&#39;ve never tried with DicomImage. I thought DicomImage<br>does window level / rescale slope/intercept transformations<br>automatically which is why I don&#39;t use it.
<br><br>Anyway I think the DICOM object will give you the image data top to<br>bottom, but VTK works in cartesian coordinates, bottom to top. So you<br>probably have to setup a pixel loop to do the work of reading the<br>
DICOM image backwards. I usually do something like:<br><br>DcmFileFormat dcm;<br>dcm.loadFile(&quot;C:\\test.dcm&quot;);<br>const unsigned short* p = NULL;<br>dcm.getDataset()-&gt;findAndGetUint16Array(DCM_PixelData, p);<br>
<br>// Then copy over each pixel value from p in a pixel loop but bottom<br>to top into your vtkImageData object.<br><br>Like I said I&#39;ve been doing that for awhile without any problems, hope<br>that helps somewhat,<br>
<br>Mark<br><br><br><br><br><br>On 8/16/07, Jesús Spí­nola &lt;<a href="mailto:jspinola@gmail.com">jspinola@gmail.com</a>&gt; wrote:<br>&gt; Hi vtkusers,<br>&gt;<br>&gt; I want to read some DICOM files into one vtkImageData. To read the pixel
<br>&gt; data from the DICOM files I want to use the DCMTK libraries. The<br>&gt; vtkImageData object will contain several DICOM images so I want to load the<br>&gt; pixel data into vtkImageData file by file.<br>&gt;<br>&gt; First I allocate the vtkImageData and then I load the files in a bucle from
<br>&gt; dcmtk (DicomImage class) to the vtkImageData object. The images are loaded<br>&gt; correctly by dcmtk ( I dumped the images in a png file and they&#39;re ok ) but<br>&gt; when I want to view the images with vtkImageViewer2 they are completely
<br>&gt; dark, so it seems no data is loaded at all. Following there&#39;s the code<br>&gt; snippet I use to do that. I also tried to read the pixel data with<br>&gt; DcmDataset::findAndGetUint16Array(DCM_PixelData,..) instead
<br>&gt; of DicomImage, but with no success.<br>&gt;<br>&gt; Has anyone any suggestions of what I&#39;m probably missing or doing wrong?<br>&gt;<br>&gt; // first we allocate the data<br>&gt; m_imageDataVTK = vtkImageData::New();
<br>&gt; m_imageDataVTK-&gt;SetOrigin( origin );<br>&gt; m_imageDataVTK-&gt;SetSpacing( spacing );<br>&gt; m_imageDataVTK-&gt;SetDimensions( rows, columns, slices );<br>&gt; m_imageDataVTK-&gt;SetScalarTypeToUnsignedShort(); // the data
<br>&gt; will be 16 bit<br>&gt; m_imageDataVTK-&gt;SetNumberOfScalarComponents(1);<br>&gt; m_imageDataVTK-&gt;AllocateScalars();<br>&gt;<br>&gt; // now we load all the images<br>&gt; int zSlice = 0;<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; foreach( Image *image, m_imageSet )
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DicomImage *dicomImage = new DicomImage( qPrintable(<br>&gt; image-&gt;getPath() ) ); // we load a new Image<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( dicomImage != NULL )<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( dicomImage-&gt;getStatus() == EIS_Normal )
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dicomImage-&gt;setMinMaxWindow();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( dicomImage-&gt;getOutputData(16) != NULL )<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&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
<br>&gt; vtkImageData one<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memcpy((unsigned short<br>&gt; *)m_imageDataVTK-&gt;GetScalarPointer(0,0,zSlice), (unsigned<br>&gt; short *)dicomImage-&gt;getOutputData(16),<br>&gt; dicomImage-&gt;getOutputDataSize() );
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dicomImage-&gt;deleteOutputData();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_imageDataVTK-&gt;Modified();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zSlice++;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt; Thanks in advance!
<br>&gt;<br>&gt; _______________________________________________<br>&gt; This is the private VTK discussion list.<br>&gt; Please keep messages on-topic. Check the FAQ at:<br>&gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt;<br>&gt;<br></blockquote>
</div><br>