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

Image normalization and example notebooks #455

Closed
nkeim opened this issue Nov 9, 2017 · 2 comments
Closed

Image normalization and example notebooks #455

nkeim opened this issue Nov 9, 2017 · 2 comments
Milestone

Comments

@nkeim
Copy link
Contributor

nkeim commented Nov 9, 2017

@charlesreid1 has graciously shown in soft-matter/trackpy-examples#43 and soft-matter/trackpy-examples#44 that the walkthrough and some other notebooks have stopped working because of a change in trackpy's image normalization. Since this could be an API change since v0.3.x, I want to make sure this change was intentional before we merge. I am not discounting the possibility that it was intentional and I'm just ignorant 🙂 . I'm creating an issue because I'm not sure I'll have time to look at this for a couple more weeks.

soft-matter/trackpy-examples#44 contains many other helpful changes, so independent of the normalization issue we should target it for v0.4.

@nkeim nkeim added this to the 0.4 milestone Nov 9, 2017
@charlesreid1
Copy link
Contributor

I have some further thoughts on what's going on here, and where some of the confusion might be coming from (in case you aren't able to reproduce my error/issue on your machine).

This is actually related to pims, and how pims reads images using the ImageSequence object. In image_sequence.py at the top, there are three different imread() functions imported. These each work differently. See this gist. The summary:

  • skimage.io.imread does not normalize pixel values, so they are integers from 0-255
  • matplotlib.pyplot.imread does normalize pixel values, so they are floats from 0-1
  • scipy.ndimage.imread is deprecated in favor of matplotlib.pyplot.imread (as printed in the output of calls to scipy's imread() function), but it uses integer pixel values 0-255

I ran into problems with the mass values in the walkthrough notebook (and other notebooks) because I did not have scikit-image installed at the time I fixed the walkthrough notebook. However, after installing scikit-image (for the bubble foam notebook), I saw that all of the mass values had changed, because all of the pixel values were loaded differently.

I will need to update my pull request to use the original mass values that were there, now that I know this is not a change in the API but rather a missing package (scikit-image) on my end.

I also plan to open an issue in the pims repository about having inconsistent imread() behavior. It might be best to make either matplotlib or scikit-image a required package in pims, and whichever one is required, consistently use its imread() function. But that discussion should probably happen elsewhere...

@nkeim
Copy link
Contributor Author

nkeim commented Nov 9, 2017

Aha! Thanks for tracking this down. I feel like we've had similar issues before. But the fact that it breaks the walkthrough is pretty unsatisfactory.

Since you're editing the notebooks, it might be helpful to add a note at the top of the walkthrough notebook in soft-matter/trackpy-examples#44 explaining that we recommend skimage be installed, and if it is not installed, some measurements will be normalized differently.

I'm closing this now that we know trackpy itself is not the problem. To be continued in soft-matter/trackpy-examples#43 and soft-matter/pims#280 .

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

No branches or pull requests

2 participants