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

Blob Detection Example #986

Merged
merged 14 commits into from May 1, 2014
Merged

Conversation

vighneshbirodkar
Copy link
Contributor

@cdeil
The Hubble Deep Field image is added here.

My only concern is the example runs 3 algorithms, and is unresponsive for 6s before all 3 images pop up.

@vighneshbirodkar
Copy link
Contributor Author

matplotlib can't load a jpg image because there is no there is no PIL on Python3. Should I resubmit this with a PNG image ?

@cdeil
Copy link
Contributor

cdeil commented Apr 22, 2014

matplotlib can't load a jpg image because there is no there is no PIL on Python3.

Being able to read JPG (via some external library) is pretty fundamental for an image-processing library like scikit-image. What is the recommended method for Python 3 for scikit-image users?


blobs = blob_log(image_gray, max_sigma=30, num_sigma=10, threshold=.1)

fig = plt.figure()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You basically repeat the same code three times.
Put it in a function and call that three times?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you notice Line 85 is different than the other 2 cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then compute the three types of blobs first, multiply the one by sqrt(2), then proceed with a for loop over all three.

@vighneshbirodkar
Copy link
Contributor Author

I am not sure what the recommended way is on Python3 but the freeimage plugin can do it

@cdeil
Copy link
Contributor

cdeil commented Apr 22, 2014

Let's wait for the scikit-image devs to comment if JPG is OK for an example image.
If yes you can simply update the .travis.yml file to make it work on Python 3.

With a very quick search I couldn't find info on how to read JPG images in the scikit-image docs.
If it's not there, @vighneshbirodkar, maybe you could add it?

@stefanv
Copy link
Member

stefanv commented Apr 22, 2014

FreeImage is installed on Travis, and should automatically be picked up. But even Matplotlib should be able to read JPEG, so not sure why this won't work on 3.

@stefanv
Copy link
Member

stefanv commented Apr 22, 2014

Ah, it's actually Matplotlib raising the error.

@vighneshbirodkar
Copy link
Contributor Author

I guess Travis hates us for some reason 😟
I think we can fix this by giving FreeImage priority whenever it's installed

@stefanv
Copy link
Member

stefanv commented Apr 22, 2014

Perhaps FreeImage should become the preferred default plugin:

https://github.com/scikit-image/scikit-image/blob/master/skimage/io/manage_plugins.py#L47

Alternatively, disable the matplotlib plugin when PIL is unavailable (you can see how to do it in the freeimage plugin).


blobs = blob_doh(image_gray, max_sigma=30, threshold=.01)

fig = plt.figure()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer the following syntax:

f, ax = plt.subplots(1, 1)

@JDWarner
Copy link
Contributor

We should probably default away from matplotlib for Python 3, at least until they decide Pillow is stable enough to incorporate or PIL comes back from the dead with a Python 3 compatible version...

@vighneshbirodkar
Copy link
Contributor Author

FreeImage cannot read a bytestream. Should I use a specific plugin in the failing test case ?

@tacaswell
Copy link
Contributor

(mpl dev) We have already switched to defaulting to pillow (atleast on the master branch matplotlib/matplotlib#2137 )

@stefanv
Copy link
Member

stefanv commented Apr 25, 2014

Why don't we just update our PIL plugin to also support pillow?

@jni
Copy link
Member

jni commented Apr 25, 2014

@stefanv I thought there was a recent PR to do that? I think it was
@sciunto's, and I merged it.

On Fri, Apr 25, 2014 at 5:20 PM, Stefan van der Walt <
notifications@github.com> wrote:

Why don't we just update our PIL plugin to also support pillow?

Reply to this email directly or view it on GitHubhttps://github.com//pull/986#issuecomment-41365271
.

@stefanv
Copy link
Member

stefanv commented Apr 25, 2014

Ah! If so, we probably only need to install pillow on the Python 3
buildbot.

@vighneshbirodkar
Copy link
Contributor Author

Wouldn't it be better to install pillow for both Python 2 and Python 3 ?

@stefanv
Copy link
Member

stefanv commented Apr 26, 2014

Sure, that's fine too.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 75ed73d on vighneshbirodkar:blob_example into 7a1213a on scikit-image:master.

def hubble_deep_field():
"""Hubble eXtreme Deep Field

This photograph contains the Hubble Telescopes farthest ever view of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hubble Space Telescope's

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 5a67937 on vighneshbirodkar:blob_example into 7a1213a on scikit-image:master.

@stefanv
Copy link
Member

stefanv commented Apr 27, 2014

Looks good! Please fix the typos in the commit messages. Thereafter, I'll let @cdeil sign off on the changes.

@cdeil
Copy link
Contributor

cdeil commented Apr 27, 2014

@stefanv FYI: Probably @vighneshbirodkar doesn't have permissions to re-start the travis-ci build. There's a feature request to let committers do this, but it's not available at the moment: travis-ci/travis-ci#887.

Blobs are bright on dark or dark on bright regions in an image. In
this example, blobs are detected using 3 algorithms. The image used
in this case is the Hubble eXtreme Deep Field. Each bright dot in the
image is a star or a galaxy, so we are literally counting stars.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true (I think most blobs are Galaxies, not stars), so I suggest to remove this statement:

so we are literally counting stars.

@cdeil
Copy link
Contributor

cdeil commented Apr 27, 2014

@vighneshbirodkar I've left some minor inline comments.

Is it possible to link to API docs from the example text?
If yes, I think the example would benefit from linking to the blob_* and hubble_deep_field docstrings.

@stefanv
Copy link
Member

stefanv commented Apr 27, 2014

Thanks for the detailed feedback, @cdeil!​

<http://hubblesite.org/newscenter/archive/releases/2012/37/image/a/>`__.

The image was captured by NASA and `may be freely used in the
public domain <http://www.nasa.gov/audience/formedia/features/MP_Photo_Guidelines.html>`_.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cdeil The URL itself occupies 80 chars. IMHO we should not break the URL.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 580f5d2 on vighneshbirodkar:blob_example into 7a1213a on scikit-image:master.

@vighneshbirodkar
Copy link
Contributor Author

@cdeil , @stefanv
Thanks a lot for the feedback. And sorry for my typos.

@cdeil
Copy link
Contributor

cdeil commented Apr 27, 2014

@vighneshbirodkar Thanks for taking all the little wording comments into account.

I think there's one comment I wrote above you haven't taken into account (or rejected) yet:

Is it possible to link to API docs from the example text?
If yes, I think the example would benefit from linking to the blob_* and hubble_deep_field docstrings.

Once that is addressed, 👍 to merge.

I would prefer this slightly different way of writing the example:
https://gist.github.com/cdeil/11354543
But that's a matter of taste, so @vighneshbirodkar, you decide.

@vighneshbirodkar
Copy link
Contributor Author

@cdeil
It might not always be true that the radius is a a multiple of the 3rd parameter returned.

@cdeil
Copy link
Contributor

cdeil commented Apr 27, 2014

It might not always be true that the radius is a a multiple of the 3rd parameter returned.

Why not?
I guess the methods you are thinking of measure an area, but for API uniformity I would suggest to return sqrt(area) in those cases and have the third parameter always be proportional to the radius.

@vighneshbirodkar
Copy link
Contributor Author

We could compute and always return the radius of the blob, that was how I initially implemented it, but later on it was decided that returning the "model parameters" was the better way, as @stefanv suggested

Edit : See #903

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling cc76e8a on vighneshbirodkar:blob_example into 7a1213a on scikit-image:master.

@cdeil
Copy link
Contributor

cdeil commented Apr 27, 2014

@vighneshbirodkar OK, the current way you handle the blobs is perfectly fine!
But if e.g. detection methods are introduced that return for some reason multiple model parameters for each blob your tuple unpacking will not work either and a re-formatting into a uniform container before plotting as e.g. here would be the cleanest solution.
If you want to save two lines you could remove the different colors for the blobs since they have no information, but that is a very nitpicky comment.

@stefanv In my opinion this is ready to merge.

@cdeil
Copy link
Contributor

cdeil commented Apr 30, 2014

@stefanv Merge this now? Can this still go in the upcoming release?

stefanv added a commit that referenced this pull request May 1, 2014
@stefanv stefanv merged commit 5e4bce3 into scikit-image:master May 1, 2014
@stefanv
Copy link
Member

stefanv commented May 1, 2014

Thanks, @vighneshbirodkar & @cdeil!

@cdeil
Copy link
Contributor

cdeil commented Nov 7, 2014

@vighneshbirodkar I don't know if you saw it ... this data example and blob detection is featured in this article on the IPython notebook in Nature (click on the interactive demo link):
http://www.nature.com/news/interactive-notebooks-sharing-the-code-1.16261

Pretty cool!

@jni
Copy link
Member

jni commented Nov 7, 2014

👍 !

@vighneshbirodkar
Copy link
Contributor Author

Thanks. I wasn't aware .
On 7 Nov 2014 17:07, "Juan Nunez-Iglesias" notifications@github.com wrote:

[image: 👍] !


Reply to this email directly or view it on GitHub
#986 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants