[vtkusers] how to display a heart

Dženan Zukić dzenanz at gmail.com
Tue Nov 15 03:58:03 EST 2011


It is not possible to extract the heart perfectly using only intensity
values. If you want to show only heart, you would have to segment it first,
and then suppress the rest of the thorax (using heart's binary mask). But
segmenting the heart is a much larger beast than just displaying it using
VTK.

Regards

2011/11/15 FanShanShan <shanfshan at hotmail.com>

>  Hi,****
>
> I want to display a heat following the example(Medical1 or Medical2) which
> is described in VTK.  In the example of Medical2 ,I get that the contour
> value of skin is 500 and the contour value of bone is 1150, but I don't
> know the contour value of heart, so I tried some numbers, but I can't only
> extract the heart exactly, there is always some bones or  skin around it. I
> don't know whether the method which is used in head in Medical2 is not
> suitable for heart extracting, or I don't get a right contour value of
> heart, or the data I used is not good to me?  I get the 4D Cardiac CT data
> from http://pubimage.hcuge.ch:8080/  and I just process one folder .
> Please help me.****
>
> ** **
>
> here is my code :****
>
> #include "itkImage.h"****
>
> #include "itkImageSeriesReader.h"****
>
> #include "itkImageFileWriter.h"****
>
> #include "itkNumericSeriesFileNames.h"****
>
>  ****
>
> #include "itkImageToVTKImageFilter.h"****
>
>  ****
>
> #include <vtkRenderer.h>****
>
> #include <vtkRenderWindow.h>****
>
> #include <vtkRenderWindowInteractor.h>****
>
> #include <vtkPolyDataMapper.h>****
>
> #include <vtkActor.h>****
>
> #include <vtkOutlineFilter.h>****
>
> #include <vtkCamera.h>****
>
> #include <vtkProperty.h>****
>
> #include <vtkPolyDataNormals.h>****
>
> #include <vtkContourFilter.h>****
>
> #include <vtkSmartPointer.h>****
>
> #include <vtkStripper.h>****
>
>  ****
>
> int main( int argc, char * argv[] )****
>
> {****
>
>     typedef signed short    PixelType;****
>
>   const unsigned int Dimension = 3;****
>
>  ****
>
>   typedef itk::Image< PixelType, Dimension >  ImageType;****
>
>   typedef itk::ImageSeriesReader< ImageType > ReaderType;****
>
>  ****
>
>   ReaderType::Pointer reader = ReaderType::New();****
>
>  ****
>
>   const unsigned int first = atoi( argv[2] );****
>
>   const unsigned int last  = atoi( argv[3] );****
>
>  ****
>
>   typedef itk::NumericSeriesFileNames    NameGeneratorType;****
>
>  ****
>
>   NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();****
>
>  ****
>
>   nameGenerator->SetSeriesFormat( argv[1] );****
>
>  ****
>
>   nameGenerator->SetStartIndex( first );****
>
>   nameGenerator->SetEndIndex( last );****
>
>   nameGenerator->SetIncrementIndex( 1 );****
>
>   std::vector<std::string> names = nameGenerator->GetFileNames();****
>
> ** **
>
>   std::vector<std::string>::iterator nit;****
>
>   for (nit = names.begin();****
>
>        nit != names.end();****
>
>        nit++)****
>
>     {****
>
>     std::cout << "File: " << (*nit).c_str() << std::endl;****
>
>     }****
>
>  ****
>
>   reader->SetFileNames( names  );****
>
>  ****
>
>   ImageType::Pointer image = reader->GetOutput();****
>
>  ****
>
>   vtkSmartPointer<vtkRenderer> aRenderer =****
>
>     vtkSmartPointer<vtkRenderer>::New();****
>
>   vtkSmartPointer<vtkRenderWindow> renWin =****
>
>     vtkSmartPointer<vtkRenderWindow>::New();****
>
>   renWin->AddRenderer(aRenderer);****
>
>  ****
>
>   vtkSmartPointer<vtkRenderWindowInteractor> iren =****
>
>     vtkSmartPointer<vtkRenderWindowInteractor>::New();****
>
>   iren->SetRenderWindow(renWin);****
>
>  ****
>
>   typedef itk::ImageToVTKImageFilter<ImageType> itkVtkConverter;****
>
>     itkVtkConverter::Pointer conv=itkVtkConverter::New();****
>
>     conv->SetInput(image);****
>
>     conv->Update();****
>
>  ****
>
>     vtkSmartPointer<vtkContourFilter> heartExtractor =****
>
>     vtkSmartPointer<vtkContourFilter>::New();****
>
>     heartExtractor->SetInput(conv->GetOutput());****
>
>     heartExtractor->SetValue(0,60);****
>
>     heartExtractor->Update();****
>
>  ****
>
>   vtkSmartPointer<vtkPolyDataNormals> heartNormals =****
>
>     vtkSmartPointer<vtkPolyDataNormals>::New();****
>
>   heartNormals->SetInput(heartExtractor->GetOutput());****
>
>   heartNormals->SetFeatureAngle(60.0);****
>
>  ****
>
>   vtkSmartPointer<vtkStripper> heartStripper =****
>
>       vtkSmartPointer<vtkStripper>::New();****
>
>   heartStripper->SetInput(heartNormals->GetOutput());****
>
>  ****
>
>   vtkSmartPointer<vtkPolyDataMapper> heartMapper =****
>
>     vtkSmartPointer<vtkPolyDataMapper>::New();****
>
>   heartMapper->SetInput(heartStripper->GetOutput());****
>
>   heartMapper->ScalarVisibilityOff();****
>
>  ****
>
>   vtkSmartPointer<vtkActor> heart =****
>
>     vtkSmartPointer<vtkActor>::New();****
>
>   heart->SetMapper(skinMapper);****
>
>   heart->GetProperty()->SetDiffuseColor(1, .49, .25);****
>
>   heart->GetProperty()->SetSpecular(.3);****
>
>   heart->GetProperty()->SetSpecularPower(20);****
>
>   heart->GetProperty()->SetOpacity(1.0);****
>
>  ****
>
>   vtkSmartPointer<vtkContourFilter> boneExtractor =****
>
>     vtkSmartPointer<vtkContourFilter>::New();****
>
>   boneExtractor->SetInput(conv->GetOutput());****
>
>   boneExtractor->SetValue(0,300);****
>
>  ****
>
>   vtkSmartPointer<vtkPolyDataNormals> boneNormals =****
>
>     vtkSmartPointer<vtkPolyDataNormals>::New();****
>
>   boneNormals->SetInput(boneExtractor->GetOutput());****
>
>   boneNormals->SetFeatureAngle(60.0);****
>
>  ****
>
>   vtkSmartPointer<vtkStripper> boneStripper =****
>
>     vtkSmartPointer<vtkStripper>::New();****
>
>   boneStripper->SetInput(boneNormals->GetOutput());****
>
>  ****
>
>   vtkSmartPointer<vtkPolyDataMapper> boneMapper =****
>
>     vtkSmartPointer<vtkPolyDataMapper>::New();****
>
>   boneMapper->SetInput(boneStripper->GetOutput());****
>
>   boneMapper->ScalarVisibilityOff();****
>
>  ****
>
>   vtkSmartPointer<vtkActor> bone =****
>
>     vtkSmartPointer<vtkActor>::New();****
>
>   bone->SetMapper(boneMapper);****
>
>   bone->GetProperty()->SetDiffuseColor(1, 1, .9412);****
>
>   bone->GetProperty()->SetOpacity(0.0);****
>
>  ****
>
>   vtkSmartPointer<vtkOutlineFilter> outlineData =****
>
>     vtkSmartPointer<vtkOutlineFilter>::New();****
>
>   outlineData->SetInput(conv->GetOutput());****
>
>  ****
>
>   vtkSmartPointer<vtkPolyDataMapper> mapOutline =****
>
>     vtkSmartPointer<vtkPolyDataMapper>::New();****
>
>   mapOutline->SetInput(outlineData->GetOutput());****
>
>  ****
>
>   vtkSmartPointer<vtkActor> outline =****
>
>     vtkSmartPointer<vtkActor>::New();****
>
>   outline->SetMapper(mapOutline);****
>
>   outline->GetProperty()->SetColor(0,0,0);****
>
>  ****
>
>   vtkSmartPointer<vtkCamera> aCamera =****
>
>     vtkSmartPointer<vtkCamera>::New();****
>
>   aCamera->SetViewUp (0, 0, -1);****
>
>   aCamera->SetPosition (0, 1, 0);****
>
>   aCamera->SetFocalPoint (0, 0, 0);****
>
>   aCamera->ComputeViewPlaneNormal();****
>
>   aCamera->Azimuth(30.0);****
>
>   aCamera->Elevation(30.0);****
>
> ** **
>
>   aRenderer->AddActor(outline);****
>
>   aRenderer->AddActor(heart);****
>
>   aRenderer->AddActor(bone);****
>
>   aRenderer->SetActiveCamera(aCamera);****
>
>   aRenderer->ResetCamera ();****
>
>   aCamera->Dolly(1.5);****
>
>  ****
>
>   aRenderer->SetBackground(.2, .3, .4);****
>
>   renWin->SetSize(640, 480);****
>
>  ****
>
>   aRenderer->ResetCameraClippingRange ();****
>
>  ****
>
>   iren->Initialize();****
>
>   iren->Start();****
>
>   ****
>
>   return EXIT_SUCCESS;****
>  }
>
>
> Regards
>
> Sally
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111115/9138b363/attachment.htm>


More information about the vtkusers mailing list