Skip to content

Commit

Permalink
WIP: Intial incomplete manual work
Browse files Browse the repository at this point in the history
  • Loading branch information
hjmjohnson committed Dec 19, 2024
1 parent 344940a commit 896738c
Show file tree
Hide file tree
Showing 63 changed files with 563 additions and 665 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ itkVtkConnectedComponentImageFilterTest(int argc, char * argv[])
filterContainer["Triangle"] = TriangleFilterType::New();
filterContainer["Yen"] = YenFilterType::New();

auto it = filterContainer.begin();
for (it = filterContainer.begin(); it != filterContainer.end(); ++it)
for (auto it = filterContainer.begin(); it != filterContainer.end(); ++it)
{
it->second->SetInsideValue(255);
it->second->SetOutsideValue(0);
Expand Down
10 changes: 3 additions & 7 deletions Modules/Core/Common/include/itkColorTable.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ template <typename TComponent>
void
ColorTable<TComponent>::UseGrayColors(unsigned int n)
{
unsigned int i;

this->DeleteColors();

m_NumberOfColors = n;
Expand Down Expand Up @@ -138,7 +136,7 @@ ColorTable<TComponent>::UseGrayColors(unsigned int n)
// Converting from TComponent to RealType may introduce a rounding error, so do static_cast
constexpr auto max_value_converted =
static_cast<typename NumericTraits<TComponent>::RealType>(NumericTraits<TComponent>::max());
for (i = 0; i < m_NumberOfColors; ++i)
for (unsigned int i = 0; i < m_NumberOfColors; ++i)
{
const typename NumericTraits<TComponent>::RealType realGray(minimum + i * delta);

Expand All @@ -159,8 +157,6 @@ template <typename TComponent>
void
ColorTable<TComponent>::UseHeatColors(unsigned int n)
{
unsigned int i;

this->DeleteColors();

m_NumberOfColors = n;
Expand All @@ -183,7 +179,7 @@ ColorTable<TComponent>::UseHeatColors(unsigned int n)
// Converting from TComponent to RealType may introduce a rounding error, so do static_cast
constexpr auto max_value_converted =
static_cast<typename NumericTraits<TComponent>::RealType>(NumericTraits<TComponent>::max());
for (i = 0; i < n / 2.0; ++i)
for (unsigned int i = 0; i < n / 2.0; ++i)
{
//
// avoid overflow
Expand All @@ -201,7 +197,7 @@ ColorTable<TComponent>::UseHeatColors(unsigned int n)
m_ColorName[i] = name.str();
}

for (i = 0; i < n / 2; ++i)
for (unsigned int i = 0; i < n / 2; ++i)
{
const typename NumericTraits<TComponent>::RealType rdouble(1.0 * scale + shift);
TComponent r(NumericTraits<TComponent>::max());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,15 @@ ConicShellInteriorExteriorSpatialFunction<VDimension, TInput>::PrintSelf(std::os
{
Superclass::PrintSelf(os, indent);

unsigned int i;
os << indent << "Origin: [";
for (i = 0; i < VDimension - 1; ++i)
for (unsigned int i = 0; i < VDimension - 1; ++i)
{
os << m_Origin[i] << ", ";
}
os << ']' << std::endl;

os << indent << "Gradient at origin: [";
for (i = 0; i < VDimension - 1; ++i)
for (unsigned int i = 0; i < VDimension - 1; ++i)
{
os << m_OriginGradient[i] << ", ";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,51 +348,49 @@ ConstNeighborhoodIteratorWithOnlyIndex<TImage>::PrintSelf(std::ostream & os, Ind
{
Superclass::PrintSelf(os, indent);

DimensionValueType i;

os << indent;
os << "ConstNeighborhoodIteratorWithOnlyIndex {this= " << this;
os << ", m_Region = { Start = {";
for (i = 0; i < Dimension; ++i)
for (DimensionValueType i = 0; i < Dimension; ++i)
{
os << m_Region.GetIndex()[i] << ' ';
}
os << "}, Size = { ";
for (i = 0; i < Dimension; ++i)
for (DimensionValueType i = 0; i < Dimension; ++i)
{
os << m_Region.GetSize()[i] << ' ';
}
os << "} }";
os << ", m_BeginIndex = { ";
for (i = 0; i < Dimension; ++i)
for (DimensionValueType i = 0; i < Dimension; ++i)
{
os << m_BeginIndex[i] << ' ';
}
os << "} , m_EndIndex = { ";
for (i = 0; i < Dimension; ++i)
for (DimensionValueType i = 0; i < Dimension; ++i)
{
os << m_EndIndex[i] << ' ';
}
os << "} , m_Loop = { ";
for (i = 0; i < Dimension; ++i)
for (DimensionValueType i = 0; i < Dimension; ++i)
{
os << m_Loop[i] << ' ';
}
os << "}, m_Bound = { ";
for (i = 0; i < Dimension; ++i)
for (DimensionValueType i = 0; i < Dimension; ++i)
{
os << m_Bound[i] << ' ';
}
os << "}, m_IsInBounds = {" << m_IsInBounds;
os << "}, m_IsInBoundsValid = {" << m_IsInBoundsValid;

os << indent << ", m_InnerBoundsLow = { ";
for (i = 0; i < Dimension; ++i)
for (DimensionValueType i = 0; i < Dimension; ++i)
{
os << m_InnerBoundsLow[i] << ' ';
}
os << "}, m_InnerBoundsHigh = { ";
for (i = 0; i < Dimension; ++i)
for (DimensionValueType i = 0; i < Dimension; ++i)
{
os << m_InnerBoundsHigh[i] << ' ';
}
Expand Down
33 changes: 12 additions & 21 deletions Modules/Core/Common/include/itkConstShapedNeighborhoodIterator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::CreateActiveListFro
<< ") does not equal radius of neighborhood("
<< neighborhood.GetRadius() << ')');
}
typename Neighborhood<TNeighborPixel, Self::Dimension>::ConstIterator nit;
NeighborIndexType idx = 0;
for (nit = neighborhood.Begin(); nit != neighborhood.End(); ++nit, ++idx)

NeighborIndexType idx = 0;
for (auto nit = neighborhood.Begin(); nit != neighborhood.End(); ++nit, ++idx)
{
if (*nit)
{
Expand Down Expand Up @@ -157,16 +157,14 @@ ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::operator++()
}
else
{
IndexListConstIterator it;

// Center pointer must be updated whether or not it is active.
if (!m_CenterIsActive)
{
this->GetElement(this->GetCenterNeighborhoodIndex())++;
}

// Increment pointers for only the active pixels.
for (it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
for (auto it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
{
(this->GetElement(*it))++;
}
Expand All @@ -182,7 +180,7 @@ ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::operator++()
{
this->GetElement(this->GetCenterNeighborhoodIndex()) += this->m_WrapOffset[ii];
}
for (it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
for (auto it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
{
(this->GetElement(*it)) += this->m_WrapOffset[ii];
}
Expand All @@ -200,9 +198,6 @@ template <typename TImage, typename TBoundaryCondition>
ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition> &
ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::operator--()
{
unsigned int i;
IndexListConstIterator it;

// Repositioning neighborhood, previous bounds check on neighborhood
// location is invalid.
this->m_IsInBoundsValid = false;
Expand All @@ -224,13 +219,13 @@ ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::operator--()
}

// Decrement pointers for only the active pixels.
for (it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
for (auto it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
{
(this->GetElement(*it))--;
}

// Check loop bounds, wrap & add pointer offsets if needed.
for (i = 0; i < Dimension; ++i)
for (unsigned int i = 0; i < Dimension; ++i)
{
if (this->m_Loop[i] == this->m_BeginIndex[i])
{
Expand All @@ -239,7 +234,7 @@ ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::operator--()
{
this->GetElement(this->GetCenterNeighborhoodIndex()) -= this->m_WrapOffset[i];
}
for (it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
for (auto it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
{
(this->GetElement(*it)) -= this->m_WrapOffset[i];
}
Expand All @@ -258,8 +253,6 @@ template <typename TImage, typename TBoundaryCondition>
ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition> &
ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::operator+=(const OffsetType & idx)
{
unsigned int i;
IndexListConstIterator it;
OffsetValueType accumulator = 0;
const OffsetValueType * stride = this->GetImagePointer()->GetOffsetTable();

Expand All @@ -285,7 +278,7 @@ ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::operator+=(const Of
// Because the image offset table is based on its buffer size and
// not its requested region size, we don't have to worry about
// adding in the wrapping offsets.
for (i = 1; i < Dimension; ++i)
for (unsigned int i = 1; i < Dimension; ++i)
{
accumulator += idx[i] * stride[i];
}
Expand All @@ -297,7 +290,7 @@ ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::operator+=(const Of
}

// Increment pointers only for those active pixels
for (it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
for (auto it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
{
(this->GetElement(*it)) += accumulator;
}
Expand All @@ -312,8 +305,6 @@ template <typename TImage, typename TBoundaryCondition>
ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition> &
ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::operator-=(const OffsetType & idx)
{
unsigned int i;
IndexListConstIterator it;
OffsetValueType accumulator = 0;
const OffsetValueType * stride = this->GetImagePointer()->GetOffsetTable();

Expand All @@ -339,7 +330,7 @@ ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::operator-=(const Of
// Because the image offset table is based on its buffer size and
// not its requested region size, we don't have to worry about
// adding in the wrapping offsets.
for (i = 1; i < Dimension; ++i)
for (unsigned int i = 1; i < Dimension; ++i)
{
accumulator += idx[i] * stride[i];
}
Expand All @@ -351,7 +342,7 @@ ConstShapedNeighborhoodIterator<TImage, TBoundaryCondition>::operator-=(const Of
}

// Increment pointers only for those active pixels
for (it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
for (auto it = m_ActiveIndexList.begin(); it != m_ActiveIndexList.end(); ++it)
{
(this->GetElement(*it)) -= accumulator;
}
Expand Down
26 changes: 12 additions & 14 deletions Modules/Core/Common/include/itkDerivativeOperator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,35 @@ template <typename TPixel, unsigned int VDimension, typename TAllocator>
auto
DerivativeOperator<TPixel, VDimension, TAllocator>::GenerateCoefficients() -> CoefficientVector
{
unsigned int i;
unsigned int j;
PixelRealType previous;
PixelRealType next;
const unsigned int w = 2 * ((m_Order + 1) / 2) + 1;
CoefficientVector coeff(w);

coeff[w / 2] = 1.0;
for (i = 0; i < m_Order / 2; ++i)
for (unsigned int i = 0; i < m_Order / 2; ++i)
{
previous = coeff[1] - 2 * coeff[0];
for (j = 1; j < w - 1; ++j)
PixelRealType previous = coeff[1] - 2 * coeff[0];
unsigned int j = 1;
for (; j < w - 1; ++j)
{
next = coeff[j - 1] + coeff[j + 1] - 2 * coeff[j];
PixelRealType next = coeff[j - 1] + coeff[j + 1] - 2 * coeff[j];
coeff[j - 1] = previous;
previous = next;
}
next = coeff[j - 1] - 2 * coeff[j];
PixelRealType next = coeff[j - 1] - 2 * coeff[j];
coeff[j - 1] = previous;
coeff[j] = next;
}
for (i = 0; i < m_Order % 2; ++i)
for (unsigned int i = 0; i < m_Order % 2; ++i)
{
previous = 0.5 * coeff[1];
for (j = 1; j < w - 1; ++j)
PixelRealType previous = 0.5 * coeff[1];
unsigned int j = 1;
for (; j < w - 1; ++j)
{
next = -0.5 * coeff[j - 1] + 0.5 * coeff[j + 1];
PixelRealType next = -0.5 * coeff[j - 1] + 0.5 * coeff[j + 1];
coeff[j - 1] = previous;
previous = next;
}
next = -0.5 * coeff[j - 1];
PixelRealType next = -0.5 * coeff[j - 1];
coeff[j - 1] = previous;
coeff[j] = next;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,19 @@ template <unsigned int VDimension, typename TInput>
void
FiniteCylinderSpatialFunction<VDimension, TInput>::PrintSelf(std::ostream & os, Indent indent) const
{
unsigned int i;

Superclass::PrintSelf(os, indent);

os << indent << "Lengths of Axis: " << m_AxisLength << std::endl;
os << indent << "Radius: " << m_Radius << std::endl;
os << indent << "Origin of Cylinder: " << m_Center << std::endl;
os << indent << "Orientation: " << std::endl;
for (i = 0; i < VDimension; ++i)
for (unsigned int i = 0; i < VDimension; ++i)
{
os << indent << indent << m_Orientation[i] << ' ';
}
os << std::endl;
os << indent << "Normalized Orientation: " << std::endl;
for (i = 0; i < VDimension; ++i)
for (unsigned int i = 0; i < VDimension; ++i)
{
os << indent << indent << m_NormalizedOrientation[i] << ' ';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,20 @@ FloodFilledSpatialFunctionConditionalConstIterator<TImage, TFunction>::IsPixelIn
// means of determining index inclusion.

// To reiterate... DO NOT use this on images higher than 16D
unsigned int counter;
unsigned int counterCopy;
const unsigned int dim = TImage::ImageDimension;
auto numReps = static_cast<unsigned int>(std::pow(2.0, static_cast<double>(dim)));

IndexType tempIndex;
constexpr unsigned int dim = TImage::ImageDimension;
auto numReps = static_cast<unsigned int>(std::pow(2.0, static_cast<double>(dim)));


// First we loop over the binary counter
for (counter = 0; counter < numReps; ++counter)
for (unsigned int counter = 0; counter < numReps; ++counter)
{
// Next we use the binary values in the counter to form
// an index to look at
IndexType tempIndex;
for (unsigned int i = 0; i < dim; ++i)
{
counterCopy = counter;
unsigned int counterCopy = counter;
tempIndex[i] = index[i] + static_cast<int>((counterCopy >> i) & 0x0001);
}

Expand Down Expand Up @@ -154,20 +153,18 @@ FloodFilledSpatialFunctionConditionalConstIterator<TImage, TFunction>::IsPixelIn
// generated indices are true

// To reiterate... DO NOT use this on images higher than 16D
unsigned int counter;
unsigned int counterCopy;

const unsigned int dim = TImage::ImageDimension;
auto numReps = static_cast<unsigned int>(std::pow(2.0, static_cast<double>(dim)));
IndexType tempIndex;

// First we loop over the binary counter
for (counter = 0; counter < numReps; ++counter)
for (unsigned int counter = 0; counter < numReps; ++counter)
{
// Next we use the binary values in the counter to form
// an index to look at
IndexType tempIndex;
for (unsigned int i = 0; i < dim; ++i)
{
counterCopy = counter;
unsigned int counterCopy = counter;
tempIndex[i] = index[i] + static_cast<int>((counterCopy >> i) & 0x0001);
}

Expand Down
Loading

0 comments on commit 896738c

Please # to comment.