From 20f27345c3dfcbf1f7c4e5ca2482e94431a948bc Mon Sep 17 00:00:00 2001 From: spotter Date: Mon, 11 Mar 2013 23:54:06 +0100 Subject: [PATCH] FIX: rgb2hed and hed2rgb can work with both signed and unsigned image. --- skimage/color/colorconv.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skimage/color/colorconv.py b/skimage/color/colorconv.py index 072fc995..586ef340 100644 --- a/skimage/color/colorconv.py +++ b/skimage/color/colorconv.py @@ -769,7 +769,7 @@ def rgb2hed(rgb): >>> ihc = data.ihc() >>> ihc_hed = rgb2hed(ihc) """ - rgb = dtype.img_as_float(rgb) + 1 + rgb = dtype.img_as_float(rgb) + 2 hed = np.dot(np.reshape(-np.log(rgb), (-1, 3)), hed_from_rgb) return np.reshape(hed, rgb.shape) @@ -812,4 +812,4 @@ def hed2rgb(hed): hed = dtype.img_as_float(hed) logrgb1 = np.dot(-np.reshape(hed, (-1, 3)), rgb_from_hed) rgb1 = np.exp(logrgb1) - return rescale_intensity(np.reshape(rgb1 - 1, hed.shape), in_range=(0, 1)) + return rescale_intensity(np.reshape(rgb1 - 2, hed.shape), in_range=(-1, 1))