<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2900.2802" name=GENERATOR></HEAD>
<BODY dir=ltr>
<DIV><SPAN class=934241622-12072006><FONT face=Arial color=#0000ff size=2>Any 
ITK filter can have multiple inputs and outputs.&nbsp; The are many examples of 
such filters in the toolkit. The constructor for your filter will need to 
specify the number of required inputs and create any outputs above the standard 
single output.&nbsp; You will need to provide an implementation of MakeOutput() 
if the outputs can be different types.&nbsp; You will not need to change 
anything at the ImageToImageFilter level.&nbsp; You probably will need to create 
your own versions of the DiscreteGaussianImageFilter and the 
NeighborhoodOperatorImageFilter to accommodate the weights.&nbsp; These new 
versions could be subclasses of the current DiscreteGaussian and 
NeighborhoodOperator filters or parallel classes.</FONT></SPAN></DIV>
<DIV><SPAN class=934241622-12072006><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=934241622-12072006><FONT face=Arial color=#0000ff 
size=2>Jim</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> 
  insight-users-bounces+millerjv=crd.ge.com@itk.org 
  [mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org]<B>On Behalf Of 
  </B>Avner MOSHKOVITZ<BR><B>Sent:</B> Wednesday, July 12, 2006 3:17 
  PM<BR><B>To:</B> insight-users@itk.org<BR><B>Subject:</B> [Insight-users] 
  Constructing a filter with multiple inputs / outputs<BR><BR></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006>Hi,</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006>Still waiting for an answer...</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=965274018-12072006>Is 
  there a way to handle multiple inputs/outputs within a 
  filter?</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT size=+0><SPAN class=965274018-12072006>
  <DIV><SPAN class=965274018-12072006></SPAN><FONT face=Arial color=#0000ff 
  size=2><SPAN class=965274018-12072006>The input image contains pixels with 
  invalid values, which need to be ignored during the filtering. 
  </SPAN></FONT><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN 
  class=965274018-12072006>Therefore, the </SPAN>itkDiscreteGaussian filter 
  needs to be applied selectively&nbsp;only to&nbsp;valid 
  pixels.</FONT></FONT></FONT></SPAN></FONT></DIV></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=965274018-12072006>To 
  do that, during smartInnerProduct, the kernel weights are accumulated. In the 
  regular case the kernel weights sum up to 1.0 but in this case the kernel 
  weights sum up to&nbsp;a number&nbsp;smaller than 1.0 which are kept in a 
  weight image (after the filtering ends, the final weight image is used to 
  normalize the result value for the filtered pixels).</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=965274018-12072006>So, 
  I'm looking for a way to introduce an input&nbsp;weight image and an output 
  weight image to the filter as additional input/output to the input image and 
  the filtered image.</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=965274018-12072006>The 
  output&nbsp;weight image from each filter (I'm using to two filters, one for 
  each dimension) should be fed as input to the next filter, in the same way as 
  the chaining of the images.</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=965274018-12072006>In 
  the construction of the itkDiscreteGaussianFilter the input/output images are 
  penetrated&nbsp;to the base classes (<FONT 
  size=2>NeighborhoodOperatorImageFilterWithWeight, <FONT 
  size=2>ImageToImageFilter).</FONT></FONT></SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=965274018-12072006>My 
  question is, how should&nbsp;I introduce the weight images as additional 
  input/output without having to change the code in the base 
  classes?</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006>Thanks,</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006>Avner</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=965274018-12072006></SPAN></FONT>&nbsp;</DIV>
  <DIV>
  <HR tabIndex=-1>
  </DIV>
  <DIV><FONT face=Tahoma size=2><B>From:</B> Avner MOSHKOVITZ <BR><B>Sent:</B> 
  Thursday, July 06, 2006 5:26 PM<BR><B>To:</B> 
  'insight-users@itk.org'<BR><B>Subject:</B> I need to customize 
  itkDiscreteGaussianImageFilter.txx to smooth an image with holes in 
  it<BR></FONT><BR></DIV>
  <DIV></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial 
  size=2>Hi,</FONT></SPAN></DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial size=2>I'm trying to 
  customize </FONT></SPAN><SPAN class=127460023-06072006><FONT face=Arial 
  size=2>itkDiscreteGaussianImageFilter.txx </FONT></SPAN><SPAN 
  class=127460023-06072006><FONT face=Arial size=2>to smooth an image with holes 
  in it.</FONT></SPAN></DIV>
  <DIV><SPAN class=127460023-06072006></SPAN><SPAN 
  class=127460023-06072006><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial size=2>With the current 
  implementation every pixel in the input image must have a valid value in it 
  and all the pixels are pipelined into the Gaussian filter.</FONT></SPAN></DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial size=2>In my case the 
  input image has invalid values in it which are signed with a predefined 
  value.</FONT></SPAN></DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial size=2>I am applying the 
  <FONT size=2>smartInnerProduct only to valid pixels. The weight of the kernel 
  is accumulated (will be less than 1 in case of holes). Then the pixel value is 
  divided by the accumulated weight to get the smoothed 
  value.</FONT></FONT></SPAN></DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial size=2>Since the Gaussian 
  filter is applied twice (separable kernel)&nbsp;in each dimension, I need to 
  maintain the weights in a separate image, keep updating them during the runs. 
  After final output image should be divided by the accumulated weight 
  image.</FONT></SPAN></DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial size=2>In my case the 
  filter should have 2 inputs (an input image and&nbsp;an input weight image) 
  and 2 outputs (an output image and an output weight 
image).</FONT></SPAN></DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial size=2>If I change the 
  structure of NeighborhoodOperatorImageFilter.txx to have the weight images, I 
  should then change ImageToImageFilter class and then Image source class and so 
  on.</FONT></SPAN></DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial size=2>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial size=2>My question is: 
  </FONT></SPAN><SPAN class=127460023-06072006><FONT face=Arial size=2>how do I 
  make the changes into ITK to incorporate an input and output weight 
  images?</FONT></SPAN></DIV></FONT></SPAN></DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=127460023-06072006><FONT face=Arial 
  size=2></FONT></SPAN>&nbsp;</DIV><!-- Converted from text/rtf format -->
  <P><SPAN lang=en-ca><FONT face=Arial size=2>Thanks,</FONT></SPAN> <BR><SPAN 
  lang=en-ca><FONT face=Arial size=2>Avner</FONT></SPAN> </P>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML>