[Insight-users] multiple questions

Iván Macía imacia at vicomtech.es
Fri Nov 4 05:16:51 EST 2005


Hi Isabelle,

Answering to the first of your questions you can use
itk::StatisticsImageFilter to compute some statistics of the input image
like mean, variance, sigma, maximum, minimum and sum.

Hope that helps

Iván


-----Mensaje original-----
De: insight-users-bounces+imacia=vicomtech.es at itk.org
[mailto:insight-users-bounces+imacia=vicomtech.es at itk.org] En nombre de
Renaud Isabelle
Enviado el: jueves, 03 de noviembre de 2005 17:51
Para: insight-users at itk.org
Asunto: [Insight-users] multiple questions


Hi, 

1- Does it already exist filters to compute variance and mean of images? Or
do I have to write mine, maybe derived from UnaryFunctorImageFilter? 

2- Is it possible to write a composite filter built with multiple filters
such as FFT 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. 

protected:
   typedef  VnlFFTRealToComplexConjugateImageFilter<float,2> FFTFilterType;
   typedef FFTFilterType::OutputImageType ComplexImageType;
   typedef itk::MultiplyComplexImageFilter<ComplexImageType,
ComplexImageType,    ComplexImageType> MultiplyComplexImageFilter;
  typedef VnlFFTComplexConjugateToRealImageFilter< float,2 > IFFTFilterType;

private:
  typename FFTFilterType::Pointer m_FFTFilter1;
  typename FFTFilterType::Pointer m_FFTFilter2;
  typename MultiplyComplexImageFilter::Pointer m_MultiplyFilter;
  typename IFFTFilterType::Pointer m_IFFTFilter;

See, actually, I have to make a lot of filters call to compute the
correlation matrix between my 2 inputs image. 

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? 

 //mean computation
  ImageRegionConstIterator inputit1(image1, image1->GetRequestedRegion());
  ImageRegionConstIterator inputit2(image2, image2->GetRequestedRegion());
  inputit1.GoToBegin();
  inputit2.GoToBegin();
  unsigned int NumberOfPixels = 0;
  float mean1 = 0.0;
  float mean2 = 0.0;
  while( !inputit1.IsAtEnd() ) 
  {
    mean1 += ((float)inputit1.Get());
   mean2 += ((float)inputit2.Get());
   NumberOfPixels++;
    ++inputit1;
   ++inputit2;
  }
  mean1 /= (float)NumberOfPixels;
  mean2 /= (float)NumberOfPixels;

  //centered matrices
  it1.GoToBegin(); 
  it2.GoToBegin();
  while( !it1.IsAtEnd() )
    {
    it1.Set(it1.Get()-mean1);
   it2.Set(it2.Get()-mean2);
   ++it1;
   ++it2;
    }

  //variances computation
   inputit1.GoToBegin();
   inputit2.GoToBegin();
  
   float var1 = 0.0;
   float var2 = 0.0;
   float tmp1, tmp2;
 
   while( !inputit1.IsAtEnd() ) 
   {
     tmp1 = (float)inputit1.Get();
    tmp2 = (float)inputit2.Get();
    var1 += SQUARE(tmp1);
    var2 += SQUARE(tmp2);
    ++inputit1;
    ++inputit2;
   }

  float denom = sqrt( var1 * var2 );
  if( denom!= 0.0) 
  {  
  
  typedef itk::VnlFFTRealToComplexConjugateImageFilter<float,2>
FFTFilterType;
  FFTFilterType::Pointer fftFilter1 = FFTFilterType::New();
  fftFilter1->SetInput( image1);
  FFTFilterType::Pointer fftFilter2 = FFTFilterType::New();
  fftFilter2->SetInput( image2);

   //output type from the FFT filters
  typedef FFTFilterType::OutputImageType ComplexImageType;
  typedef itk::MultiplyComplexImageFilter<ComplexImageType,
ComplexImageType, ComplexImageType> MultiplyComplexImageFilter;
  MultiplyComplexImageFilter::Pointer multiplyFilter =
MultiplyComplexImageFilter::New();
  multiplyFilter->SetInput1( fftFilter1->GetOutput() );
  multiplyFilter->SetInput2( fftFilter2->GetOutput() );
  
  typedef itk::VnlFFTComplexConjugateToRealImageFilter< float,2 >
IFFTFilterType;
  IFFTFilterType::Pointer ifftFilter = IFFTFilterType::New();
  ifftFilter->SetInput(multiplyFilter->GetOutput()); // try to recover the
input image
  ifftFilter->Update();
   
  ImageRegionIterator out(ifftFilter->GetOutput(),
ifftFilter->GetOutput()->GetRequestedRegion());
  out.GoToBegin();
  while( !out.IsAtEnd() )
    {
   out.Set(out.Get()/denom); 
    ++out;
    }
  }

Thank you for answering,

Isabelle


Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez le ici ! 

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.12.7/159 - Release Date: 02/11/2005

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.12.8/161 - Release Date: 03/11/2005
 



More information about the Insight-users mailing list