[vtkusers] How to get vtkProbeFilter image output

Jingjing Deng jjdeng at gmail.com
Tue Apr 9 07:17:34 EDT 2013


Hi All,

I am implementing the curved MPR for dicom viewer following the example
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/CurvedReformation.
The code is attached.

Everything works fine. But the thing is I want to take actually cutting
image out rather than showing it as a actor. Would be great that anybody
could give me a hint on this.

// Compute the normal of the cutting surface
double p1[3] = {0.0};
        double p2[3] = {0.0};
        double p3[3] = {0.0};
        curvedPoints->GetPoint(0, p1);
        curvedPoints->GetPoint(1, p2);
        curvedPoints->GetPoint(2, p3);
        double v1[3] = {p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]};
        double v2[3] = {p3[0]-p1[0], p3[1]-p1[1], p3[2]-p1[2]};
        double v3[3] = {0.0};
        vtkMath::Cross(v1, v2, v3);
        vtkMath::Normalize(v3);
 
//construct the spline      
        vtkSmartPointer<vtkParametricSpline> spline =
vtkSmartPointer<vtkParametricSpline>::New();
        spline->SetPoints(curvedPoints);
        vtkSmartPointer<vtkParametricFunctionSource> functionSource =
vtkSmartPointer<vtkParametricFunctionSource>::New();
        functionSource->SetParametricFunction(spline);
        functionSource->Update();
   
//interpolate the spline     
        vtkSmartPointer<vtkSplineFilter> nspline =
vtkSmartPointer<vtkSplineFilter>::New();
        nspline->SetInputConnection(functionSource->GetOutputPort());
        nspline->SetSubdivideToSpecified();
        nspline->SetNumberOfSubdivisions(500);
        nspline->Update();
        
        vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
        mapper->SetInputConnection(nspline->GetOutputPort());
        vtkSmartPointer<vtkProperty> splineProp =
vtkSmartPointer<vtkProperty>::New();
        splineProp->SetColor(0, 1, 0);
        splineProp->SetLineWidth(5.0);
        curvedSplineActor = vtkSmartPointer<vtkActor>::New();
        curvedSplineActor->SetMapper(mapper);
        curvedSplineActor->SetProperty(splineProp);
        [viewVTK getRenderer]->AddActor(curvedSplineActor);

//mapping the 3D medical volume data to color image    
        vtkSmartPointer<vtkImageMapToColors> colorMap =
vtkSmartPointer<vtkImageMapToColors>::New();
        colorMap->SetInputConnection(source->GetOutputPort());
        colorMap->SetLookupTable(bwLut);
        colorMap->SetOutputFormatToRGBA();

//construct the cutting surface base on the spline, and probe it with volume
data
        vtkSmartPointer<vtkPolyData> surface =
SweepLine(nspline->GetOutput(), v3, 100, 500);
        vtkSmartPointer<vtkProbeFilter> sampleVolume =
vtkSmartPointer<vtkProbeFilter>::New();
        sampleVolume->SetSource(colorMap->GetOutput());
        sampleVolume->SetInputConnection(surface->GetProducerPort());
        sampleVolume->Update();

//construct the mapper and actor
vtkSmartPointer<vtkDataSetMapper> curvedMapper =
vtkSmartPointer<vtkDataSetMapper>::New();
        curvedMapper->SetInputConnection(sampleVolume->GetOutputPort());
        if(curvedPlaneActor != NULL)
            [viewVTK getRenderer]->RemoveActor(curvedPlaneActor);
        curvedPlaneActor = vtkSmartPointer<vtkActor>::New();
        curvedPlaneActor->SetMapper(curvedMapper);
        [viewVTK getRenderer]->AddActor(curvedPlaneActor);

// all above codes work fine. But I want to get the actually cutting image
data rather than the actor itself.

Many thanks.





--
View this message in context: http://vtk.1045678.n5.nabble.com/How-to-get-vtkProbeFilter-image-output-tp5719924.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list