[vtkusers] Help!!!!! VtkMarchingCubes::SetValue

Vicky bonsai19 at gmx.de
Sun Nov 2 18:40:56 EST 2008


Hi Bill,

thank you for your fast help.

I set the value to 127.5 but I get no model anyway. No surface is 
generated using  vtkDiscreteMarchingCubes.
I'm really desparate...

When I run my script, I get the following errors:


ERROR: In m:\dev\cur\vtkdotnet\branch\50\Graphics\vtkDecimatePro.cxx, 
line 161
vtkDecimatePro (04042A88): No data to decimate!

ERROR: In 
m:\dev\cur\vtkdotnet\branch\50\Graphics\vtkSmoothPolyDataFilter.cxx, 
line 212
vtkSmoothPolyDataFilter (04053210): No data to smooth!

ERROR: In 
m:\dev\cur\vtkdotnet\branch\50\Graphics\vtkPolyDataNormals.cxx, line 94
vtkPolyDataNormals (040540D0): No data to generate normals for!


I think that the segmented labeled images that I read are not correct. 
Or I can't read them.

My proceeding to get labeled images is the following:
I have 160 segmented bitmap-images available. Each file is 234 x 340.
 At first I built one file per tissue (color). Then I create (with 
matlab) binary labeled images for each tissue.
For example, I'm going to assume there are 4 colors (red, green, blue, 
black) in a slice.Then I get 3 images, that I call {Red, Green, Blue}. 
So each of these images is a matrix full of 1's and 0's. If I bring the 
seperated images together again I have to change the 1's in something 
else so that I can distinguish the different tissues (colors).
          Red = Red                  //leave as 1
          Blue = 2 * Blue           //change to label 2
          Green = 3 * Green;     //change to label 3
Now if I add them together, different tissues have differnt labels.
At this time I have binary labeled bitmap-images.

I think a surface is extracted using the binary labeled images. But I 
get errors.

What is wrong with my labeled images?

This is how I read my data:

                vtkBMPReader bmpReader = new vtkBMPReader();
                bmpReader.SetDataExtent(0, 340, 0,234, 1, 160);
                bmpReader.SetDataSpacing(dataSpacing);
                bmpReader.SetFilePattern(imageVTK.data);
                bmpReader.SetDataScalarTypeToUnsignedShort();
                bmpReader.GetOutput().ReleaseDataFlagOn();
                bmpReader.Update();

                public vtkImageAlgorithm image;
                image = bmpReader;



Bill Lorensen schrieb:
> Vicky,
>
> In your example, Threshold selects segment label 1 and converts all
> voxels to either 0 or 255. Using this pipeline you should always
> select the isovalue to be midway between 0 and 255 (127.5). If you
> want tosegment label 27 for example, threshold.SetBetween(27,27). But
> the isovalue will still be 127.5.
>
> This method of creating surfaces from segemented data is old although
> still valid. I would recommend using vtkDiscreteMarchingCubes to
> generate surfaces from segmentation labels.
>
> But first, try the value of 127.5 and see how you like the results.
>
> Bill
>
> On Fri, Oct 31, 2008 at 6:34 AM, Vicky <bonsai19 at gmx.de> wrote:
>   
>> Hi there,
>>
>> I'll be grateful if someone can help me out.
>>
>> I want to create models from segmented 2D images (slices).
>> I have used code like the VTK frog-example from the book "Visualization
>> Toolkit: An Object-Oriented Approach to 3D Graphics":
>>
>>           vtkImageThreshold threshold = new vtkImageThreshold();
>>           threshold.ThresholdBetween(1,1);
>>           threshold.SetInValue(255);
>>           threshold.SetOutValue(0);
>>           threshold.SetInput(image.GetOutput());
>>
>>           vtkImageShrink3D shrink = new vtkImageShrink3D();
>>           shrink.SetInput(threshold.GetOutput());
>>           shrink.SetShrinkFactors(shrinkFactor);
>>           shrink.AveragingOn();
>>
>>           vtkImageGaussianSmooth gaussiansmooth = new
>> vtkImageGaussianSmooth();
>>           gaussiansmooth.SetDimensionality(3);
>>           gaussiansmooth.SetStandardDeviation(gaussianStandardDeviation);
>>           gaussiansmooth.SetInput(shrink.GetOutput());
>>
>>           vtkImageToStructuredPoints structuredPoints = new
>> vtkImageToStructuredPoints();
>>           structuredPoints.SetInput(gaussiansmooth.GetOutput());
>>           structuredPoints.GetOutput().ReleaseDataFlagOn();
>>
>>           vtkMarchingCubes marchingCubes = new vtkMarchingCubes();
>>           marchingCubes.SetInput(structuredPoints.GetOutput());
>>           marchingCubes.ComputeScalarsOff();
>>           marchingCubes.ComputeGradientsOff();
>>           marchingCubes.ComputeNormalsOff();
>>           marchingCubes.SetValue(0, 450);
>>
>>           vtkDecimatePro decimate = new vtkDecimatePro();
>>           decimate.SetInput(marchingCubes.GetOutput());
>>           decimate.SetFeatureAngle(60.0);
>>           decimate.SetMaximumError(1);
>>           decimate.SetTargetReduction(decimateReduction);
>>           decimate.GetOutput().ReleaseDataFlagOn();
>>
>>           vtkSmoothPolyDataFilter smoother = new vtkSmoothPolyDataFilter();
>>           smoother.SetInput(decimate.GetOutput());
>>           smoother.SetNumberOfIterations(smoothIterations);
>>           smoother.SetRelaxationFactor(RelaxionsFactor);
>>           smoother.SetFeatureAngle(smoothAngle);
>>           smoother.FeatureEdgeSmoothingOff();
>>           smoother.SetConvergence(0);
>>           smoother.GetOutput().ReleaseDataFlagOn();
>>
>>           vtkPolyDataNormals normals = new vtkPolyDataNormals();
>>           normals.SetInput(smoother.GetOutput());
>>           normals.SetFeatureAngle(featureAngle);
>>           normals.GetOutput().ReleaseDataFlagOn();
>>
>>           vtkStripper stripper = new vtkStripper();
>>           stripper.SetInput(normals.GetOutput());
>>           stripper.GetOutput().ReleaseDataFlagOn();
>>
>>           vtkPolyDataWriter writer = new vtkPolyDataWriter();
>>           writer.SetInput(stripper.GetOutput());
>>           writer.SetFileName("Ratte_Lila.vtk");
>>           writer.SetFileType(2);
>>
>>           ... and so on!
>>
>> I think the pipeline is correct
>>
>> But my problem is I can't determine which value is used in SetValue-function
>> of the vtkMarchingCubes-class. I don't know how to calculate it.This value
>> seems to be different to which tissue will be rendered. But how can I
>> calculate this value for each tissue?
>>
>> I know the first parameter is the contour-number. Is this right?
>>
>>
>> Can anyone help me?
>> I'm using vtk 5.0
>>
>> Thanks!
>>
>> Vicky
>> _______________________________________________
>> This is the private VTK discussion list.
>> Please keep messages on-topic. Check the FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>     
>
>   




More information about the vtkusers mailing list