<div dir="ltr">Maybe I was a little fast firing that one of. <div style>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).</div>
<div style>Still interested in hearing if I am missing something obvious here.</div><div style><br></div><div style> </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Mar 30, 2013 at 8:55 PM, Soren Christensen <span dir="ltr"><<a href="mailto:sorench@gmail.com" target="_blank">sorench@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div> I'd like to run convolutions at locations of a mask while limiting the kernel to the pixels inside the mask. For example:</div>
<div>Mask</div><div>1 1 0</div><div>1 1 1</div>
<div>1 1 1</div><div><br></div><div>kernel:</div><div>1/9 1/9 1/9</div><div>1/9 1/9 1/9 </div><div>1/9 1/9 1/9</div><div><br></div><div>Source image:</div><div>0.5 0.5 0.2</div>
<div>0.5 0.5 0.5<br></div><div>0.5 0.5 0.5<br></div><div><br></div><div>In this case I'd like the convolution results for pixel [1,1] (center in this example) to be </div><div>8*0.5*1/(8) = 0.5</div>
<div>My kernels will always have mean 1.</div><div><br></div><div>So effectively the kernel is adapted at each iteration based on the mask. (Rationale is that only valid pixels contribute to the smoothed result).</div>
<div>I have usually achieved this in Matlab by filling the non mask pixels with nanmean and nansum.</div><div><br></div><div>I am not sure of the best way to achieve this in ITK - I can't see an obvious way of doing it.</div>
<div>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?</div><div><br></div><div>Thanks,</div><div>Soren</div>
<div><br></div></div>
</blockquote></div><br></div>