<DIV>Hi, </DIV>
<DIV>&nbsp;</DIV>
<DIV>1- Does it already exist filters to compute <STRONG>variance</STRONG> and <STRONG>mean</STRONG> of images? Or do I have to write mine,&nbsp;maybe derived from UnaryFunctorImageFilter? </DIV>
<DIV>&nbsp;</DIV>
<DIV>2- Is it possible to write a composite filter built with multiple filters such as&nbsp;<STRONG>FFT</STRONG> filter?I tried to, but it seems that declaration of this kind of filter in my header file causes an error because of the type of the component filters.&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG><EM>protected:</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp;&nbsp; typedef&nbsp; VnlFFTRealToComplexConjugateImageFilter&lt;float,2&gt; FFTFilterType;</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp;&nbsp; typedef FFTFilterType::OutputImageType ComplexImageType;<BR>&nbsp;&nbsp; typedef itk::MultiplyComplexImageFilter&lt;ComplexImageType, ComplexImageType,&nbsp;&nbsp;&nbsp; ComplexImageType&gt; MultiplyComplexImageFilter;</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; typedef VnlFFTComplexConjugateToRealImageFilter&lt; float,2 &gt; IFFTFilterType;</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG>&nbsp;</DIV>
<DIV><STRONG><EM>private:</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; typename FFTFilterType::Pointer m_FFTFilter1;</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp;&nbsp;typename FFTFilterType::Pointer m_FFTFilter2;</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; typename MultiplyComplexImageFilter::Pointer m_MultiplyFilter;</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; typename IFFTFilterType::Pointer m_IFFTFilter;</EM></STRONG></DIV>
<DIV>&nbsp;</DIV>
<DIV>See, actually, I have to make a lot of filters call to compute the correlation matrix between my 2 inputs image. </DIV>
<DIV>&nbsp;</DIV>
<DIV>Here is all my procedure and actually it works fine. Now, I would like to incorporate all of this in one composite filter to make my implementation more automatic and easy to read. Do you t hink that it is possible? </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;<STRONG><EM>//mean computation</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; ImageRegionConstIterator inputit1(image1, image1-&gt;GetRequestedRegion());<BR>&nbsp; ImageRegionConstIterator inputit2(image2, image2-&gt;GetRequestedRegion());</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; inputit1.GoToBegin();<BR>&nbsp; inputit2.GoToBegin();</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; unsigned int NumberOfPixels = 0;<BR>&nbsp; float mean1 = 0.0;<BR>&nbsp; float mean2 = 0.0;<BR>&nbsp; while( !inputit1.IsAtEnd() ) <BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; mean1 += ((float)inputit1.Get());<BR>&nbsp;&nbsp; mean2 += ((float)inputit2.Get());<BR>&nbsp;&nbsp; NumberOfPixels++;<BR>&nbsp;&nbsp;&nbsp; ++inputit1;<BR>&nbsp; &nbsp;++inputit2;<BR>&nbsp; }</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; mean1 /= (float)NumberOfPixels;<BR>&nbsp; mean2 /= (float)NumberOfPixels;</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG>&nbsp;</DIV>
<DIV><STRONG><EM>&nbsp; //centered matrices</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; it1.GoToBegin(); <BR>&nbsp; it2.GoToBegin();<BR>&nbsp; while( !it1.IsAtEnd() )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; it1.Set(it1.Get()-mean1);<BR>&nbsp;&nbsp; it2.Set(it2.Get()-mean2);<BR>&nbsp; &nbsp;++it1;<BR>&nbsp; &nbsp;++it2;<BR>&nbsp;&nbsp;&nbsp; }</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG>&nbsp;</DIV>
<DIV><STRONG><EM>&nbsp; //variances computation<BR>&nbsp;&nbsp; inputit1.GoToBegin();<BR>&nbsp;&nbsp; inputit2.GoToBegin();<BR>&nbsp; <BR>&nbsp;&nbsp; float var1 = 0.0;<BR>&nbsp;&nbsp; float var2 = 0.0;<BR>&nbsp;&nbsp; float tmp1, tmp2;<BR>&nbsp;<BR>&nbsp;&nbsp; while( !inputit1.IsAtEnd() ) <BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp; tmp1 = (float)inputit1.Get();<BR>&nbsp;&nbsp; &nbsp;tmp2 = (float)inputit2.Get();<BR>&nbsp;&nbsp; &nbsp;var1 += SQUARE(tmp1);<BR>&nbsp;&nbsp; &nbsp;var2 += SQUARE(tmp2);<BR>&nbsp;&nbsp;&nbsp; ++inputit1;<BR>&nbsp;&nbsp;&nbsp; ++inputit2;<BR>&nbsp;&nbsp; }</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG>&nbsp;</DIV>
<DIV><STRONG><EM>&nbsp; float denom = sqrt( var1 * var2 );</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; if( denom!= 0.0)&nbsp;</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; {&nbsp; </EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp;&nbsp;</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; typedef itk::VnlFFTRealToComplexConjugateImageFilter&lt;float,2&gt; FFTFilterType;<BR>&nbsp; FFTFilterType::Pointer fftFilter1 = FFTFilterType::New();<BR>&nbsp; fftFilter1-&gt;SetInput( image1);</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; FFTFilterType::Pointer fftFilter2 = FFTFilterType::New();<BR>&nbsp; fftFilter2-&gt;SetInput( image2);</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG>&nbsp;</DIV>
<DIV><STRONG><EM>&nbsp;&nbsp; //output type from the FFT filters<BR>&nbsp; typedef FFTFilterType::OutputImageType ComplexImageType;<BR>&nbsp; typedef itk::MultiplyComplexImageFilter&lt;ComplexImageType, ComplexImageType, ComplexImageType&gt; MultiplyComplexImageFilter;<BR>&nbsp; MultiplyComplexImageFilter::Pointer multiplyFilter = MultiplyComplexImageFilter::New();<BR>&nbsp; multiplyFilter-&gt;SetInput1( fftFilter1-&gt;GetOutput() );<BR>&nbsp; multiplyFilter-&gt;SetInput2( fftFilter2-&gt;GetOutput() );<BR>&nbsp; <BR>&nbsp; typedef itk::VnlFFTComplexConjugateToRealImageFilter&lt; float,2 &gt; IFFTFilterType;<BR>&nbsp; IFFTFilterType::Pointer ifftFilter = IFFTFilterType::New();<BR>&nbsp; ifftFilter-&gt;SetInput(multiplyFilter-&gt;GetOutput()); // try to recover the input image<BR>&nbsp; ifftFilter-&gt;Update();</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp;&nbsp; </EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; ImageRegionIterator out(ifftFilter-&gt;GetOutput(), ifftFilter-&gt;GetOutput()-&gt;GetRequestedRegion());<BR>&nbsp;&nbsp;out.GoToBegin();<BR>&nbsp; while( !out.IsAtEnd() )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp; out.Set(out.Get()/denom); </EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp;&nbsp;&nbsp; ++out;<BR>&nbsp;&nbsp;&nbsp; }</EM></STRONG></DIV>
<DIV><STRONG><EM>&nbsp; }</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG>&nbsp;</DIV>
<DIV>Thank you for answering,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Isabelle</DIV><p>
                <hr size=1> 
<b><font color=#FF0000>Appel audio GRATUIT</font> partout dans le monde</b> avec le nouveau Yahoo! Messenger<br> 
<a href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.messenger.yahoo.com">Téléchargez le ici !</a>