[Insight-users] the question about vtk

daliang_guo daliang_guo at 163.com
Thu May 10 01:03:10 EDT 2007


I'm a new VTKuser,when i wanted to display a Image of dicom,I got this message     ERROR: In \vtk-5.0.0\Rendering\vtkImageActor.cxx, line 182
vtkOpenGLImageActor (0273CF50): This filter requires unsigned char scalars as input I don't know why!I need some help. ////////////////void CvtkDLGDlg::OnBtnLoadFile()
{
  static char BASED_CODE szFilter[] = "VTK Files (*.dcm)|*.dcm|All Files (*.*)|*.*||";
  CFileDialog cFileDialog(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter);  if (cFileDialog.DoModal() == IDOK)
  {
    // remove old actors
   this->pvtkRenderer->RemoveActor(this->m_Actor);
    //this->pvtkRenderer->RemoveActor(this->pvtkActor2D);
 
    // read new data
   this->dcmReader=vtkDICOMImageReader::New();
   double origin[3] = {0, 0, 0};
  this->dcmReader->SetDataByteOrderToLittleEndian();
  this->dcmReader->SetDataScalarTypeToUnsignedChar();
  this->dcmReader->SetFileDimensionality(3);
  this->dcmReader->SetDataOrigin(origin);   this->dcmReader->SetFileName(cFileDialog.GetPathName());     this->dcmReader->SetNumberOfScalarComponents(1);
     this->dcmReader->SetHeaderSize(0);
     this->dcmReader->UpdateWholeExtent();
  this->dcmReader->SetDataScalarTypeToUnsignedChar();
  this->m_Actor->SetInput(this->dcmReader->GetOutput());  this->pvtkRenderer->SetBackground(0.0,0.0,0.4);
  this->pvtkRenderer->AddActor(this->m_Actor);
  this->pvtkMFCWindow->GetRenderWindow()->AddRenderer(this->pvtkRenderer); 
    // update window
    if (this->pvtkMFCWindow)
      this->pvtkMFCWindow->RedrawWindow();
  }
}  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070510/6dae5e04/attachment.html


More information about the Insight-users mailing list