From c2fd471c5589c3a94c4477ffae1a8befef6b93fc Mon Sep 17 00:00:00 2001 From: blink1073 Date: Tue, 4 Feb 2014 21:59:39 -0600 Subject: [PATCH] Fix aliasing and update docstring --- skimage/measure/profile.py | 5 +++-- skimage/viewer/plugins/lineprofile.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/skimage/measure/profile.py b/skimage/measure/profile.py index 7cb6a135..fef3fac8 100644 --- a/skimage/measure/profile.py +++ b/skimage/measure/profile.py @@ -78,8 +78,9 @@ def _line_profile_coordinates(src, dst, linewidth=1): Returns ------- - return_value : array - The coordinates of the profile along the scan line. The length of the profile is the ceil of the computed length of the scan line. The array is of the form (2, length, linewidth). + coords : array, shape (2, N, C), float + The coordinates of the profile along the scan line. The length of the + profile is the ceil of the computed length of the scan line. Notes ----- diff --git a/skimage/viewer/plugins/lineprofile.py b/skimage/viewer/plugins/lineprofile.py index 03b5eaaf..2affc444 100644 --- a/skimage/viewer/plugins/lineprofile.py +++ b/skimage/viewer/plugins/lineprofile.py @@ -159,7 +159,11 @@ class LineProfile(PlotPlugin): if width > 1: rp, cp = measure.profile._line_profile_coordinates( *end_points[:, ::-1], linewidth=width) - line_image[rp.astype(int), cp.astype(int)] = 128 + # the points are aliased, so create a polygon using the corners + yp = np.rint(rp[[0, 0, -1, -1],[0, -1, -1, 0]]).astype(int) + xp = np.rint(cp[[0, 0, -1, -1],[0, -1, -1, 0]]).astype(int) + rp, cp = draw.polygon(yp, xp, line_image.shape) + line_image[rp, cp] = 128 (x1, y1), (x2, y2) = end_points.astype(int) rr, cc = draw.line(y1, x1, y2, x2) line_image[rr, cc] = 255