[vtkusers] Region Growing (Volume Rendering) Cropping Problem

Yusuf OEZBEK nasil122002 at yahoo.de
Mon Mar 29 06:10:13 EDT 2010


Hello All.
I have a problem with to cut (cropping) a 3D object, which I produced by the segmentation-method “region growing”. In the beginning I read the DICOM (. dcm) images with itkImageSeriesReader then I run region growing -algorithm, in order to connect itk with vtk and a 3D object produce, I use ImageToVTKImageFilter and volume rendering (ray casting). And after segmentation of cutting the images I give below vtkFixedPointVolumeRayCastMapper (SetCroppingRegionPlanes) the Xmin, Xmax, Ymin, Ymax, Zmin and Zmax coordinates, but the result is a black screen. But when I read the images with vtkDICOMImageReader and then segmented with volume rendering, then it works completely well. The problem arises only for region growing -algorithm. Where is my mistake in the code? What should I do?
Thank you.
 
 
 
My Code for Volume Rendering:
int levelForVolumeRendering = (int)this->sliderRangeMin->value()-(int)this->sliderRangeMax->value()/2;
int widhtForVolumeRendering = (int)this->sliderRangeMin->value()+(int)this->sliderRangeMax->value()/2;
 
      
mode3D = vtkInteractorStyleTrackballCamera::New();
 
renderer3D = vtkRenderer::New();
 
renderWindow3D = vtkRenderWindow::New();
renderWindow3D->AddRenderer(renderer3D);
 
displayImage3D->SetRenderWindow(renderWindow3D);
displayImage3D->SetInteractorStyle(mode3D);
displayImage3D->Initialize();
 
 
vtkPiecewiseFunction *oTFun = vtkPiecewiseFunction::New();
oTFun->AddPoint((double)levelForVolumeRendering, 0);
oTFun->AddPoint((double)widhtForVolumeRendering, 1.0);
 
 
vtkPiecewiseFunction* gradOpacity = vtkPiecewiseFunction::New();
gradOpacity->AddPoint(0, 0.0);
gradOpacity->AddPoint((int)this->changeLevelInput->value(), 1.0);
gradOpacity->AddPoint((int)this->changeWidthInput->value(), 1.0);
 
 
volumeColor = vtkColorTransferFunction::New();
volumeColor->AddRGBPoint((double)levelForVolumeRendering, .62, .36, .18 );
volumeColor->AddRGBPoint((double)widhtForVolumeRendering, .83, .66, 1);
 
      
volumeProperty = vtkVolumeProperty::New();
volumeProperty->SetShade(0);
volumeProperty->SetAmbient(0.3);
volumeProperty->SetDiffuse(1.0);
volumeProperty->SetSpecular(0.2);
volumeProperty->SetSpecularPower(50.0);
volumeProperty->SetColor(volumeColor);
volumeProperty->SetScalarOpacity(oTFun);
volumeProperty->ShadeOn();
volumeProperty->SetInterpolationTypeToLinear();
 
//read with vtkDICOMImageReader and give 6 coordinates for cropping
volumeRayCastMapper = vtkFixedPointVolumeRayCastMapper::New();
volumeRayCastMapper->SetInputConnection(reader2D->GetOutputPort()); 
volumeRayCastMapper->CroppingOn();
volumeRayCastMapper->SetCroppingRegionPlanes(minpoint4[0], maxpoint4[0], minpoint4[1], maxpoint4[1],minpoint4[2], maxpoint4[2]);
volumeRayCastMapper->SetCroppingRegionFlagsToSubVolume();
 
 
volume = vtkVolume::New();
volume->SetProperty(volumeProperty);
volume->SetMapper(volumeRayCastMapper);
 
camera3D = vtkCamera::New();
camera3D->SetViewUp(0, 0, -1);
camera3D->SetPosition(0, 1, 0);
camera3D->SetFocalPoint(0, 0, 0);
camera3D->ComputeViewPlaneNormal();
camera3D->Azimuth(20);
 
renderer3D->AddViewProp(volume);
renderer3D->SetActiveCamera(camera3D);
renderer3D->ResetCamera();
camera3D->Dolly(1.3);
renderer3D->ResetCameraClippingRange();
      
      


Region Growing Segmentation:

int levelForRegionGrowing = (int)this->sliderRangeMin->value();
int widhtForRegionGrowing = (int)this->sliderRangeMax->value();
 
double rangeBeginWatershed = ((levelForRegionGrowing-(-(int)this->sliderRangeMin->minimum()))/((int)this->sliderRangeMax->maximum()-(-(int)this->sliderRangeMin->minimum())));
double rangeEndWatershed =  ((widhtForRegionGrowing-(-(int)this->sliderRangeMin->minimum()))/((int)this->sliderRangeMax->maximum()-(-(int)this->sliderRangeMin->minimum())));
 
typedef float InputPixelType;
typedef float OutputPixelType;
const unsigned int Dimension = 3;
 
 
typedef itk::OrientedImage< InputPixelType, Dimension >    ImageType;
typedef itk::ImageSeriesReader< ImageType >   ReaderType;
ReaderType::Pointer reader = ReaderType::New();
 
typedef itk::GDCMImageIO     ImageIOType;
ImageIOType::Pointer dicomIO = ImageIOType::New();
      
reader->SetImageIO( dicomIO );
 
typedef itk::GDCMSeriesFileNames NamesGeneratorType;
NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
 
nameGenerator->SetUseSeriesDetails( true );
nameGenerator->AddSeriesRestriction("0008|0021" );
 
nameGenerator->SetDirectory( selectedDirectory);
 
typedef std::vector< std::string >    SeriesIdContainer;
        
const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
        
SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
 
while( seriesItr != seriesEnd )
         {
         seriesItr++;
         }
 
std::string seriesIdentifier;
 
seriesIdentifier = seriesUID.begin()->c_str();
 
typedef std::vector< std::string >   FileNamesContainer;
FileNamesContainer fileNames;
 
fileNames = nameGenerator->GetFileNames( seriesIdentifier );
 
reader->SetFileNames( fileNames );
reader->Update();
 
 
typedef itk::Image< InternalPixelType, Dimension >  InternalImageType;
typedef itk::Image<OutputPixelType, Dimension> OutputImageType;
typedef itk::CastImageFilter<InternalImageType, OutputImageType> CastingFilterType;
CastingFilterType::Pointer caster = CastingFilterType::New();
 
typedef itk::CurvatureFlowImageFilter<InternalImageType, InternalImageType> CurvatureFlowImageFilterType;
CurvatureFlowImageFilterType::Pointer smoothing = CurvatureFlowImageFilterType::New();
      
typedef itk::ConfidenceConnectedImageFilter<InternalImageType, InternalImageType> ConnectedFilterType;
ConnectedFilterType::Pointer confidenceConnected = ConnectedFilterType::New();
 
      
typedef itk::ImageToVTKImageFilter<InternalImageType> ConnectorType;
      
smoothing->SetInput( reader->GetOutput() );
confidenceConnected->SetInput(smoothing->GetOutput());
caster->SetInput( confidenceConnected->GetOutput() );
 
 
smoothing->SetNumberOfIterations(2);
smoothing->SetTimeStep(0.05);
 
 
confidenceConnected->SetMultiplier(2.5);
confidenceConnected->SetNumberOfIterations(2);
confidenceConnected->SetReplaceValue(255);
confidenceConnected->SetInitialNeighborhoodRadius(2);
      
InternalImageType::IndexType  index;
index[0] = (int)this->changeRegionGrowingInputX->value()-300/reader2D->GetHeight();
index[1] = (int)this->changeRegionGrowingInputY->value()-300/reader2D->GetHeight();
index[2] = (int)this->changeRegionGrowingInputZ->value()-300/reader2D->GetHeight();
confidenceConnected->AddSeed( index );
     
 
ConnectorType::Pointer connectorRegionGrowing = ConnectorType::New();
connectorRegionGrowing->SetInput(caster->GetOutput());
 
shiftRegionGrowing = vtkImageShiftScale::New();
shiftRegionGrowing->SetInput(connectorRegionGrowing->GetOutput());
shiftRegionGrowing->SetOutputScalarTypeToUnsignedShort();
     
mode3D = vtkInteractorStyleTrackballCamera::New();
 
renderer3D = vtkRenderer::New();
 
renderWindow3D = vtkRenderWindow::New();
renderWindow3D->AddRenderer(renderer3D);
 
displayImage3D->SetRenderWindow(renderWindow3D);
displayImage3D->SetInteractorStyle(mode3D);
displayImage3D->Initialize();
 
piecewiseRegionGrowing = vtkPiecewiseFunction::New();
piecewiseRegionGrowing->AddPoint(0,0.0);
piecewiseRegionGrowing->AddPoint((double)rangeEndWatershed,0);
piecewiseRegionGrowing->AddPoint((double)rangeEndWatershed+0.01,0.2);
piecewiseRegionGrowing->AddPoint((double)rangeBeginWatershed,0.2);
piecewiseRegionGrowing->AddPoint((double)rangeBeginWatershed+0.01/255,0);
piecewiseRegionGrowing->AddPoint(1,0);
 
volumeColorRegionGrowing = vtkColorTransferFunction::New();
volumeColorRegionGrowing->AddRGBPoint(0, 1.0, 1.0, 0.0);
volumeColorRegionGrowing->AddRGBPoint(1, 1.0, 1.0, 0.0);
 
volumePropertyRegionGrowing = vtkVolumeProperty::New();
volumePropertyRegionGrowing->SetColor(volumeColorRegionGrowing);
volumePropertyRegionGrowing->SetScalarOpacity(piecewiseRegionGrowing);
volumePropertyRegionGrowing->ShadeOn();
volumePropertyRegionGrowing->SetInterpolationTypeToLinear();
  
volumeRayCastMapperRegionGrowing = vtkFixedPointVolumeRayCastMapper::New();
volumeRayCastMapperRegionGrowing->SetInputConnection(shiftRegionGrowing->GetOutputPort());
volumeRayCastMapperRegionGrowing->CroppingOn();
volumeRayCastMapperRegionGrowing->SetCroppingRegionPlanes(minpoint4[0], maxpoint4[0], minpoint4[1], maxpoint4[1], minpoint4[2], maxpoint4[2]);
volumeRayCastMapperRegionGrowingCut->SetCroppingRegionFlagsToSubVolume();
 
volumeRegionGrowing = vtkVolume::New();
volumeRegionGrowing->SetProperty(volumePropertyRegionGrowing);
volumeRegionGrowing->SetMapper(volumeRayCastMapperRegionGrowing);
 
camera3D = vtkCamera::New();
camera3D->SetViewUp(0, 0, -1);
camera3D->SetPosition(0, 1, 0);
camera3D->SetFocalPoint(0, 0, 0);
camera3D->ComputeViewPlaneNormal();
camera3D->Azimuth(20);
 
renderer3D->AddViewProp(volumeRegionGrowing);
renderer3D->SetActiveCamera(camera3D);
renderer3D->ResetCamera();
camera3D->Dolly(1.3);
renderer3D->ResetCameraClippingRange();


__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100329/78f57851/attachment.htm>


More information about the vtkusers mailing list