[Insight-users] Weighted sum of two PNG images

Jayant Chauhan gripened at hotmail.com
Sat, 01 May 2004 15:44:03 +0530


<html><div style='background-color:'><DIV class=RTE>Hey fellas,</DIV>
<DIV class=RTE>A lil confused. To make my own Filter to find the weighted mean of two images (PNG), what changes do I need to make in the AddImageFilter.h ?!! </DIV>
<DIV class=RTE>And do I just have to include the header file that I create in my directory.</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>I am not sure as to how to use the AccumulorType, as in, what all operations are defined for it. So could you please let me know what changes to be made in the inline operator() part of the code. </DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>/*=========================================================================</DIV>
<DIV class=RTE>&nbsp; Program:&nbsp;&nbsp; Insight Segmentation &amp; Registration Toolkit<BR>&nbsp; Module:&nbsp;&nbsp;&nbsp; $RCSfile: itkAddImageFilter.h,v $<BR>&nbsp; Language:&nbsp; C++<BR>&nbsp; Date:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Date: 2003/09/10 14:28:43 $<BR>&nbsp; Version:&nbsp;&nbsp; $Revision: 1.7 $</DIV>
<DIV class=RTE>&nbsp; Copyright (c) Insight Software Consortium. All rights reserved.<BR>&nbsp; See ITKCopyright.txt or <A href="http://www.itk.org/HTML/Copyright.htm">http://www.itk.org/HTML/Copyright.htm</A> for details.</DIV>
<DIV class=RTE>&nbsp;&nbsp;&nbsp;&nbsp; This software is distributed WITHOUT ANY WARRANTY; without even <BR>&nbsp;&nbsp;&nbsp;&nbsp; the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR <BR>&nbsp;&nbsp;&nbsp;&nbsp; PURPOSE.&nbsp; See the above copyright notices for more information.</DIV>
<DIV class=RTE>=========================================================================*/<BR>#ifndef __itkWeightedAddImageFilter_h<BR>#define __itkWeigthedAddImageFilter_h</DIV>
<DIV class=RTE>#include "itkBinaryFunctorImageFilter.h"<BR>#include "itkNumericTraits.h"</DIV>
<DIV class=RTE><BR>namespace itk<BR>{<BR>&nbsp; </DIV>
<DIV class=RTE>namespace Functor {&nbsp; <BR>&nbsp; <BR>template&lt; class TInput1, class TInput2, class TOutput, float &gt;<BR>class WeightedAdd2<BR>{<BR>public:<BR>&nbsp; typedef typename NumericTraits&lt; TInput1 &gt;::AccumulateType AccumulatorType;<BR>&nbsp; WeightedAdd2() {};<BR>&nbsp; ~WeightedAdd2() {};<BR>&nbsp; inline TOutput operator()( const TInput1 &amp; A, const TInput2 &amp; B, float &amp; gamma)<BR>&nbsp; {<BR>/***********WHAT to be done here???1!!!!**************************/</DIV>
<DIV class=RTE>&nbsp;&nbsp;&nbsp; const AccumulatorType sum = A;<BR>&nbsp;&nbsp;&nbsp; return static_cast&lt;TOutput&gt;( gamma*sum +(1-gamma)* B ); // How to achieve this ???<BR>&nbsp; }<BR>}; </DIV>
<DIV class=RTE>}<BR>template &lt;class TInputImage1, class TInputImage2, class TOutputImage, float&gt;<BR>class ITK_EXPORT WeightedAddImageFilter :<BR>&nbsp;&nbsp;&nbsp; public<BR>BinaryFunctorImageFilter&lt;TInputImage1,TInputImage2,TOutputImage, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Functor::WeightedAdd2&lt; <BR>&nbsp; typename TInputImage1::PixelType, <BR>&nbsp; typename TInputImage2::PixelType,<BR>&nbsp; typename TOutputImage::PixelType, <BR>&nbsp; float&gt;&nbsp;&nbsp; &gt;</DIV>
<DIV class=RTE><BR>{<BR>public:<BR>&nbsp; /** Standard class typedefs. */<BR>&nbsp; typedef WeightedAddImageFilter&nbsp; Self;<BR>&nbsp; typedef BinaryFunctorImageFilter&lt;TInputImage1,TInputImage2,TOutputImage, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Functor::WeightedAdd2&lt; <BR>&nbsp;&nbsp;&nbsp; typename TInputImage1::PixelType, <BR>&nbsp;&nbsp;&nbsp; typename TInputImage2::PixelType,<BR>&nbsp;&nbsp;&nbsp; typename TOutputImage::PixelType, float&gt;&nbsp;&nbsp; <BR>&nbsp; &gt;&nbsp; Superclass;<BR>&nbsp; typedef SmartPointer&lt;Self&gt;&nbsp;&nbsp; Pointer;<BR>&nbsp; typedef SmartPointer&lt;const Self&gt;&nbsp; ConstPointer;</DIV>
<DIV class=RTE>&nbsp; /** Method for creation through the object factory. */<BR>&nbsp; itkNewMacro(Self);<BR>&nbsp; <BR>protected:<BR>&nbsp; WeightedAddImageFilter() {}<BR>&nbsp; virtual ~WeightedAddImageFilter() {}</DIV>
<DIV class=RTE>private:<BR>&nbsp; WeightedAddImageFilter(const Self&amp;); //purposely not implemented<BR>&nbsp; void operator=(const Self&amp;); //purposely not implemented</DIV>
<DIV class=RTE>};</DIV>
<DIV class=RTE>} // end namespace itk</DIV>
<DIV class=RTE><BR>#endif<BR></DIV></div><br clear=all><hr>Deals can't get any better. Products at Lowest Prices.  <a href="http://g.msn.com/8HMBENIN/2749??PS=">Only on baazee.com</a> </html>