/usr/include/InsightToolkit/Review/itkGaborImageSource.txx is in libinsighttoolkit3-dev 3.20.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkGaborImageSource.txx
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkGaborImageSource_txx
#define __itkGaborImageSource_txx
#include "itkGaborKernelFunction.h"
#include "itkGaborImageSource.h"
#include "itkImageRegionIteratorWithIndex.h"
#include "itkProgressReporter.h"
#include "itkObjectFactory.h"
namespace itk
{
template <class TOutputImage>
GaborImageSource<TOutputImage>
::GaborImageSource()
{
//Initial image is 64 wide in each direction.
for (unsigned int i = 0; i < ImageDimension; i++)
{
this->m_Size[i] = 64;
this->m_Spacing[i] = 1.0;
this->m_Origin[i] = 0.0;
}
this->m_Direction.SetIdentity();
// Gabor parameters, defined so that the gaussian
// is centered in the default image
this->m_Mean.Fill( 32.0 );
this->m_Sigma.Fill( 16.0 );
this->m_CalculateImaginaryPart = false;
this->m_Frequency = 0.4;
this->m_PhaseOffset = 0.0;
}
template <class TOutputImage>
GaborImageSource<TOutputImage>
::~GaborImageSource()
{
}
//----------------------------------------------------------------------------
template <class TOutputImage>
void
GaborImageSource<TOutputImage>
::GenerateOutputInformation()
{
OutputImageType *output;
typename OutputImageType::IndexType index = {{0}};
output = this->GetOutput( 0 );
typename OutputImageType::RegionType largestPossibleRegion;
largestPossibleRegion.SetSize( this->m_Size );
largestPossibleRegion.SetIndex( index );
output->SetLargestPossibleRegion( largestPossibleRegion );
output->SetSpacing( this->m_Spacing );
output->SetOrigin( this->m_Origin );
output->SetDirection( this->m_Direction );
}
template <class TOutputImage>
void
GaborImageSource<TOutputImage>
::GenerateData()
{
typename OutputImageType::Pointer outputPtr = this->GetOutput();
// allocate the output buffer
outputPtr->SetBufferedRegion( outputPtr->GetRequestedRegion() );
outputPtr->Allocate();
// Create and initialize a new gaussian function
typedef GaborKernelFunction KernelFunctionType;
typename KernelFunctionType::Pointer gabor = KernelFunctionType::New();
gabor->SetSigma( this->m_Sigma[0] );
gabor->SetFrequency( this->m_Frequency );
gabor->SetPhaseOffset( this->m_PhaseOffset );
gabor->SetCalculateImaginaryPart( this->m_CalculateImaginaryPart );
// Create an iterator that will walk the output region
ImageRegionIteratorWithIndex<OutputImageType>
outIt( outputPtr, outputPtr->GetRequestedRegion() );
// The position at which the function is evaluated
Point<double, ImageDimension> evalPoint;
ProgressReporter progress( this, 0,
outputPtr->GetRequestedRegion().GetNumberOfPixels() );
// Walk the output image, evaluating the spatial function at each pixel
for ( outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt )
{
typename OutputImageType::IndexType index = outIt.GetIndex();
outputPtr->TransformIndexToPhysicalPoint( index, evalPoint );
double sum = 0.0;
for ( unsigned int i = 1; i < ImageDimension; i++ )
{
sum += vnl_math_sqr( ( evalPoint[i] - this->m_Mean[i] ) / this->m_Sigma[i] );
}
double value = vcl_exp( -0.5 * sum ) * gabor->Evaluate( evalPoint[0] - this->m_Mean[0] );
// Set the pixel value to the function value
outIt.Set( static_cast<PixelType>( value ) );
progress.CompletedPixel();
}
}
template <class TOutputImage>
void
GaborImageSource<TOutputImage>
::PrintSelf( std::ostream& os, Indent indent ) const
{
Superclass::PrintSelf( os,indent );
os << indent << "Image parameters: " << std::endl;
os << indent << " Size: " << this->GetSize() << std::endl;
os << indent << " Origin: " << this->GetOrigin() << std::endl;
os << indent << " Spacing: " << this->GetSpacing() << std::endl;
os << indent << " Direction: " << this->GetDirection() << std::endl;
os << indent << "Gabor filter parameters: " << std::endl;
os << indent << " Sigma: " << this->GetSigma() << std::endl;
os << indent << " Mean: " << this->GetMean() << std::endl;
os << indent << " Frequency: " << this->GetFrequency() << std::endl;
if ( this->GetCalculateImaginaryPart() )
{
os << indent << " Calculate complex part: true " << std::endl;
}
else
{
os << indent << " Calculate complex part: false " << std::endl;
}
}
} // end namespace itk
#endif
|