From d546fe8e45414fbe7fc7a47c51ee62fff16fed9a Mon Sep 17 00:00:00 2001 From: Luke Yeager Date: Fri, 14 Oct 2016 12:31:34 -0700 Subject: [PATCH] Segmentation - force image into [0-255] before viz --- digits/extensions/view/imageSegmentation/view.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/digits/extensions/view/imageSegmentation/view.py b/digits/extensions/view/imageSegmentation/view.py index 538441e30..eab50f4b6 100644 --- a/digits/extensions/view/imageSegmentation/view.py +++ b/digits/extensions/view/imageSegmentation/view.py @@ -206,7 +206,14 @@ def process_data(self, input_id, input_data, output_data): fill_data[:, :, x] * line_mask) # Input image with outlines - input_image = PIL.Image.fromarray(input_data) + input_max = input_data.max() + input_min = input_data.min() + input_range = input_max - input_min + if input_range > 255: + input_data = (input_data - input_min) * 255.0 / input_range + elif input_min < 0: + input_data -= input_min + input_image = PIL.Image.fromarray(input_data.astype('uint8')) input_image.format = 'png' # Fill image