[vtkusers] Clipping image data with polygon data.
superzz
jxdw_zlf at yahoo.com.cn
Mon Jan 18 11:43:18 EST 2010
vtkMarchingCubes *_skinExtractor = vtkMarchingCubes::New();
_skinExtractor->SetInput(bmpreader->GetOutput());
_skinExtractor->SetValue(0, 15);
vtkStripper *_skinStripper = vtkStripper::New();
_skinStripper->SetInput(_skinExtractor->GetOutput());
vtkPolyDataToImageStencil *dataToStencil =
vtkPolyDataToImageStencil::New();
dataToStencil->SetInput(_skinStripper->GetOutput());
dataToStencil->SetOutputSpacing(bmpreader->GetDataSpacing());
vtkImageStencil *_vtkImageStencil = vtkImageStencil::New();
_vtkImageStencil->SetInput(bmpreader->GetOutput());
_vtkImageStencil->SetStencil(dataToStencil->GetOutput());
_vtkImageStencil->ReverseStencilOn();
_vtkImageStencil->SetBackgroundValue(50000);
_vtkImageStencil->Update();
The last line _vtkImageStencil->Update() never return.
Thanks
superZZ
David Gobbi-3 wrote:
>
> Please provide a few lines of code, so that I can get an idea about
> what might be going wrong.
>
> David
>
>
> On Sun, Jan 17, 2010 at 9:55 PM, superzz <jxdw_zlf at yahoo.com.cn> wrote:
>>
>> Hello David Gobbi
>> Thank you for your response.
>> The example works fine. I can see the result in ImageViewer. I want to
>> export stencil image to raw file now. However, if I call
>> imageStencil.Update() manually, Update() never returns. Why this happens?
>>
>> Thanks
>>
>> superZZ
>>
>>
>> David Gobbi-3 wrote:
>>>
>>> Hi SuperZZ,
>>>
>>> One way that I've done this is with vtkImplicitSelectionLoop, which is
>>> a vtkImplicitFunction that takes a vtkPoints list that defines a
>>> polygon. Then vtkImplicitFunctionToImageStencil can create an image
>>> stencil, and vtkImageStencil can apply the stencil to the image and
>>> black out everything outside the polygon.
>>>
>>> There are two simple testing examples for stenciling images (both of
>>> these examples are for 3D images and 3D selection regions, though):
>>> VTK/Imaging/Testing/Tcl/TestStencilWithFunction.tcl
>>> VTK/Hybrid/Testing/Tcl/TestImageStencilWithPolydata.tcl
>>>
>>> It's probably also possible to use vtkProbeFilter to create a "mask"
>>> image from your polygon.
>>>
>>> David
>>>
>>>
>>> On Fri, Jan 15, 2010 at 2:46 AM, superzz <jxdw_zlf at yahoo.com.cn> wrote:
>>>>
>>>> Hello
>>>> I wanna know does VTK support clipping image data with specified
>>>> polygon
>>>> data.
>>>>
>>>> I am developping a segmentation program. What I want to implement is,
>>>> first
>>>> user pick some connected polygons, then the program keeps the regions
>>>> of
>>>> image data covered by picked polygons. Erase other regions of image
>>>> data
>>>> to
>>>> black.
>>>>
>>>> Thanks!
>>>>
>>>> superZZ
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Clipping-image-data-with-polygon-data.-tp27173364p27173364.html
>>>> Sent from the VTK - Users mailing list archive at Nabble.com.
>>>>
>>>> _______________________________________________
>>>> 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
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Clipping-image-data-with-polygon-data.-tp27173364p27206195.html
>> Sent from the VTK - Users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> 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
>
>
--
View this message in context: http://old.nabble.com/Clipping-image-data-with-polygon-data.-tp27173364p27213200.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list