[Insight-users] convolution restricted by mask

Soren Christensen sorench at gmail.com
Sat Mar 30 23:55:39 EDT 2013


Hi,
 I'd like to run convolutions at locations of a mask while limiting the
kernel to the pixels inside the mask. For example:
Mask
1 1 0
1 1 1
1 1 1

kernel:
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9

Source image:
0.5 0.5 0.2
0.5 0.5 0.5
0.5 0.5 0.5

In this case I'd like the convolution results for pixel [1,1] (center in
this example) to be
8*0.5*1/(8) = 0.5
My kernels will always have mean 1.

So effectively the kernel is adapted at each iteration based on the mask.
(Rationale is that only valid pixels contribute to the smoothed result).
I have usually achieved this in Matlab by filling the non mask pixels with
nanmean and nansum.

I am not sure of the best way to achieve this in ITK - I can't see an
obvious way of doing it.
It seems I need to recalculate the kernel for each iteration - am I looking
at implementing a new filter or can I use an existing filter for this?

Thanks,
Soren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130330/2c0f10eb/attachment.htm>


More information about the Insight-users mailing list