[vtkusers] 2D segmented colored images transform in 3D volume

Wiebke bonsai19 at gmx.de
Wed Jul 30 12:54:03 EDT 2008


Hi vtk users,

I have a dataset of 2D segmented images of a ratbrain. These images are 
colored. I have not the original gray-scale images of the ratbrain. Now, 
I would like to produce a 3D volume from these 2D images. I wrote a 
program, which represents the contours of these segmented images as a 3D 
model.


My code looks like:

vtkBMPReader bmpReader = new vtkBMPReader();
bmpReader.SetFileDimensionality(2);
bmpReader.SetFilePattern(imageVTK.data);
bmpReader.SetDataScalarTypeToUnsignedChar();
 bmpReader.SetDataExtent(0, imageVTK.dimX, 0, imageVTK.dimY, 
imageVTK.rangeFrom, imageVTK.rangeTo);
bmpReader.SetDataSpacing(dataSpacing);
bmpReader.Update();

image = bmpReader;

//Pipeline
vtkImageShrink3D shrinker = new vtkImageShrink3D();
shrinker.SetInputConnection(image.GetOutputPort());
shrinker.SetShrinkFactors(1, 1, 1);
shrinker.AveragingOn();

vtkImageGaussianSmooth gaussian = new vtkImageGaussianSmooth();
gaussian.SetInput(shrinker.GetOutput());
gaussian.SetDimensionality(3);
gaussian.SetStandardDeviation(0, 0, 0);
gaussian.SetRadiusFactor(1);

vtkImageToStructuredPoints toStructuredPoints = new 
vtkImageToStructuredPoints();
toStructuredPoints.SetInput(image.GetOutput());
toStructuredPoints.Update();
 toStructuredPoints.GetOutput().ReleaseDataFlagOn();

vtkMarchingCubes mcubes = new vtkMarchingCubes();
mcubes.SetInputConnection(toStructuredPoints.GetOutputPort());
mcubes.ComputeScalarsOff();
mcubes.ComputeGradientsOn();
mcubes.ComputeNormalsOn();
mcubes.SetValue(0, 127.5);
mcubes.GetOutput().ReleaseDataFlagOn();

vtkSmoothPolyDataFilter smoother = new vtkSmoothPolyDataFilter();
smoother.SetInput(mcubes.GetOutput());
smoother.SetNumberOfIterations(0);
smoother.SetRelaxationFactor(0.01);
smoother.FeatureEdgeSmoothingOff();
smoother.BoundarySmoothingOff();
smoother.SetConvergence(0);
smoother.GetOutput().ReleaseDataFlagOn();

vtkPolyDataNormals normals = new vtkPolyDataNormals();
normals.SetInputConnection(smoother.GetOutputPort());
normals.SetFeatureAngle(60);
normals.GetOutput().ReleaseDataFlagOn();

vtkStripper stripper = new vtkStripper();
stripper.SetInputConnection(normals.GetOutputPort());
stripper.GetOutput().ReleaseDataFlagOn();

vtkPolyDataWriter writer = new vtkPolyDataWriter();
writer.SetInputConnection(stripper.GetOutputPort());
writer.SetFileName("Mensch.vtk");
writer.Update();

vtkProperty propTissue = new vtkProperty();
propTissue.SetDiffuseColor(1, 0, 0);
propTissue.SetSpecularPower(50);
propTissue.SetSpecular(0.5);
propTissue.SetDiffuse(0.8);

vtkPolyDataReader readerTissue = new vtkPolyDataReader();
readerTissue.SetFileName("Mensch.vtk");

vtkPolyDataMapper mapperTissue = new vtkPolyDataMapper();
mapperTissue.SetInput(readerTissue.GetOutput());

vtkActor m_actor = new vtkActor();
m_actor.SetMapper(mapperTissue);
m_actor.SetProperty(propTissue);




Is it possible to create a 3D model, which include all the colored 
segments that are locate in the 2D images? The 3D output model should 
looks like the colored segmented 2D input images. How can I get such a 
3D model?

Can somebody help me, please.

Regards,
         
       Vicky



More information about the vtkusers mailing list