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

Code Review #1

Open
frank-engel-usgs opened this issue Sep 20, 2021 · 6 comments
Open

Code Review #1

frank-engel-usgs opened this issue Sep 20, 2021 · 6 comments

Comments

@frank-engel-usgs
Copy link

frank-engel-usgs commented Sep 20, 2021

Purpose

This issue was created to serve as a review document for the USGS review of the PBR_filter repo.

Overview

I have reviewed and tested the code in the PBR_filter repository. The PBR_filter presents a novel method to pre-process images with a pansharpening-like approach. The resultant images will have increased contrast of edge features (especially) and differentiating color in transitions. The purpose is to aid in the detection of objects and training for Machine Learning (ML) applications, but would also be of use to other imagery science that often is looking for ways to increase contrast of texture or other features without changing the overall distribution of of values in the image.

Daniel has done a thorough job and the method appears to work on all tests I employed it on. I have no major recommendations to the code, however there were a few comments and minor suggestions which I have detailed in the next session.

Review

I followed the instructions in README.md to install using conda. Everything installed as expected (using Anaconda3 and PyCharms IDE).

  • I suggest also providing a requirements.txt and some easy instructions for installing without conda.
setup install PBR_filter.py
  • Also suggest some minor tweaks to README.md to easy reading. Adding some level 1 headings (e.g., Overview, How to Install, Example uses) would be a good idea.

That said, I was able to replicate all of the examples given in the readme. I also tried using the function on several examples of my own (typically UAS or stationary camera imagery used for Image Velocimetry).
The approach is novel, or at least I have not seen it before, and I think I have a decent idea of the current state of literature for imagery manipulation. I can see several use cases:

  • Aiding in ML dataset training (intended purpose)
  • Increasing "contrast" for imagery with poor bit depth and/or other complicated scenes
  • Another image processing algorithm that can be deployed for various imagery projects, e.g., classification, object/pattern detection, etc.

Method Review

  • line 60: Why set wavelet_levels=6? The default behavior is 3 less that the max possible decompositions. If this was a class, this would be a nice setting that could be suggested but varied by the user if needed
  • line 66: Is there a speed advantage to manually doing weighted grayscale conversion? Nevermind, I get it. skimage only has RGB to greyscale.
  • It may be better to evaluate whether or not you need to invert before doing the rolling ball segmentation. Could do something like:
def img_estim(img, thrshld):
    is_light = np.mean(img) > thrshld
  • I think this code should be reworked into a class. This would provide a quicker way to integrate into other software packages. I think you'd end up with some wide use in that case.
  • I have no other issues with this method. Pretty novel idea, and useful!

Code optimization / functionality /readability

I appreciate the inclusion of the warning suppression:

# rescale_sigma=True required to silence deprecation warnings
_denoise_wavelet = partial(denoise_wavelet, rescale_sigma=True)
from skimage import util

# import warnings filter
from warnings import simplefilter

However, I think it would be better to enable the warning messages. I could be convinced that leaving the partial(denoise_wavelet, rescale_sigma=True) makes sense, but not really the simplefilter application. This makes sense for a "one and done" script where users will not need any warnings. However, as I mention elsewhere in the review, I think this PBR_filter should be converted to not need tkinter, and be just callable as a class. In this case, the warnings may be more relevant.

  • The code is well written and pythonic. However, I would suggest renaming certain variables to help with the readibility of the code. For example, rather than refer to the loaded image as Z, I would at least do img, and maybe in_image would be even more descriptive.
  • I also suggest formalizing the function docstrings, preferably using the PEP8 or Google style guides.

Security / Other USGS stuff

"This software has been approved for release by the U.S. Geological Survey (USGS). Although the software has been subjected to rigorous review, the USGS reserves the right to update the software as needed pursuant to further analysis and review. No warranty, expressed or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor shall the fact of release constitute any such warranty. Furthermore, the software is released on condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from its authorized or unauthorized use."

@frank-engel-usgs
Copy link
Author

@dbuscombe-usgs: I have completed my review of your PBR_filter. Interesting and useful tool! See my review in the comment above, and let me know if you have any comments or follow up questions.

@dbuscombe-usgs
Copy link
Collaborator

Thanks for the very thorough review. However this is not the code I asked you to review (dash doodler)!

@frank-engel-usgs
Copy link
Author

Ha! Such is life. Ok, I'll review that one ASAP. Apologies. -F

@dbuscombe-usgs
Copy link
Collaborator

I'm on vacation now with bad signal for a few days but I will email when I can. Sorry for the confusion. It's doodler I would like to review and publish. See my original email with links to the code.usgs.gov repo. Thanks Frank!! 🙏

@dbuscombe-usgs
Copy link
Collaborator

So sorry for the confusion!! 😹

@frank-engel-usgs
Copy link
Author

No sweat @dbuscombe-usgs: I was happy to review PBR_filter, as I see it as something I would likely use in the future. So, no loss.

I'm sorry this delays your expected review!

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