diff --git a/skimage/draw/_draw.pyx b/skimage/draw/_draw.pyx index c22600a4..db63d343 100644 --- a/skimage/draw/_draw.pyx +++ b/skimage/draw/_draw.pyx @@ -834,31 +834,3 @@ def bezier_curve(Py_ssize_t y0, Py_ssize_t x0, px.extend(rr) py.extend(cc) return np.array(px, dtype=np.intp), np.array(py, dtype=np.intp) - - -def set_color(img, coords, color): - """Set pixel color in the image at the given coordinates. - - Coordinates that exceed the shape of the image will be ignored. - - Parameters - ---------- - img : (M, N, D) ndarray - Image - coords : ((P,) ndarray, (P,) ndarray) - Coordinates of pixels to be colored. - color : (D,) ndarray - Color to be assigned to coordinates in the image. - - Returns - ------- - img : (M, N, D) ndarray - The updated image. - - """ - - rr, cc = coords - rr_inside = np.logical_and(rr >= 0, rr < img.shape[0]) - cc_inside = np.logical_and(cc >= 0, cc < img.shape[1]) - inside = np.logical_and(rr_inside, cc_inside) - img[rr[inside], cc[inside]] = color diff --git a/skimage/draw/tests/test_draw.py b/skimage/draw/tests/test_draw.py index d3cab811..2d739f0f 100644 --- a/skimage/draw/tests/test_draw.py +++ b/skimage/draw/tests/test_draw.py @@ -1,11 +1,22 @@ from numpy.testing import assert_array_equal, assert_equal import numpy as np -from skimage.draw import (line, line_aa, polygon, +from skimage.draw import (set_color, line, line_aa, polygon, circle, circle_perimeter, circle_perimeter_aa, ellipse, ellipse_perimeter, - _bezier_segment, bezier_curve, - ) + _bezier_segment, bezier_curve) + + +def test_set_color(): + img = np.zeros((10, 10)) + + rr, cc = line(0, 0, 0, 30) + set_color(img, (rr, cc), 1) + + img_ = np.zeros((10, 10)) + img_[0, :] = 1 + + assert_array_equal(img, img_) def test_line_horizontal():