[Insight-users] Masked UnaryFunctorImageFilter

Luis Ibanez luis.ibanez at kitware.com
Mon Oct 25 09:01:48 EDT 2010


David,

Yes, but that will imply to modify the UnaryFunctorImageFilter
and penalize all of its derived classes with an "if" that may
or may not get used.

A potential way to implement this could be to have in the
ThreadedGenerateData() method, two separate loops,
one that expects a mask and another that do not expects
a mask.  In that way, you can avoid penalizing all uses of
the filter.

Please give it a try at modifying the loop and feel free
to submit a patch to Gerrit.


    Thanks


         Luis


-----------------------------------------------------------
On Sun, Oct 24, 2010 at 6:35 PM, David Doria <daviddoria at gmail.com> wrote:

> Instead of applying a Functor to EVERY pixel using UnaryFunctorImageFilter,
> is there a way to pass it (or something else) a mask to tell it only to
> apply the function on the masked pixels?
>
> I often find myself doing:
>
>   while(!imageIterator.IsAtEnd())
>     {
>     // If the pixel is not enabled in the mask, skip it
>     if(imageIterator.Get() == 0)
>       {
>       output->SetPixel(imageIterator.GetIndex(), 0);
>       continue;
>       }
>
>     PixelType value = MyFunctor(imageIterator.GetIndex());
>    ....
>
>     output->SetPixel(imageIterator.GetIndex(), value);
>     ++imageIterator;
>     }
>
> Thanks,
>
> David
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101025/90b7c1e7/attachment.htm>


More information about the Insight-users mailing list