New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mdmueller cython wrappers: Made Python wrappers for public Cython functions #2303
Mdmueller cython wrappers: Made Python wrappers for public Cython functions #2303
Conversation
@scikit-image/core please, feel free to help to sort out the last issues. We need to merge this PR quickly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few comments, otherwise this looks good. But there seems to be a merge conflict.
Bresenham method is also known as midpoint circle algorithm. | ||
Anti-aliased circle generator is available with `circle_perimeter_aa`. | ||
|
||
This function is a wrapper for Cython code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is necessary...
|
||
Notes | ||
----- | ||
This function is a wrapper for Cython code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is necessary...
Wu's method draws anti-aliased circle. This implementation doesn't use | ||
lookup table optimization. | ||
|
||
This function is a wrapper for Cython code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is necessary...
|
||
Notes | ||
----- | ||
This function is a wrapper for Cython code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is necessary...
The algorithm is the rational quadratic algorithm presented in | ||
reference [1]_. | ||
|
||
This function is a wrapper for Cython code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is necessary...
|
||
Notes | ||
----- | ||
This function is a wrapper for Cython code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is necessary...
segmentation, though this is not strictly necessary. For this to work, the | ||
image must be given in RGB format. | ||
|
||
This function is a wrapper for Cython code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is necessary...
>>> result.tolist() | ||
[(10, 10.0, 10.0, 8.0, 6.0, 0.0)] | ||
>>> result | ||
[(10, 10.0, 8.0, 6.0, 0.0, 10.0)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?
|
||
Notes | ||
----- | ||
The accuracy must be chosen to produce a peak in the accumulator | ||
distribution. In other words, a flat accumulator distribution with low | ||
values may be caused by a too low bin size. | ||
|
||
This function is a wrapper for Cython code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is necessary...
|
||
Notes | ||
----- | ||
This function is a wrapper for Cython code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment is necessary...
I think some tests do not pass... |
37c96da
to
e0d5e8e
Compare
I fixed few additional regressions (thanks unittests). |
a9e0c12
to
3633ecb
Compare
OK. I think I'm done fixing the tests. |
Current coverage is 90.63% (diff: 100%)@@ master #2303 diff @@
==========================================
Files 304 305 +1
Lines 21540 21563 +23
Methods 0 0
Messages 0 0
Branches 1851 1852 +1
==========================================
+ Hits 19521 19544 +23
Misses 1665 1665
Partials 354 354
|
@@ -272,3 +268,354 @@ def set_color(img, coords, color, alpha=1): | |||
vals = img[rr, cc] * (1 - alpha) | |||
|
|||
img[rr, cc] = vals + color | |||
|
|||
|
|||
def line(y1, x1, y2, x2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to use 0-based indexing: y0, y1, ...
.
return _line(y1, x1, y2, x2) | ||
|
||
|
||
def line_aa(y1, x1, y2, x2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
@@ -156,7 +153,6 @@ def polygon_perimeter(cr, cc, shape=None, clip=False): | |||
|
|||
Examples | |||
-------- | |||
>>> from skimage.draw import polygon_perimeter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this line?
|
||
|
||
def circle_perimeter(cy, cx, radius, | ||
method='bresenham', shape=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be put in a single line?
|
||
Returns | ||
------- | ||
rr, cc : (N,) ndarray of int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I can understand, this is not correct. _bezier_curve
returns arrays in a reverse order (px, py
==> cc, rr
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's correct, it means that the API is wrong (see example below...). I vote to fix that elsewhere.
Shape of the grid. | ||
verts : (V, 2) array | ||
Specify the V vertices of the polygon, sorted either clockwise | ||
or anti-clockwise. The first point may (but does not need to be) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix double whitespace.
hspace_max = ndimage.maximum_filter1d(hspace, size=distance_size, axis=0, | ||
mode='constant', cval=0) | ||
hspace_max = ndimage.maximum_filter1d(hspace_max, size=angle_size, axis=1, | ||
mode='constant', cval=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why not just to use nd version of maximum_filter
? (Not a blocker for this PR.)
@@ -257,43 +153,30 @@ def hough_circle(image, radius, normalize=True, full_output=False): | |||
Hough transform accumulator for each radius. | |||
R designates the larger radius if full_output is True. | |||
Otherwise, R = 0. | |||
|
|||
Examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree to remove this for now - is a very complicated example. Any plans to add something instead in the near future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I even didn't figure out that was removed... hum.
Thanks for pushing this, @sciunto! Few remarks from my side, then is good to go. |
I made some changes. @soupault I do not disagree with the rest, but, if you don't mind, I would prefer to see new issues and this one merged. It's already thick. :) |
@sciunto Sure. |
@sciunto this is blocking now -> be94c6f#diff-17d59a5c1e414486337775a134925622L313 :). 0-indexing there as well. |
Thanks! I didn't see it. |
@sciunto would you like to squash the commits, while you are here? |
5d72078
to
ab5dc99
Compare
I regrouped half of them. I kept some of them for the history. |
This LGTM. @ahojnnes would you like to give it a quick look? |
LGTM. |
Thanks @mdmueller, @sciunto! Great work, gentlemen! |
Replaces #1432
Closes #1323, #2047