Calculate the per-pixel errors, then compute the root mean square error.
(expected_image, actual_image)
| 381 | |
| 382 | |
| 383 | def calculate_rms(expected_image, actual_image): |
| 384 | """ |
| 385 | Calculate the per-pixel errors, then compute the root mean square error. |
| 386 | """ |
| 387 | if expected_image.shape != actual_image.shape: |
| 388 | raise ImageComparisonFailure( |
| 389 | f"Image sizes do not match expected size: {expected_image.shape} " |
| 390 | f"actual size {actual_image.shape}") |
| 391 | # Convert to float to avoid overflowing finite integer types. |
| 392 | return np.sqrt(((expected_image - actual_image).astype(float) ** 2).mean()) |
| 393 | |
| 394 | |
| 395 | # NOTE: compare_image and save_diff_image assume that the image does not have |
nothing calls this directly
no test coverage detected
searching dependent graphs…