I just realized the problem wasn'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't look very well, maybe it's about the bytes I'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> <<a href="mailto:markww@gmail.com">markww@gmail.com</a>> 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't had problems with it and<br>vtkImageData. I've never tried with DicomImage. I thought DicomImage<br>does window level / rescale slope/intercept transformations<br>automatically which is why I don'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("C:\\test.dcm");<br>const unsigned short* p = NULL;<br>dcm.getDataset()->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'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 <<a href="mailto:jspinola@gmail.com">jspinola@gmail.com</a>> wrote:<br>> Hi vtkusers,<br>><br>> I want to read some DICOM files into one vtkImageData. To read the pixel
<br>> data from the DICOM files I want to use the DCMTK libraries. The<br>> vtkImageData object will contain several DICOM images so I want to load the<br>> pixel data into vtkImageData file by file.<br>><br>> First I allocate the vtkImageData and then I load the files in a bucle from
<br>> dcmtk (DicomImage class) to the vtkImageData object. The images are loaded<br>> correctly by dcmtk ( I dumped the images in a png file and they're ok ) but<br>> when I want to view the images with vtkImageViewer2 they are completely
<br>> dark, so it seems no data is loaded at all. Following there's the code<br>> snippet I use to do that. I also tried to read the pixel data with<br>> DcmDataset::findAndGetUint16Array(DCM_PixelData,..) instead
<br>> of DicomImage, but with no success.<br>><br>> Has anyone any suggestions of what I'm probably missing or doing wrong?<br>><br>> // first we allocate the data<br>> m_imageDataVTK = vtkImageData::New();
<br>> m_imageDataVTK->SetOrigin( origin );<br>> m_imageDataVTK->SetSpacing( spacing );<br>> m_imageDataVTK->SetDimensions( rows, columns, slices );<br>> m_imageDataVTK->SetScalarTypeToUnsignedShort(); // the data
<br>> will be 16 bit<br>> m_imageDataVTK->SetNumberOfScalarComponents(1);<br>> m_imageDataVTK->AllocateScalars();<br>><br>> // now we load all the images<br>> int zSlice = 0;<br>><br>> foreach( Image *image, m_imageSet )
<br>> {<br>> DicomImage *dicomImage = new DicomImage( qPrintable(<br>> image->getPath() ) ); // we load a new Image<br>> if( dicomImage != NULL )<br>> {<br>> if( dicomImage->getStatus() == EIS_Normal )
<br>> {<br>> dicomImage->setMinMaxWindow();<br>> if( dicomImage->getOutputData(16) != NULL )<br>> {<br>> // we copy the data in the dcmtk buffer to the
<br>> vtkImageData one<br>> memcpy((unsigned short<br>> *)m_imageDataVTK->GetScalarPointer(0,0,zSlice), (unsigned<br>> short *)dicomImage->getOutputData(16),<br>> dicomImage->getOutputDataSize() );
<br>> dicomImage->deleteOutputData();<br>> m_imageDataVTK->Modified();<br>> }<br>> }<br>> zSlice++;<br>> }<br>><br>> Thanks in advance!
<br>><br>> _______________________________________________<br>> This is the private VTK discussion list.<br>> Please keep messages on-topic. Check the FAQ at:<br>> <a href="http://www.vtk.org/Wiki/VTK_FAQ">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>> Follow this link to subscribe/unsubscribe:<br>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>><br>><br></blockquote>
</div><br>