| 234 | |
| 235 | template<typename Metric> |
| 236 | double compare(const Image& imageA, const Image& imageB, bool alpha, float* errorMap) |
| 237 | { |
| 238 | Metric metric; |
| 239 | double sum = 0.0; |
| 240 | const float* a = imageA.getData(); |
| 241 | const float* b = imageB.getData(); |
| 242 | size_t count = imageA.getWidth() * imageA.getHeight(); |
| 243 | for (size_t i = 0; i < count; ++i) |
| 244 | { |
| 245 | double error = metric(a, b, alpha ? 4 : 3); |
| 246 | if (errorMap) |
| 247 | *errorMap++ = float(error); |
| 248 | sum += error; |
| 249 | a += 4; |
| 250 | b += 4; |
| 251 | } |
| 252 | return sum / count; |
| 253 | } |
| 254 | |
| 255 | struct ErrorMetric |
| 256 | { |