Skip to content
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

Merged
merged 9 commits into from Sep 26, 2016

Conversation

sciunto
Copy link
Member

@sciunto sciunto commented Sep 17, 2016

Replaces #1432

Closes #1323, #2047

@sciunto sciunto added the 🔧 type: Maintenance Refactoring and maintenance of internals label Sep 17, 2016
@sciunto sciunto added this to the 0.13 milestone Sep 17, 2016
@sciunto sciunto changed the title Mdmueller cython wrappers Mdmueller cython wrappers: Made Python wrappers for public Cython functions Sep 17, 2016
@sciunto
Copy link
Member Author

sciunto commented Sep 17, 2016

@scikit-image/core please, feel free to help to sort out the last issues. We need to merge this PR quickly.

Copy link
Member

@ahojnnes ahojnnes left a 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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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)]
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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...

@sciunto
Copy link
Member Author

sciunto commented Sep 17, 2016

I think some tests do not pass...

@sciunto
Copy link
Member Author

sciunto commented Sep 17, 2016

I fixed few additional regressions (thanks unittests).

@sciunto
Copy link
Member Author

sciunto commented Sep 17, 2016

OK. I think I'm done fixing the tests.

@codecov-io
Copy link

codecov-io commented Sep 18, 2016

Current coverage is 90.63% (diff: 100%)

Merging #2303 into master will increase coverage by 0.01%

@@             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          

Powered by Codecov. Last update 9a516ed...ab5dc99

@@ -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):
Copy link
Member

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):
Copy link
Member

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
Copy link
Member

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):
Copy link
Member

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
Copy link
Member

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).

Copy link
Member Author

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)
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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?

Copy link
Member Author

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.

@soupault
Copy link
Member

Thanks for pushing this, @sciunto! Few remarks from my side, then is good to go.

@sciunto
Copy link
Member Author

sciunto commented Sep 18, 2016

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. :)

@soupault
Copy link
Member

@sciunto Sure.
You forgot to rename variables in returns. :)

@sciunto
Copy link
Member Author

sciunto commented Sep 23, 2016

@soupault I opened #2319, so it's not blocking this PR and @amccaugh can work on his feature.

Thanks!

@soupault
Copy link
Member

@sciunto this is blocking now -> be94c6f#diff-17d59a5c1e414486337775a134925622L313 :). 0-indexing there as well.

@sciunto
Copy link
Member Author

sciunto commented Sep 26, 2016

Thanks! I didn't see it.

@soupault
Copy link
Member

@sciunto would you like to squash the commits, while you are here?

@sciunto
Copy link
Member Author

sciunto commented Sep 26, 2016

I regrouped half of them. I kept some of them for the history.

@soupault
Copy link
Member

This LGTM. @ahojnnes would you like to give it a quick look?

@ahojnnes
Copy link
Member

LGTM.

@soupault soupault merged commit 5d0352f into scikit-image:master Sep 26, 2016
@sciunto sciunto deleted the mdmueller-cython-wrappers2 branch September 26, 2016 19:56
@soupault
Copy link
Member

Thanks @mdmueller, @sciunto! Great work, gentlemen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 type: Maintenance Refactoring and maintenance of internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants