Repository: scikit-image/scikit-image

Issue:
BUG: name of bg_color is not supported in skimage.color.label2rgb
## Description
Docstring of `label2rgb` says
```
    bg_color : str or array, optional
        Background color. Must be a name in `color_dict` or RGB float values
        between [0, 1].
```
but only array of `bg_color` is supported in the `kind` of overlay.
The reason is lack of processing for string at here
https://github.com/scikit-image/scikit-image/blob/7227346b262659103392b5701b057b776664f9aa/skimage/color/colorlabel.py#L46-L48

<!--
(Note: for guidance on how to use `scikit-image`, please post instead on https://forum.image.sc/tag/scikit-image)
-->

## Way to reproduce
we can simply reproduce the bug by using the example `doc/examples/segmentation/plot_label.py`
```python
# Place the full code we need to recreate your issue here
# upload all necessary images to github too!
from skimage import data
from skimage.filters import threshold_otsu
from skimage.segmentation import clear_border
from skimage.measure import label
from skimage.morphology import closing, square
from skimage.color import label2rgb


image = data.coins()[50:-50, 50:-50]

thresh = threshold_otsu(image)
bw = closing(image > thresh, square(3))

cleared = clear_border(bw)

label_image = label(cleared)
image_label_overlay = label2rgb(label_image, image=image, bg_label=0, bg_color='red')
```


## Version information
```python
# Paste the output of the following python commands
from __future__ import print_function
import sys; print(sys.version)
import platform; print(platform.platform())
import skimage; print("scikit-image version: {}".format(skimage.__version__))
import numpy; print("numpy version: {}".format(numpy.__version__))
```

```python
# your output here
3.6.10 | packaged by conda-forge | (default, Mar  5 2020, 09:56:10) 
[GCC Clang 9.0.1 ]
Darwin-18.7.0-x86_64-i386-64bit
scikit-image version: 0.17.dev0
numpy version: 1.18.1
```



Discussion:
Oh, wow! Thanks for reporting!
just to note that I am working on this.

Resolving patch:
diff --git a/skimage/color/colorlabel.py b/skimage/color/colorlabel.py
--- a/skimage/color/colorlabel.py
+++ b/skimage/color/colorlabel.py
@@ -45,7 +45,7 @@ def _match_label_with_color(label, colors, bg_label, bg_color):
     # Temporarily set background color; it will be removed later.
     if bg_color is None:
         bg_color = (0, 0, 0)
-    bg_color = _rgb_vector([bg_color])
+    bg_color = _rgb_vector(bg_color)
 
     # map labels to their ranks among all labels from small to large
     unique_labels, mapped_labels = np.unique(label, return_inverse=True)
@@ -66,7 +66,7 @@ def _match_label_with_color(label, colors, bg_label, bg_color):
 
     # Modify labels and color cycle so background color is used only once.
     color_cycle = itertools.cycle(colors)
-    color_cycle = itertools.chain(bg_color, color_cycle)
+    color_cycle = itertools.chain([bg_color], color_cycle)
 
     return mapped_labels, color_cycle
 
@@ -223,7 +223,7 @@ def _label2rgb_avg(label_field, image, bg_label=0, bg_color=(0, 0, 0)):
     out : array, same shape and type as `image`
         The output visualization.
     """
-    out = np.zeros_like(image)
+    out = np.zeros(label_field.shape + (3,))
     labels = np.unique(label_field)
     bg = (labels == bg_label)
     if bg.any():


Test patch:
diff --git a/skimage/color/tests/test_colorlabel.py b/skimage/color/tests/test_colorlabel.py
--- a/skimage/color/tests/test_colorlabel.py
+++ b/skimage/color/tests/test_colorlabel.py
@@ -6,7 +6,8 @@
 
 from skimage._shared import testing
 from skimage._shared.testing import (assert_array_almost_equal,
-                                     assert_array_equal, assert_warns)
+                                     assert_array_equal, assert_warns,
+                                     assert_no_warnings)
 
 
 def test_deprecation_warning():
@@ -198,3 +199,20 @@ def test_negative_intensity():
     labels = np.arange(100).reshape(10, 10)
     image = np.full((10, 10), -1, dtype='float64')
     assert_warns(UserWarning, label2rgb, labels, image, bg_label=-1)
+
+
+def test_bg_color_rgb_string():
+    img = np.random.randint(0, 255, (10, 10), dtype=np.uint8)
+    labels = np.zeros((10, 10), dtype=np.int64)
+    labels[1:3, 1:3] = 1
+    labels[6:9, 6:9] = 2
+    output = label2rgb(labels, image=img, alpha=0.9, bg_label=0, bg_color='red')
+    assert output[0, 0, 0] > 0.9 # red channel
+
+
+def test_avg_with_2d_image():
+    img = np.random.randint(0, 255, (10, 10), dtype=np.uint8)
+    labels = np.zeros((10, 10), dtype=np.int64)
+    labels[1:3, 1:3] = 1
+    labels[6:9, 6:9] = 2
+    assert_no_warnings(label2rgb, labels, image=img, bg_label=0, kind='avg')