VTK三维重建(1)-使用VTK读取DICOM,并动态输出

原文地址:http://blog.csdn.net/chinamming/article/details/16829351

[效果显示]

将脚部骨骼扫描的CT照片进行的连续读取, 运行结果存为了两个动态gif, 不知道能不能正常显示

VTK三维重建(1)-使用VTK读取DICOM,并动态输出_第1张图片

VTK三维重建(1)-使用VTK读取DICOM,并动态输出_第2张图片

[主程序实现]

int main(int argc, char* argv[])
{
   // Verify input arguments
   if ( argc != 2 )
   {
      std::cout << "Usage: " << argv[0]
      << " FolderName" << std::endl;
      return EXIT_FAILURE;
   }

   std::string folder = argv[1];

   // Read all the DICOM files in the specified directory.
   vtkSmartPointer reader =
      vtkSmartPointer::New();
   reader->SetDirectoryName(folder.c_str());
   reader->Update();

   // Visualize
   vtkSmartPointer imageViewer =
      vtkSmartPointer::New();
   imageViewer->SetInputConnection(reader->GetOutputPort());

   // slice status message
   vtkSmartPointer sliceTextProp = vtkSmartPointer::New();
   sliceTextProp->SetFontFamilyToCourier();
   sliceTextProp->SetFontSize(20);
   sliceTextProp->SetVerticalJustificationToBottom();
   sliceTextProp->SetJustificationToLeft();

   vtkSmartPointer sliceTextMapper = vtkSmartPointer::New();
   std::string msg = StatusMessage::Format(imageViewer->GetSliceMin(), imageViewer->GetSliceMax());
   sliceTextMapper->SetInput(msg.c_str());
   sliceTextMapper->SetTextProperty(sliceTextProp);

   vtkSmartPointer sliceTextActor = vtkSmartPointer::New();
   sliceTextActor->SetMapper(sliceTextMapper);
   sliceTextActor->SetPosition(15, 10);

   // usage hint message
   vtkSmartPointer usageTextProp = vtkSmartPointer::New();
   usageTextProp->SetFontFamilyToCourier();
   usageTextProp->SetFontSize(14);
   usageTextProp->SetVerticalJustificationToTop();
   usageTextProp->SetJustificationToLeft();

   vtkSmartPointer usageTextMapper = vtkSmartPointer::New();
   usageTextMapper->SetInput("- Slice with mouse wheel\n  or Up/Down-Key\n- Zoom with pressed right\n  mouse button while dragging");
   usageTextMapper->SetTextProperty(usageTextProp);

   vtkSmartPointer usageTextActor = vtkSmartPointer::New();
   usageTextActor->SetMapper(usageTextMapper);
   usageTextActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedDisplay();
   usageTextActor->GetPositionCoordinate()->SetValue( 0.05, 0.95);

   vtkSmartPointer renderWindowInteractor =
      vtkSmartPointer::New();

   vtkSmartPointer myInteractorStyle =
      vtkSmartPointer::New();

   myInteractorStyle->SetImageViewer(imageViewer);
   myInteractorStyle->SetStatusMapper(sliceTextMapper);

   imageViewer->SetupInteractor(renderWindowInteractor);
   renderWindowInteractor->SetInteractorStyle(myInteractorStyle);

   imageViewer->GetRenderer()->AddActor2D(sliceTextActor);
   imageViewer->GetRenderer()->AddActor2D(usageTextActor);

   imageViewer->Render();
   imageViewer->GetRenderer()->ResetCamera();
   imageViewer->Render();
   renderWindowInteractor->Start();
   return EXIT_SUCCESS;
}

 

原文地址:http://blog.csdn.net/chinamming/article/details/16829351

你可能感兴趣的:([+原创]VTK三维重建)