Skip to content
Snippets Groups Projects
Commit 8e25c83f authored by Julien Michel's avatar Julien Michel
Browse files

correction genericInterpolateImageFunction

parent ef447b31
Branches
Tags
No related merge requests found
......@@ -98,17 +98,20 @@ public itk::InterpolateImageFunction<TInputImage,TCoordRep>
}
/** Delete tables.*/
void ResetOffsetTable();
void ResetOffsetTable() const;
/** Initialize used tables*/
void InitializeTables();
void InitializeTables() const;
/** Fill the weight offset table*/
void FillWeightOffsetTable();
void FillWeightOffsetTable() const;
protected:
GenericInterpolateImageFunction();
~GenericInterpolateImageFunction();
void PrintSelf(std::ostream& os, itk::Indent indent) const;
/** Call the superclass implementation and set the TablesHaveBeenGenerated
* flag to false */
virtual void Modified(void);
private:
GenericInterpolateImageFunction(const Self&); //purposely not implemented
......@@ -118,17 +121,23 @@ public itk::InterpolateImageFunction<TInputImage,TCoordRep>
// Constant to store twice the radius
unsigned int m_WindowSize;
/** The offset array, used to keep a list of relevant
* offsets in the neihborhoodIterator */
unsigned int *m_OffsetTable;
/** Used function */
FunctionType m_Function;
/** Size of the offset table */
unsigned int m_OffsetTableSize;
/** Store the image dimension.*/
unsigned int m_ImageDimension;
/** These members are declared mutable so that they can be
regenerated seamlessly inside the EvaluateAtContinuousIndex method if
they need to */
/** Size of the offset table */
mutable unsigned int m_OffsetTableSize;
/** The offset array, used to keep a list of relevant
* offsets in the neihborhoodIterator */
mutable unsigned int *m_OffsetTable;
/** Index into the weights array for each offset */
unsigned int **m_WeightOffsetTable;
mutable unsigned int **m_WeightOffsetTable;
/** True if internal statistics have been generated */
mutable bool m_TablesHaveBeenGenerated;
};
} // end namespace itk
......
......@@ -28,6 +28,9 @@ GenericInterpolateImageFunction<TInputImage, TFunction, TBoundaryCondition, TCoo
{
//m_Radius = 1;
m_WindowSize = 1;
m_OffsetTable = NULL;
m_WeightOffsetTable = NULL;
m_TablesHaveBeenGenerated=false;
}
/** Destructor */
......@@ -42,17 +45,25 @@ GenericInterpolateImageFunction<TInputImage, TFunction,TBoundaryCondition, TCoor
template<class TInputImage, class TFunction, class TBoundaryCondition, class TCoordRep>
void
GenericInterpolateImageFunction<TInputImage, TFunction, TBoundaryCondition, TCoordRep>
::ResetOffsetTable()
::ResetOffsetTable() const
{
// Clear the offset table
delete [] m_OffsetTable;
if(m_OffsetTable!=NULL)
{
delete [] m_OffsetTable;
m_OffsetTable=NULL;
}
// Clear the weights tables
for(unsigned int i=0; i < m_OffsetTableSize; i++)
// Clear the weights tales
if(m_WeightOffsetTable!=NULL)
{
delete [] m_WeightOffsetTable[i];
for(unsigned int i=0; i < m_OffsetTableSize; i++)
{
delete [] m_WeightOffsetTable[i];
}
delete[] m_WeightOffsetTable;
m_WeightOffsetTable = NULL;
}
delete[] m_WeightOffsetTable;
}
......@@ -78,20 +89,24 @@ GenericInterpolateImageFunction<TInputImage, TFunction, TBoundaryCondition, TCoo
//m_Radius = rad;
this->GetFunction().SetRadius(rad);
m_WindowSize = rad << 1;
// Delete existing tables
this->ResetOffsetTable();
// Tables initialization
this->InitializeTables();
// fill the weigth table
this->FillWeightOffsetTable();
this->Modified();
}
template<class TInputImage, class TFunction, class TBoundaryCondition, class TCoordRep>
void
GenericInterpolateImageFunction<TInputImage, TFunction, TBoundaryCondition, TCoordRep>
::Modified()
{
Superclass::Modified();
m_TablesHaveBeenGenerated=false;
}
/** Initialize used tables*/
template<class TInputImage, class TFunction, class TBoundaryCondition, class TCoordRep>
void
GenericInterpolateImageFunction<TInputImage, TFunction, TBoundaryCondition, TCoordRep>
::InitializeTables()
::InitializeTables() const
{
// Compute the offset table size
m_OffsetTableSize = 1;
......@@ -115,7 +130,7 @@ GenericInterpolateImageFunction<TInputImage, TFunction, TBoundaryCondition, TCoo
template<class TInputImage, class TFunction, class TBoundaryCondition, class TCoordRep>
void
GenericInterpolateImageFunction<TInputImage, TFunction, TBoundaryCondition, TCoordRep>
::FillWeightOffsetTable()
::FillWeightOffsetTable() const
{
// Initialize the neighborhood
SizeType radius;
......@@ -171,6 +186,17 @@ typename GenericInterpolateImageFunction<TInputImage, TFunction, TBoundaryCondit
GenericInterpolateImageFunction<TInputImage, TFunction, TBoundaryCondition, TCoordRep>
::EvaluateAtContinuousIndex(const ContinuousIndexType& index) const
{
if(!m_TablesHaveBeenGenerated)
{
// Delete existing tables
this->ResetOffsetTable();
// Tables initialization
this->InitializeTables();
// fill the weigth table
this->FillWeightOffsetTable();
m_TablesHaveBeenGenerated=true;
}
unsigned int dim;
IndexType baseIndex;
double distance[ImageDimension];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment