Skip to content

Remove unnecessary private m_NumberOfPixelsCounted data members #1310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Common/Transforms/itkAdvancedImageMomentsCalculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ class ITK_TEMPLATE_EXPORT AdvancedImageMomentsCalculator : public Object

mutable std::vector<AlignedComputePerThreadStruct> m_ComputePerThreadVariables{};
bool m_UseMultiThread{};
SizeValueType m_NumberOfPixelsCounted{};

SizeValueType m_NumberOfSamplesForCenteredTransformInitialization{};
InputPixelType m_LowerThresholdForCenterGravity{};
Expand Down
1 change: 0 additions & 1 deletion Common/itkComputeDisplacementDistribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ class ITK_TEMPLATE_EXPORT ComputeDisplacementDistribution : public ScaledSingleV

mutable std::vector<AlignedComputePerThreadStruct> m_ComputePerThreadVariables{};

SizeValueType m_NumberOfPixelsCounted{};
bool m_UseMultiThread{ true };
std::vector<ImageSampleType> m_Samples{};
};
Expand Down
12 changes: 6 additions & 6 deletions Common/itkComputeDisplacementDistribution.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -410,24 +410,24 @@ ComputeDisplacementDistribution<TFixedImage, TTransform>::AfterThreadedCompute(d
{
/** Reset all variables. */
maxJJ = 0.0;
double displacement = 0.0;
double displacementSquared = 0.0;
m_NumberOfPixelsCounted = 0.0;
double displacement = 0.0;
double displacementSquared = 0.0;
SizeValueType numberOfPixelsCounted = 0;

/** Accumulate thread results. */
for (const auto & computePerThreadStruct : m_ComputePerThreadVariables)
{
maxJJ = std::max(maxJJ, computePerThreadStruct.st_MaxJJ);
displacement += computePerThreadStruct.st_Displacement;
displacementSquared += computePerThreadStruct.st_DisplacementSquared;
m_NumberOfPixelsCounted += computePerThreadStruct.st_NumberOfPixelsCounted;
numberOfPixelsCounted += computePerThreadStruct.st_NumberOfPixelsCounted;
}
// Reset all variables for the next resolution.
std::fill_n(m_ComputePerThreadVariables.begin(), m_ComputePerThreadVariables.size(), AlignedComputePerThreadStruct());

/** Compute the sigma of the distribution of the displacements. */
const double meanDisplacement = displacement / m_NumberOfPixelsCounted;
const double sigma = displacementSquared / m_NumberOfPixelsCounted - vnl_math::sqr(meanDisplacement);
const double meanDisplacement = displacement / numberOfPixelsCounted;
const double sigma = displacementSquared / numberOfPixelsCounted - vnl_math::sqr(meanDisplacement);

jacg = meanDisplacement + 2.0 * std::sqrt(sigma);

Expand Down