[Insight-users] [vtkusers] Region Growing (Volume Rendering) Cropping Problem
Yusuf OEZBEK
nasil122002 at yahoo.de
Tue Apr 6 22:07:24 EDT 2010
Hello,
Okay, I have tried it with vtkContourFilter and it works, but still takes cropping problem. How can I be sure or determine the spatial coordinates that correct? What function in vtk should I use for cropping of the 3D-image? I think the problem lies not in the direction of the camera., but read with the pictures. Please help.
Thank you!
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::ConfidenceConnectedImageFilter<InternalImageType, OutputImageType> ConnectedFilterType;
ConnectedFilterType::Pointer confidenceConnected = ConnectedFilterType::New();
confidenceConnected->SetInput(reader->GetOutput());
confidenceConnected->SetMultiplier(2.5);
confidenceConnected->SetNumberOfIterations(2);
confidenceConnected->SetReplaceValue(255);
InternalImageType::IndexType index;
index[0] = (int)this->changeRegionGrowingInputX->value();
index[1] = (int)this->changeRegionGrowingInputY->value();
index[2] = (int)this->changeRegionGrowingInputZ->value();
confidenceConnected->AddSeed( index );
typedef itk::VTKImageExport< InternalImageType > ExportFilter1Type;
typedef itk::VTKImageExport< OutputImageType > ExportFilter2Type;
ExportFilter1Type::Pointer itkExporter1 = ExportFilter1Type::New();
ExportFilter2Type::Pointer itkExporter2 = ExportFilter2Type::New();
itkExporter1->SetInput( reader->GetOutput() );
itkExporter2->SetInput( confidenceConnected->GetOutput() );
vtkImageImport* vtkImporter1 = vtkImageImport::New();
ConnectPipelines(itkExporter1, vtkImporter1);
vtkImageImport* vtkImporter2 = vtkImageImport::New();
ConnectPipelines(itkExporter2, vtkImporter2);
vtkImporter1->Update();
mode3D = vtkInteractorStyleTrackballCamera::New();
renderer3D = vtkRenderer::New();
renderWindow3D = vtkRenderWindow::New();
renderWindow3D->AddRenderer(renderer3D);
displayImage3D->SetRenderWindow(renderWindow3D);
displayImage3D->SetInteractorStyle(mode3D);
displayImage3D->Initialize();
contour = vtkContourFilter::New();
contour->SetInput( vtkImporter2->GetOutput() );
contour->ComputeNormalsOn();
contour->ComputeGradientsOn();
contour->ComputeScalarsOn();
contour->SetNumberOfContours(2);
contour->SetValue(0, 255);
polyMapper = vtkPolyDataMapper::New();
polyMapper->SetInput(contour->GetOutput());
polyMapper->ScalarVisibilityOff();
polyActor = vtkActor::New();
polyActor->SetMapper(polyMapper);
propertyRegionGrowing = vtkProperty::New();
propertyRegionGrowing->SetAmbient(0.3);
propertyRegionGrowing->SetDiffuse(1.0);
propertyRegionGrowing->SetSpecular(0.2);
propertyRegionGrowing->SetSpecularPower(10.0);
propertyRegionGrowing->SetColor(1, 1, 1);
propertyRegionGrowing->SetRepresentationToSurface();
polyActor->SetProperty(propertyRegionGrowing);
camera3D = vtkCamera::New();
camera3D->SetViewUp(0, 0, -1);
camera3D->SetPosition(0, 1, 0);
camera3D->SetFocalPoint(0, 0, 0);
camera3D->ComputeViewPlaneNormal();
camera3D->Azimuth(20);
renderer3D->AddActor(polyActor);
renderer3D->SetActiveCamera(camera3D);
renderer3D->ResetCamera();
camera3D->Dolly(1.3);
renderer3D->ResetCameraClippingRange();
________________________________
Von: Luis Ibanez <luis.ibanez at kitware.com>
An: Yusuf OEZBEK <nasil122002 at yahoo.de>
CC: ITK Mailinglist <insight-users at itk.org>; VTK Mailinglist <vtkusers at vtk.org>; nasil122002 at gmail.com
Gesendet: Dienstag, den 30. März 2010, 0:48:58 Uhr
Betreff: Re: [vtkusers] Region Growing (Volume Rendering) Cropping Problem
Hi Yusuf,
The output of the Region Growing filters in ITK are binary images.
The fist thing you should do is to make sure that your camera is
looking in the right direction.
To this end, you could simply introduce first a surface-based visualization
of the binary image, by passing it through the vtkContour filter, as illustrated
in the examples :
InsightApplications/Auxiliary/vtk/
itkReadITKImage3DExtractContourVTK.cxx
ExtractIsoSurface.cxx
ScreenShotGenerator.cxx
http://public.kitware.com/cgi-bin/viewcvs.cgi/Auxiliary/vtk/?root=InsightApplications
Once you have made sure that your spatial coordinates are correct,
you could proceed to setup a volume rendering visualization.
You should then make sure that you use a transfer function suitable
for an image whose pixel values are only { 0, 255 }. The transfer
function that you may have used for the original values of the DICOM
image, will probably not be appropriate for the binary values of the
segmented image.
Also, please note that Volume Rendering (although it is an extremly
useful visualization method) is not a substitute for image segmentation
methods.
Regards,
Luis
-----------------------------------------------------------------------------------------------
On Mon, Mar 29, 2010 at 6:10 AM, Yusuf OEZBEK <nasil122002 at yahoo.de> wrote:
> 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.
>
>
>
__________________________________________________
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.itk.org/pipermail/insight-users/attachments/20100407/d290292b/attachment.htm>
More information about the Insight-users
mailing list