[vtkusers] 3D modeling

Dean Inglis dean.inglis at camris.ca
Tue Sep 28 12:53:33 EDT 2004


Florent,

if your segmented bone is stored in an unsigned char image
volume as 255 and background (non-bone) is 0, you
could use vtkImageShiftScale to invert the results:

  vtkImageShiftScale* m_shift =  vtkImageShiftScale::New();
  m_shift->SetOutputScalarTypeToUnsignedChar();
  m_shift->ClampOverflowOn();
  m_shift->SetInput( a_segmented_bone_image );

  double* r = m_shift->GetInput()->GetScalarRange();
  double dmin = r[0];  // in your case would be 0
  double dmax = r[1];  // in your case would be 255
  double diff = dmax - dmin;
  double scale = -1.0;
  double intercept = dmin - scale*dmax;
  double shift = intercept / scale;

  m_shift->SetShift( shift );
  m_shift->SetScale( scale );

  m_shift->Update();

Dean  



 




More information about the vtkusers mailing list