From 95f9855af23f521fa97bf3e772330fc6a58701f6 Mon Sep 17 00:00:00 2001 From: Ruan Comelli Date: Wed, 23 Jun 2021 16:17:38 -0300 Subject: [PATCH] fix: reshape images to match in *shannon_cross_entropy* With this fix, we can now safely compare two images with different shapes. --- boiling_learning/preprocessing/image.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boiling_learning/preprocessing/image.py b/boiling_learning/preprocessing/image.py index b3c17227..df0e2f84 100644 --- a/boiling_learning/preprocessing/image.py +++ b/boiling_learning/preprocessing/image.py @@ -295,6 +295,8 @@ def retained_variance(ref: np.ndarray, image: np.ndarray) -> float: def shannon_cross_entropy( ref: np.ndarray, image: np.ndarray, nbins: int = 100 ) -> float: + ref, image = reshape_to_largest(ref, image) + ref_histogram, _ = histogram(ref, nbins=nbins) img_histogram, _ = histogram(image, nbins=nbins)