[vtkusers] Data Scaling

Doug Hoppes dhoppes at mbfbioscience.com
Thu Sep 2 11:04:04 EDT 2010


Hi all,

 

                I'm running into an issue with the data scaling.  I have
an image stack composed of 36 image planes and each image plane is 400 x
400 pixels wide.  I'm using the scaling of: x = 0.073567003
microns/pixel, y = 0.073965006 microns/pixel and z = 1 micron/pixel.

 

      In my code, I call the
SetDataSpacing(0.073567003,0.073965006,1.0000000), but the image is
always a fairly flat box, rather than a square.  Not sure what's going
on.

 

My code:

 

___________________

 

void ImageSliceItem::loadImageVolume()

{

      m_pReader = vtkSmartPointer<vtkTIFFReader>::New();

 

      // Get the input file prefix.

      int lastIndex = m_inputFile.lastIndexOf("_");

      QString m_inputFilePrefix = m_inputFile.left(lastIndex + 1);

 

      // Set up the rest of the reader configuration

      m_pReader->SetFilePrefix(m_inputFilePrefix.toStdString().c_str());

      m_pReader->SetFilePattern("%s%03d.tif");

      m_pReader->SetDataScalarTypeToUnsignedChar();

      m_pReader->SetNumberOfScalarComponents(3);

      m_pReader->SetDataOrigin(0,0,0);

      m_pReader->SetDataSpacing(0.073567003,0.073965006,1.0000000);

 

      // Get the size of the stack

      QString rightPart = m_inputFile.right(m_inputFile.length() -
lastIndex - 1);

      lastIndex = rightPart.lastIndexOf(".");

      QString m_stackIndex = rightPart.left(lastIndex);

      

      // Put the size of your image here (-1).  If your image is 1024 x
768,

      // then you have (0, 1025, 0, 767, 0, (last value computed))

      int test = m_stackIndex.toInt();

      m_pReader->SetDataExtent(0, 399, 0, 399, 0, m_stackIndex.toInt());

      m_pReader->UpdateWholeExtent();

 

      vtkSmartPointer<vtkImageLuminance> pLuminanceFilter =
vtkSmartPointer<vtkImageLuminance>::New();

      pLuminanceFilter->SetInput(m_pReader->GetOutput());

 

      vtkSmartPointer<vtkImageAppendComponents> pAppendComponent =
vtkSmartPointer<vtkImageAppendComponents>::New();

      pAppendComponent->SetInput(m_pReader->GetOutput());

      pAppendComponent->SetInput(1,pLuminanceFilter->GetOutput());

 

      vtkSmartPointer<vtkFixedPointVolumeRayCastMapper> pGPUMapper =
vtkSmartPointer<vtkFixedPointVolumeRayCastMapper>::New();

      pGPUMapper->SetBlendModeToMaximumIntensity();

      pGPUMapper->SetAutoAdjustSampleDistances(true);

      pGPUMapper->SetInput(pAppendComponent->GetOutput());

 

      vtkSmartPointer<vtkColorTransferFunction> pColorFunction =
vtkSmartPointer<vtkColorTransferFunction>::New();

      pColorFunction->AddRGBPoint(0.0, 0.0, 0.0, 0.0);

      pColorFunction->AddRGBPoint(255.0, 1.0, 1.0, 1.0);

 

      // create transfer mapping scalar value to opacity

      vtkSmartPointer<vtkPiecewiseFunction> pScalarToOpacityMapping =
vtkSmartPointer<vtkPiecewiseFunction>::New();

      pScalarToOpacityMapping->AddPoint(0, 0.0);

      pScalarToOpacityMapping->AddPoint(255, 2.0);

 

      vtkSmartPointer<vtkVolumeProperty> pVolumeProperty =
vtkSmartPointer<vtkVolumeProperty>::New();

      pVolumeProperty->SetColor(pColorFunction);

      pVolumeProperty->SetInterpolationTypeToLinear();

      pVolumeProperty->SetScalarOpacity(pScalarToOpacityMapping);

      pVolumeProperty->IndependentComponentsOff();

 

      vtkSmartPointer<vtkVolume> pVolumeActor =
vtkSmartPointer<vtkVolume>::New();

      pVolumeActor->SetMapper(pGPUMapper);

      pVolumeActor->SetProperty(pVolumeProperty);

 

      // Add Actor to renderer

      m_pRenderer->AddViewProp(pVolumeActor);

}

___________________

 

Any help is greatly appreciated!

 

Thanks.

 

Doug

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100902/57fb8a33/attachment.htm>


More information about the vtkusers mailing list