[vtkusers] How to render the contours of a binary image?

Thomas Kilgus t.kilgus at dkfz-heidelberg.de
Wed Jun 15 04:37:10 EDT 2011


Hi,

I attached some screenshots of my issue. The "BinaryImage.png" shows the 
actual contour (and of course the rest of the image) I would like to 
render (red). The "filterOutput.png" depicts
the filter output. The contour is not even corret, because some pixels 
are left out for some reason...

Regards
Thomas

On 15.06.2011 10:19, Thomas Kilgus wrote:
> Hi,
>
> I solved my issue. It wasn't about the data type but I was still
> applying a texture to the mapper.
>
> However, the vtkMarchingSquares - which is meant for image data -
> generates not the kind of contours I am looking for. I would like to
> render the edges of the image pixels. The filter interpolates the edges
> at corners. Is there any out the box way to render the edges of the
> pixels and make it look "stepped"?
>
> Regards
> Thomas
>
> On 10.06.2011 11:43, Thomas Kilgus wrote:
>> Hi,
>>
>> I figured out that I should use the the output of the vtkMarchingSquares
>> filter as input for the mapper. Furthmore, my data type of the
>> vtkImageData is actually char which seems to disturb the filter. How can
>> I apply such a filter on a char vtkImageData? Do I have to convert it first?
>>
>> regards
>> thomas
>>
>>
>> On 31.05.2011 16:29, Bill Lorensen wrote:
>>> Try,
>>> contourFilter->GenerateValues(1, .5, .5);
>>>
>>> On Tue, May 31, 2011 at 8:57 AM, Thomas Kilgus
>>> <t.kilgus at dkfz-heidelberg.de>    wrote:
>>>> hinHi Dominik,
>>>>
>>>> the documentation of vtkDiscreteMarchingCubes tells me that I should use
>>>> vtkMarchingSquares for 2D image slices (which i have in my case).
>>>> vtkDiscreteMarchingCubes is not applicable for data with dimension != 3. If
>>>> I use vtkMarchingSquares instead the following message occurs:
>>>> "vtkPainterPolyDataMapper: Mapper has no input" and my image is still
>>>> completely rendered in one color.
>>>>
>>>> regards
>>>> thomas
>>>>
>>>> On 31.05.2011 13:24, Dominik Szczerba wrote:
>>>>> See vtkDiscreteMarchingCubes.
>>>>> What I also do at times is to cast the binary image to float, smooth
>>>>> it, and then extract 0.5 value.
>>>>>
>>>>> On Tue, May 31, 2011 at 1:19 PM, Thomas Kilgus
>>>>> <t.kilgus at dkfz-heidelberg.de>      wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I am using a vtkPolyDataMapper to render images as a texture on a plane.
>>>>>> Some images (in the form of vtkImageData) just consist of the values 1.0
>>>>>> and
>>>>>> 0.0. By means of a vtkLookuptable I can easily render those images with a
>>>>>> single color (the 1.0 values) and with a transparent background (0.0
>>>>>> values). What would be the best way to render just the contours of those
>>>>>> images?
>>>>>>
>>>>>> I already found the vtkContourFilter. But when I use it like this:
>>>>>>
>>>>>>         vtkSmartPointer<vtkContourFilter>      contourFilter =
>>>>>> vtkSmartPointer<vtkContourFilter>::New();
>>>>>>         contourFilter->SetInput(image);
>>>>>>         contourFilter->GenerateValues(1, 1.0, 1.0);
>>>>>>         contourFilter->Update();
>>>>>>         texture->SetInputConnection(contourFilter->GetOutputPort());
>>>>>>
>>>>>> the whole image is just rendered as a single color.
>>>>>>
>>>>>> Is there anything wrong with my code or is the vtkContourFilter just not
>>>>>> the
>>>>>> appropriate filter for my task?
>>>>>>
>>>>>> regards
>>>>>> thomas kilgus
>>>>>> _______________________________________________
>>>>>> 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
>>>>>>
>>>>>>
>>>> _______________________________________________
>>>> 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 --------------
A non-text attachment was scrubbed...
Name: BinaryImage.png
Type: image/png
Size: 1769 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110615/ce989b1a/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filterOutput.png
Type: image/png
Size: 3860 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110615/ce989b1a/attachment-0001.png>


More information about the vtkusers mailing list