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/draw.py b/skimage/draw/draw.py index cbf3ced2..c823b73e 100644 --- a/skimage/draw/draw.py +++ b/skimage/draw/draw.py @@ -2,11 +2,6 @@ import numpy as np -def _coords_inside_image(rr, cc, shape): - mask = (rr >= 0) & (rr < shape[0]) & (cc >= 0) & (cc < shape[1]) - return rr[mask], cc[mask] - - def ellipse(cy, cx, yradius, xradius, shape=None): """Generate coordinates of pixels within ellipse. @@ -131,26 +126,10 @@ def set_color(img, coords, color): img : (M, N, D) ndarray The updated image. - Examples - -------- - >>> from skimage.draw import line, set_color - >>> img = np.zeros((10, 10), dtype=np.uint8) - >>> rr, cc = line(1, 1, 20, 20) - >>> set_color(img, (rr, cc), 1) - >>> img - array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]], dtype=uint8) - """ rr, cc = coords - rr, cc = _coords_inside_image(rr, cc, img.shape) - img[rr, cc] = color + 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