From 3a9dbd127f068371ae82e0804fd1ce3c7a6ddeca Mon Sep 17 00:00:00 2001 From: Floris Van den Abeele Date: Thu, 20 Jun 2019 13:50:07 +0200 Subject: [PATCH] Clip the out from run_bm3d_wrap before the type conversion. --- pybm3d/bm3d.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pybm3d/bm3d.pyx b/pybm3d/bm3d.pyx index a0405f5..30e3ca3 100644 --- a/pybm3d/bm3d.pyx +++ b/pybm3d/bm3d.pyx @@ -132,12 +132,12 @@ def bm3d(input_array, *args, clip=True, **kwargs): input_array = np.atleast_3d(input_array).astype(np.float32) out = run_bm3d_wrap(input_array, *args, **kwargs) - out = np.array(out, dtype=initial_dtype).reshape(initial_shape) if clip: if np.issubdtype(initial_dtype, np.integer): dtype_info = np.iinfo(initial_dtype) else: dtype_info = np.finfo(initial_dtype) out = np.clip(out, dtype_info.min, dtype_info.max) + out = np.array(out, dtype=initial_dtype).reshape(initial_shape) return out