From a57e282a7cbf36537f35e99e731afb008f1f4fdd Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Sat, 27 Nov 2021 12:20:41 +0100 Subject: [PATCH] PERF: Call `FastEvaluateMovingImageValueAndDerivative` in 4 more metrics Replace `this->EvaluateMovingImageValueAndDerivative(...)` calls by `this->FastEvaluateMovingImageValueAndDerivative(..., threadId)` in four more metrics: itkAdvancedKappaStatisticImageToImageMetric itkParzenWindowMutualInformationImageToImageMetric itkAdvancedMeanSquaresImageToImageMetric itkPCAMetric_F_multithreaded Follow-up to pull request https://github.com/SuperElastix/elastix/pull/556 commit c8c4a6a225a4fb21bf8464a4f34d5cc09332f025 "PERF: Make AdvancedNormalizedCorrelationImageToImageMetric faster" --- .../itkAdvancedKappaStatisticImageToImageMetric.hxx | 3 ++- .../itkParzenWindowMutualInformationImageToImageMetric.hxx | 3 ++- .../itkAdvancedMeanSquaresImageToImageMetric.hxx | 5 +++-- .../Metrics/PCAMetric/itkPCAMetric_F_multithreaded.hxx | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Components/Metrics/AdvancedKappaStatistic/itkAdvancedKappaStatisticImageToImageMetric.hxx b/Components/Metrics/AdvancedKappaStatistic/itkAdvancedKappaStatisticImageToImageMetric.hxx index ca96d4d68..b7b28fd0e 100644 --- a/Components/Metrics/AdvancedKappaStatistic/itkAdvancedKappaStatisticImageToImageMetric.hxx +++ b/Components/Metrics/AdvancedKappaStatistic/itkAdvancedKappaStatisticImageToImageMetric.hxx @@ -541,7 +541,8 @@ AdvancedKappaStatisticImageToImageMetric::ThreadedGet MovingImageDerivativeType movingImageDerivative; if (sampleOk) { - sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative); + sampleOk = this->FastEvaluateMovingImageValueAndDerivative( + mappedPoint, movingImageValue, &movingImageDerivative, threadId); } /** Do the actual calculation of the metric value. */ diff --git a/Components/Metrics/AdvancedMattesMutualInformation/itkParzenWindowMutualInformationImageToImageMetric.hxx b/Components/Metrics/AdvancedMattesMutualInformation/itkParzenWindowMutualInformationImageToImageMetric.hxx index 49ef54759..709c4dbb9 100644 --- a/Components/Metrics/AdvancedMattesMutualInformation/itkParzenWindowMutualInformationImageToImageMetric.hxx +++ b/Components/Metrics/AdvancedMattesMutualInformation/itkParzenWindowMutualInformationImageToImageMetric.hxx @@ -490,7 +490,8 @@ ParzenWindowMutualInformationImageToImageMetric::Thre */ if (sampleOk) { - sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative); + sampleOk = this->FastEvaluateMovingImageValueAndDerivative( + mappedPoint, movingImageValue, &movingImageDerivative, threadId); } if (sampleOk) diff --git a/Components/Metrics/AdvancedMeanSquares/itkAdvancedMeanSquaresImageToImageMetric.hxx b/Components/Metrics/AdvancedMeanSquares/itkAdvancedMeanSquaresImageToImageMetric.hxx index f0ce29726..35926741e 100644 --- a/Components/Metrics/AdvancedMeanSquares/itkAdvancedMeanSquaresImageToImageMetric.hxx +++ b/Components/Metrics/AdvancedMeanSquares/itkAdvancedMeanSquaresImageToImageMetric.hxx @@ -362,7 +362,7 @@ AdvancedMeanSquaresImageToImageMetric::ThreadedGetVal */ if (sampleOk) { - sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr); + sampleOk = this->FastEvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr, threadId); } if (sampleOk) @@ -677,7 +677,8 @@ AdvancedMeanSquaresImageToImageMetric::ThreadedGetVal */ if (sampleOk) { - sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative); + sampleOk = this->FastEvaluateMovingImageValueAndDerivative( + mappedPoint, movingImageValue, &movingImageDerivative, threadId); } if (sampleOk) diff --git a/Components/Metrics/PCAMetric/itkPCAMetric_F_multithreaded.hxx b/Components/Metrics/PCAMetric/itkPCAMetric_F_multithreaded.hxx index 6a7a70d0c..f288e2e90 100644 --- a/Components/Metrics/PCAMetric/itkPCAMetric_F_multithreaded.hxx +++ b/Components/Metrics/PCAMetric/itkPCAMetric_F_multithreaded.hxx @@ -779,7 +779,7 @@ PCAMetric::ThreadedGetSamples(ThreadIdType threadId) if (sampleOk) { - sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr); + sampleOk = this->FastEvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr, threadId); } if (sampleOk) @@ -991,7 +991,7 @@ PCAMetric::ThreadedComputeDerivative(ThreadIdType thr this->GetFixedImage()->TransformContinuousIndexToPhysicalPoint(voxelCoord, fixedPoint); this->TransformPoint(fixedPoint, mappedPoint); - this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative); + this->FastEvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative, threadId); /** Get the TransformJacobian dT/dmu */ this->EvaluateTransformJacobian(fixedPoint, jacobian, nzjis);