MCPcopy Create free account
hub / github.com/SuperElastix/elastix / ComputeRMSE

Function ComputeRMSE

Testing/itkTestHelper.h:215–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213// Helper function to compute RMSE
214template <typename TScalarType, typename CPUImageType, typename GPUImageType>
215TScalarType
216ComputeRMSE(const CPUImageType * cpuImage, const GPUImageType * gpuImage, TScalarType & rmsRelative)
217{
218 ImageRegionConstIterator<CPUImageType> cit(cpuImage, cpuImage->GetLargestPossibleRegion());
219 ImageRegionConstIterator<GPUImageType> git(gpuImage, gpuImage->GetLargestPossibleRegion());
220
221 TScalarType rmse = 0.0;
222 TScalarType sumCPUSquared = 0.0;
223
224 for (cit.GoToBegin(), git.GoToBegin(); !cit.IsAtEnd(); ++cit, ++git)
225 {
226 auto cpu = static_cast<TScalarType>(cit.Get());
227 TScalarType err = cpu - static_cast<TScalarType>(git.Get());
228 rmse += err * err;
229 sumCPUSquared += cpu * cpu;
230 }
231
232 rmse = std::sqrt(rmse / cpuImage->GetLargestPossibleRegion().GetNumberOfPixels());
233 rmsRelative = rmse / std::sqrt(sumCPUSquared / cpuImage->GetLargestPossibleRegion().GetNumberOfPixels());
234
235 return rmse;
236} // end ComputeRMSE()
237
238
239//------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 1

GetMethod · 0.80

Tested by

no test coverage detected