[Insight-users] convolution restricted by mask
Soren Christensen
sorench at gmail.com
Sun Mar 31 01:40:19 EDT 2013
Maybe I was a little fast firing that one of.
I guess one could convolve the mask itself (0/1) with the kernel to get a
per-pixel weighting factor, W that can then be multiplied on the the
convolved image (where outside mask pixels are zeroed prior to convolution).
Still interested in hearing if I am missing something obvious here.
On Sat, Mar 30, 2013 at 8:55 PM, Soren Christensen <sorench at gmail.com>wrote:
> 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/161feaa4/attachment.htm>
More information about the Insight-users
mailing list