From 1e327046239c970c99108c32cc29fc149d99e3f2 Mon Sep 17 00:00:00 2001 From: Tom Runia Date: Wed, 12 Dec 2018 18:19:32 +0100 Subject: [PATCH] still a bug --- steerable/SCFpyr_NumPy.py | 19 +++++++++++++++++++ steerable/SCFpyr_PyTorch.py | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/steerable/SCFpyr_NumPy.py b/steerable/SCFpyr_NumPy.py index 93db7e8..ea67ef8 100644 --- a/steerable/SCFpyr_NumPy.py +++ b/steerable/SCFpyr_NumPy.py @@ -188,8 +188,27 @@ def reconstruct(self, coeff): hidft = np.fft.fftshift(np.fft.fft2(coeff[0])) outdft = tempdft * lo0mask + hidft * hi0mask + real = outdft.real + imag = outdft.imag + print(' [numpy] levels remaining {}. outdft real ({:.3f}, {:.3f}, {:.3f})'.format( + len(coeff), real.mean().item(), real.std().item(), real.sum().item() + )) + print(' [numpy] levels remaining {}. outdft imag ({:.3f}, {:.3f}, {:.3f})'.format( + len(coeff), imag.mean().item(), imag.std().item(), imag.sum().item() + )) + reconstruction = np.fft.ifftshift(outdft) reconstruction = np.fft.ifft2(reconstruction) + + real = reconstruction.real + imag = reconstruction.imag + print(' [numpy] levels remaining {}. outdft real ({:.3f}, {:.3f}, {:.3f})'.format( + len(coeff), real.mean().item(), real.std().item(), real.sum().item() + )) + print(' [numpy] levels remaining {}. outdft imag ({:.3f}, {:.3f}, {:.3f})'.format( + len(coeff), imag.mean().item(), imag.std().item(), imag.sum().item() + )) + reconstruction = reconstruction.real.astype(np.uint8) return reconstruction diff --git a/steerable/SCFpyr_PyTorch.py b/steerable/SCFpyr_PyTorch.py index b7fc5e7..f861ebf 100644 --- a/steerable/SCFpyr_PyTorch.py +++ b/steerable/SCFpyr_PyTorch.py @@ -242,8 +242,29 @@ def reconstruct(self, coeff): hidft = np.fft.fftshift(np.fft.fft2(coeff_0)) outdft = tempdft * lo0mask + hidft * hi0mask + + + real = outdft.real + imag = outdft.imag + print(' [torch] levels remaining {}. outdft real ({:.3f}, {:.3f}, {:.3f})'.format( + len(coeff), real.mean().item(), real.std().item(), real.sum().item() + )) + print(' [torch] levels remaining {}. outdft imag ({:.3f}, {:.3f}, {:.3f})'.format( + len(coeff), imag.mean().item(), imag.std().item(), imag.sum().item() + )) + reconstruction = np.fft.ifftshift(outdft) reconstruction = np.fft.ifft2(reconstruction) + + real = reconstruction.real + imag = reconstruction.imag + print(' [torch] levels remaining {}. outdft real ({:.3f}, {:.3f}, {:.3f})'.format( + len(coeff), real.mean().item(), real.std().item(), real.sum().item() + )) + print(' [torch] levels remaining {}. outdft imag ({:.3f}, {:.3f}, {:.3f})'.format( + len(coeff), imag.mean().item(), imag.std().item(), imag.sum().item() + )) + reconstruction = reconstruction.real.astype(np.uint8) return reconstruction