| 240 | // Helper function to compute RMSE |
| 241 | template <typename TScalarType, typename CPUImageType, typename GPUImageType> |
| 242 | TScalarType |
| 243 | ComputeRMSE2(const CPUImageType * cpuImage, const GPUImageType * gpuImage, const float & threshold) |
| 244 | { |
| 245 | ImageRegionConstIterator<CPUImageType> cit(cpuImage, cpuImage->GetLargestPossibleRegion()); |
| 246 | ImageRegionConstIterator<GPUImageType> git(gpuImage, gpuImage->GetLargestPossibleRegion()); |
| 247 | |
| 248 | TScalarType rmse = 0.0; |
| 249 | |
| 250 | for (cit.GoToBegin(), git.GoToBegin(); !cit.IsAtEnd(); ++cit, ++git) |
| 251 | { |
| 252 | TScalarType err = static_cast<TScalarType>(cit.Get()) - static_cast<TScalarType>(git.Get()); |
| 253 | if (err > threshold) |
| 254 | { |
| 255 | rmse += err * err; |
| 256 | } |
| 257 | } |
| 258 | rmse = std::sqrt(rmse / cpuImage->GetLargestPossibleRegion().GetNumberOfPixels()); |
| 259 | return rmse; |
| 260 | } // end ComputeRMSE2() |
| 261 | |
| 262 | |
| 263 | //------------------------------------------------------------------------------ |