[vtkusers] iterating through vtkImageStencilData

David Gobbi david.gobbi at gmail.com
Wed Jul 21 11:42:52 EDT 2010


You can use the vtkImageStencil filter to create a binary image that
matches the stencil.  You will need to use a blank white image of the
correct size as an input to vtkImageStencil, and the output will be a
binary image.

   David


On Wed, Jul 21, 2010 at 9:30 AM, Prathamesh Kulkarni
<prathameshmkulkarni at gmail.com> wrote:
> I find it very complicated to port into my code. All I need to do is to
> write the pixel values corresponding to the stencil into a text file (in any
> order). I tried getting the extent of the stencil by:
>
> vtkImplicitFunctionToImageData->GetExtent(); but this gives me the whole
> extent of the InformationInput (vtkImageData). Isn't there a simple way to
> do this? My idea is to iterate over vtkImageData using extent of the
> stencil. Is this a good/viable idea?
>
> Prathmesh
>
> On Wed, Jul 21, 2010 at 9:40 AM, David Gobbi <david.gobbi at gmail.com> wrote:
>>
>> Hi Prathamesh,
>>
>> Take a look at the code for the filters that use vtkImageStencilData,
>> for example see vtkImageAccumulate.cxx at line 200.  The
>> vtkImageStencilData does not store the raw pixel data.  It uses a form
>> of run-length encoding instead.
>>
>>  David
>>
>>
>> On Wed, Jul 21, 2010 at 8:31 AM, Prathamesh Kulkarni
>> <prathameshmkulkarni at gmail.com> wrote:
>> > Hi David,
>> >
>> > Thanks for the direction. The documentation does not make it very clear
>> > to
>> > me. Could you please point/cook me a little example for accessing pixel
>> > values of vtkImageStencilData using the method you suggested? If I am
>> > able
>> > to do it, I'll post it out.
>> >
>> >
>> > Prathamesh
>> >
>> > On Tue, Jul 20, 2010 at 6:34 PM, David Gobbi <david.gobbi at gmail.com>
>> > wrote:
>> >>
>> >> Hi Prathamesh,
>> >>
>> >> You can use the following method of vtkImageStencilData to do the
>> >> iteration:
>> >>
>> >>  int vtkImageStencilData::GetNextExtent(int &r1, int &r2, int xMin,
>> >>            int xMax, int yIdx, int zIdx, int &iter);
>> >>
>> >> The documentation describes what each of the parameters is for.  I
>> >> started work on a proper iterator for vtkImageStencilData many, many
>> >> years ago but never found time to finish it.
>> >>
>> >>  David
>> >>
>> >>
>> >> On Tue, Jul 20, 2010 at 5:00 PM, Prathamesh Kulkarni
>> >> <prathameshmkulkarni at gmail.com> wrote:
>> >> > Hello all,
>> >> >
>> >> > I want to be able to write vtkImageStencilData to text files in a CSV
>> >> > format
>> >> > in order to be analyzed in some other software.
>> >> >
>> >> > I could not find a way to iterate through vtkImageStencilData similar
>> >> > to
>> >> > vtkImageData.
>> >> >
>> >> > One idea is to convert the vtkImageStencilData to vtkImageData and
>> >> > then
>> >> > use
>> >> > vtkImageIterator. However, I do not know how to perform this
>> >> > conversion.
>> >> >
>> >> > Has anyone tried this before? How?
>> >> >
>> >> > Thanks,
>> >> > Prathamesh
>> >> >
>> >> > _______________________________________________
>> >> > 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
>> >> >
>> >> >
>> >
>> >
>
>



More information about the vtkusers mailing list