[vtkusers] vtkDistanceWidget and Dicom Images
Leonardo M. Ramé
l.rame at griensu.com
Tue Oct 19 14:40:38 EDT 2010
On 2010-10-19 14:27:19 -0400, John Drescher wrote:
> >
> > Wait a minute. I am doing that myself with this code. That works..
> >
> > if (fZAxisSpacing > 0.0) {
> > double spacing[3];
> > m_pImage->GetSpacing(spacing);
> > pChangeInfo->SetInput(m_pImage);
> > spacing[2] = fZAxisSpacing;
> > pChangeInfo->SetOutputSpacing(spacing);
> > pChangeInfo->Update();
> > m_pImage = pChangeInfo->GetOutput();
> > }
> >
> > This changes the z axes spacing because the vtkGDCMImageReader that I
> > use does not get the spacing correct in that direction for all image
> > types that I need to read.
> >
>
> pChangeInfo was defined before the conditional as:
>
> vtkSmartPointer<vtkImageChangeInformation> pChangeInfo =
> vtkSmartPointer<vtkImageChangeInformation>::New();
>
> John
Look, this is my code, setting the spacing with m_imageDataVTK does the
same as vtkImageChangeInformation::SetOutputSpacing, the spacing is
right, the measure is correct, but the image is small on screen. I think
what I need is some way to Zoom in the image.
This is the method I use to get the image from dcmtk and show in a
vtkImageViewer2.
mImage = m_qdicomImage->getDicomImage();
mImage->flipImage(0,-1);
m_imageDataVTK->SetOrigin( 0, 0, 0 );
m_imageDataVTK->SetDimensions( mImage->getWidth(), mImage->getHeight(), 1 );
m_imageDataVTK->SetScalarTypeToUnsignedShort(); // the data will be 16 bit
m_imageDataVTK->AllocateScalars();
double lPixelSpacing;
m_qdicomImage->getDataSet()->findAndGetFloat64(DCM_PixelSpacing, lPixelSpacing, 0, false);
//m_imageDataVTK->SetSpacing(lPixelSpacing, lPixelSpacing, lPixelSpacing);
// aplicamos Window Level
m_qdicomImage->getDicomImage()->setWindow(0);
mImage->getOutputData(
m_imageDataVTK->GetScalarPointer(0,0,0),
mImage->getOutputDataSize()
);
vtkImageChangeInformation * in = vtkImageChangeInformation::New();
in->SetInput(m_imageDataVTK);
in->SetOutputSpacing(lPixelSpacing, lPixelSpacing, lPixelSpacing);
in->Update();
m_ImageViewer->SetInput(in->GetOutput());
m_ImageViewer->SetRenderWindow(this->GetRenderWindow());
m_ImageViewer->SetupInteractor(this->GetInteractor());
vtkSmartPointer<DCMInteractorStyle> style = vtkSmartPointer<DCMInteractorStyle>::New();
this->GetInteractor()->SetInteractorStyle(style);
--
Leonardo M. Ramé
http://leonardorame.blogspot.com
More information about the vtkusers
mailing list