[vtkusers] Thresholding a dicom image ?

Chasan KIOUTSOUKMOUSTAFA chasank at yahoo.com
Fri Sep 3 09:08:52 EDT 2010


I want to threshold a dicom image..and view the original image with thresholded image..However vtkImageThreshold currently does nothing. what must be the missing point? thanks

void ThreSholdDICOMImage(string DICOMFolder, double below, double above)
{
        iren->SetRenderWindow(renWin);
        reader->SetFileName(DICOMFolder.c_str());
        reader->Update();

        // original dicomImage actor
        vtkSmartPointer<vtkImageCast> originalCastFilter = vtkSmartPointer<vtkImageCast>::New();
        originalCastFilter->SetInputConnection(reader->GetOutputPort());
        originalCastFilter->SetOutputScalarTypeToUnsignedChar();
        originalCastFilter->Update();

        vtkSmartPointer<vtkImageActor> originalActor =  vtkSmartPointer<vtkImageActor>::New();
        originalActor->SetInput(originalCastFilter->GetOutput());        

        // Thresholded dicomImage actor
        vtkSmartPointer <vtkImageThreshold> threshold = vtkSmartPointer <vtkImageThreshold>::New();
        threshold->SetInputConnection(reader->GetOutputPort());
        threshold->ThresholdBetween(below, above);
        threshold->Update();

        vtkSmartPointer<vtkImageCast> thresholdCastFilter = vtkSmartPointer<vtkImageCast>::New();
        thresholdCastFilter->SetInputConnection(threshold->GetOutputPort());
        thresholdCastFilter->SetOutputScalarTypeToUnsignedChar();
        thresholdCastFilter->Update();

        vtkSmartPointer<vtkImageActor> thresholdedActor =  vtkSmartPointer<vtkImageActor>::New();
        thresholdedActor->SetInput(thresholdCastFilter->GetOutput());         

        double leftViewport[4] = {0.0, 0.0, 0.5, 1.0};
        double rightViewport[4] = {0.5, 0.0, 1.0, 1.0};

        renWin->AddRenderer(leftRenderer);
        renWin->AddRenderer(rightRenderer);
        leftRenderer->SetViewport(leftViewport);
        rightRenderer->SetViewport(rightViewport);

        leftRenderer->AddActor(originalActor);
        leftRenderer->ResetCamera();    
        rightRenderer->AddActor(thresholdedActor);
        rightRenderer->ResetCamera();
        renWin->Render();
        iren->Start();
}
        

Chasan KIOUTSOUKMOUSTAFA


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100903/b8a90c99/attachment.htm>


More information about the vtkusers mailing list