[vtkusers] How to generate MIP (maximum intensity projection) image from a 3D image ?
zhq
15891495523 at 126.com
Mon Aug 17 08:05:02 EDT 2015
Dear David
Thank you for your reply. And I have finish the function using
vtkImageResliceMapper.
The code is :
#include <vtkVersion.h>
#include <vtkImageData.h>
#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleImage.h>
#include <vtkRenderer.h>
#include <vtkImageMapper.h>
#include <vtkImageResliceMapper.h>
#include <vtkImageSlice.h>
#include <vtkImageProperty.h>
#include <vtkPlane.h>
#include <vtkDICOMImageReader.h>
static void CreateColorImage(vtkImageData*);
int main(int, char *[])
{
vtkSmartPointer<vtkDICOMImageReader> reader =
vtkSmartPointer<vtkDICOMImageReader>::New();
reader->SetDirectoryName("G:\\Perfusion
Project\\Perfusion_MIP\\MIP\\TimePhase\\Time2");
reader->SetDataByteOrderToBigEndian();
reader->Update();
/*vtkSmartPointer<vtkImageData> colorImage =
vtkSmartPointer<vtkImageData>::New();
CreateColorImage(colorImage);*/
double center[3];
reader->GetOutput()->GetCenter(center);
double spacing[3];
reader->GetOutput()->GetSpacing(spacing);
vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New();
plane->SetOrigin(center);
vtkSmartPointer<vtkImageResliceMapper> imageResliceMapper =
vtkSmartPointer<vtkImageResliceMapper>::New();
imageResliceMapper->SetInputConnection(reader->GetOutputPort());
imageResliceMapper->SetSlicePlane(plane);
imageResliceMapper->SetSlabThickness(20);
imageResliceMapper->SetSlabTypeToMax();
double thickness = imageResliceMapper->GetSlabThickness();
//imageResliceMapper->SetInputData(colorImage);
vtkSmartPointer<vtkImageSlice> imageSlice =
vtkSmartPointer<vtkImageSlice>::New();
imageSlice->SetMapper(imageResliceMapper);
imageSlice->GetProperty()->SetInterpolationTypeToNearest();
// Setup renderers
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->AddViewProp(imageSlice);
renderer->ResetCamera();
// Setup render window
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->SetSize(300, 300);
renderWindow->AddRenderer(renderer);
// Setup render window interactor
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
vtkSmartPointer<vtkInteractorStyleImage> style =
vtkSmartPointer<vtkInteractorStyleImage>::New();
renderWindowInteractor->SetInteractorStyle(style);
// Render and start interaction
renderWindowInteractor->SetRenderWindow(renderWindow);
renderWindowInteractor->Initialize();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
ZhangQiang
--
View this message in context: http://vtk.1045678.n5.nabble.com/How-to-generate-MIP-maximum-intensity-projection-image-from-a-3D-image-tp5733520p5733526.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list