From 4bd3fe9eb05009345aeedc89bcbb62ed13bfddd9 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Mon, 1 Apr 2013 22:19:25 -0500 Subject: [PATCH] ENH: Add some checks on the inputs. --- skimage/color/colorlabel.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/skimage/color/colorlabel.py b/skimage/color/colorlabel.py index 22027401..cc295204 100644 --- a/skimage/color/colorlabel.py +++ b/skimage/color/colorlabel.py @@ -1,5 +1,6 @@ import os import ast +import warnings import itertools import ConfigParser @@ -68,6 +69,12 @@ def image_label2rgb(image, label, colors=None, alpha=0.3, image_alpha : float [0, 1] Opacity of the image. """ + if not image.shape[:2] == label.shape: + raise ValueError("`image` and `label` must be the same shape") + + if image.min() < 0: + warnings.warn("Negative intensities in `image` are not supported") + if colors is None: colors = DEFAULT_COLORS colors = [_rgb_vector(c) for c in colors]