<DIV>Hi, </DIV>
<DIV> </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, maybe derived from UnaryFunctorImageFilter? </DIV>
<DIV> </DIV>
<DIV>2- Is it possible to write a composite filter built with multiple filters such as <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. </DIV>
<DIV> </DIV>
<DIV><STRONG><EM>protected:</EM></STRONG></DIV>
<DIV><STRONG><EM> typedef VnlFFTRealToComplexConjugateImageFilter<float,2> FFTFilterType;</EM></STRONG></DIV>
<DIV><STRONG><EM> typedef FFTFilterType::OutputImageType ComplexImageType;<BR> typedef itk::MultiplyComplexImageFilter<ComplexImageType, ComplexImageType, ComplexImageType> MultiplyComplexImageFilter;</EM></STRONG></DIV>
<DIV><STRONG><EM> typedef VnlFFTComplexConjugateToRealImageFilter< float,2 > IFFTFilterType;</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG> </DIV>
<DIV><STRONG><EM>private:</EM></STRONG></DIV>
<DIV><STRONG><EM> typename FFTFilterType::Pointer m_FFTFilter1;</EM></STRONG></DIV>
<DIV><STRONG><EM> typename FFTFilterType::Pointer m_FFTFilter2;</EM></STRONG></DIV>
<DIV><STRONG><EM> typename MultiplyComplexImageFilter::Pointer m_MultiplyFilter;</EM></STRONG></DIV>
<DIV><STRONG><EM> typename IFFTFilterType::Pointer m_IFFTFilter;</EM></STRONG></DIV>
<DIV> </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> </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> </DIV>
<DIV> <STRONG><EM>//mean computation</EM></STRONG></DIV>
<DIV><STRONG><EM> ImageRegionConstIterator inputit1(image1, image1->GetRequestedRegion());<BR> ImageRegionConstIterator inputit2(image2, image2->GetRequestedRegion());</EM></STRONG></DIV>
<DIV><STRONG><EM> inputit1.GoToBegin();<BR> inputit2.GoToBegin();</EM></STRONG></DIV>
<DIV><STRONG><EM> unsigned int NumberOfPixels = 0;<BR> float mean1 = 0.0;<BR> float mean2 = 0.0;<BR> while( !inputit1.IsAtEnd() ) <BR> {<BR> mean1 += ((float)inputit1.Get());<BR> mean2 += ((float)inputit2.Get());<BR> NumberOfPixels++;<BR> ++inputit1;<BR> ++inputit2;<BR> }</EM></STRONG></DIV>
<DIV><STRONG><EM> mean1 /= (float)NumberOfPixels;<BR> mean2 /= (float)NumberOfPixels;</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG> </DIV>
<DIV><STRONG><EM> //centered matrices</EM></STRONG></DIV>
<DIV><STRONG><EM> it1.GoToBegin(); <BR> it2.GoToBegin();<BR> while( !it1.IsAtEnd() )<BR> {<BR> it1.Set(it1.Get()-mean1);<BR> it2.Set(it2.Get()-mean2);<BR> ++it1;<BR> ++it2;<BR> }</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG> </DIV>
<DIV><STRONG><EM> //variances computation<BR> inputit1.GoToBegin();<BR> inputit2.GoToBegin();<BR> <BR> float var1 = 0.0;<BR> float var2 = 0.0;<BR> float tmp1, tmp2;<BR> <BR> while( !inputit1.IsAtEnd() ) <BR> {<BR> tmp1 = (float)inputit1.Get();<BR> tmp2 = (float)inputit2.Get();<BR> var1 += SQUARE(tmp1);<BR> var2 += SQUARE(tmp2);<BR> ++inputit1;<BR> ++inputit2;<BR> }</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG> </DIV>
<DIV><STRONG><EM> float denom = sqrt( var1 * var2 );</EM></STRONG></DIV>
<DIV><STRONG><EM> if( denom!= 0.0) </EM></STRONG></DIV>
<DIV><STRONG><EM> { </EM></STRONG></DIV>
<DIV><STRONG><EM> </EM></STRONG></DIV>
<DIV><STRONG><EM> typedef itk::VnlFFTRealToComplexConjugateImageFilter<float,2> FFTFilterType;<BR> FFTFilterType::Pointer fftFilter1 = FFTFilterType::New();<BR> fftFilter1->SetInput( image1);</EM></STRONG></DIV>
<DIV><STRONG><EM> FFTFilterType::Pointer fftFilter2 = FFTFilterType::New();<BR> fftFilter2->SetInput( image2);</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG> </DIV>
<DIV><STRONG><EM> //output type from the FFT filters<BR> typedef FFTFilterType::OutputImageType ComplexImageType;<BR> typedef itk::MultiplyComplexImageFilter<ComplexImageType, ComplexImageType, ComplexImageType> MultiplyComplexImageFilter;<BR> MultiplyComplexImageFilter::Pointer multiplyFilter = MultiplyComplexImageFilter::New();<BR> multiplyFilter->SetInput1( fftFilter1->GetOutput() );<BR> multiplyFilter->SetInput2( fftFilter2->GetOutput() );<BR> <BR> typedef itk::VnlFFTComplexConjugateToRealImageFilter< float,2 > IFFTFilterType;<BR> IFFTFilterType::Pointer ifftFilter = IFFTFilterType::New();<BR> ifftFilter->SetInput(multiplyFilter->GetOutput()); // try to recover the input image<BR> ifftFilter->Update();</EM></STRONG></DIV>
<DIV><STRONG><EM> </EM></STRONG></DIV>
<DIV><STRONG><EM> ImageRegionIterator out(ifftFilter->GetOutput(), ifftFilter->GetOutput()->GetRequestedRegion());<BR> out.GoToBegin();<BR> while( !out.IsAtEnd() )<BR> {<BR> out.Set(out.Get()/denom); </EM></STRONG></DIV>
<DIV><STRONG><EM> ++out;<BR> }</EM></STRONG></DIV>
<DIV><STRONG><EM> }</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG> </DIV>
<DIV>Thank you for answering,</DIV>
<DIV> </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>