[vtkusers] vtkImageStencil, vtkImageMask?

David Gobbi david.gobbi at gmail.com
Wed Jul 10 11:40:38 EDT 2013


Hi Richard,

The vtkImageStencil can do what you want, but the median filter
doesn't support stencils directly.  So you would have to do something
like this:

1) pass the whole image though the median filter
2) use both the original image and the filtered image as inputs to
vtkImageStencil, so that the desired "filtered area" in the original
image will be replaced by pixels from the median filtered image.

I've been hoping that more of the VTK image filters would be modified
so that they can directly work with stencils, but it just hasn't
happened.  I contributed a helper class called vtkImageStencilIterator
so that people can write filters that operate on just some pixels and
pass the rest of the pixels unchanged, but I don't think that anyone
has ever used this class except for myself.

 - David

On Wed, Jul 10, 2013 at 9:00 AM, Richard Frank <rickfrank at me.com> wrote:
> Hi
>
> In a previous post, I asked if there was a best-practice way to apply a
> filter to a sub-region of an ImageData 2D object.
>
> For instance, I want to median filter a small area in the center of the
> image, while passing the rest of the pixels through the chain unchanged.
>
>
> Image
> _________________________________
> |                                                         |
> |                  ________                           |
> |                 |  filtered   |                           |
> |                 |   area     |                           |
> |                 |--------------|                           |
> |                                                         |
> ----------------------------------------------------------
>
>
>
> I didn't receive a response, and have looked at vtkImageMask and
> vtkImageStencil.
>
> vtkImageMask doesn't quite do what I want sets the pixels outside the mask
> to a constant color.
>
> vtkImageStencil - is this capable of doing what I want to do? I'm not quite
> sure how it works.....
>
>
> Image
> _________________________________
> |                                                         |
> |                  ________                           |
> |                 |  filtered   |                           |
> |                 |   area     |                           |
> |                 |--------------|                           |
> |                                                         |
> ----------------------------------------------------------
>
>
> Thanks
>
> Rick



More information about the vtkusers mailing list