Conversation
DeepSource reviewed changes in the commit range For detailed review results, please see the PR on DeepSource ↗ PR Report Card
Code Review Summary
How are these analyzer statuses calculated?Administrators can configure which issue categories are reported and cause analysis to be marked as failed when detected. This helps prevent bad and insecure code from being introduced in the codebase. If you're an administrator, you can modify this in the repository's settings. Code Coverage Summary
➟ Additional coverage metrics may have been reported. See full coverage report ↗ |
|||||||||||||||||||||||||||||||||||||||||||||||
|
There was a lot of hassle with cyclic imports getting this to pass checks. I ended up changing a bunch of places where a function is imported from |
There was a problem hiding this comment.
Pull request overview
This pull request adds a new image sharpening function using the unsharp masking technique, as requested in issue #1824. The PR also includes a significant refactoring effort that moves the Params and Outputs singleton classes from classes.py to a new _globals.py module and updates all imports throughout the codebase. Additionally, the Points class is renamed to Point (singular), and the time_lapse_video function and its tests are removed.
Changes:
- Added a new
sharpenfunction implementing unsharp masking for image sharpening - Refactored global singleton instances (
paramsandoutputs) into a dedicated_globals.pymodule - Renamed the
Pointsclass toPointfor consistency with naming conventions
Reviewed changes
Copilot reviewed 116 out of 118 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| plantcv/plantcv/sharpen.py | New function implementing image sharpening via unsharp masking with ROI support |
| tests/plantcv/test_sharpen.py | Basic test coverage for the sharpen function |
| plantcv/plantcv/_globals.py | New module containing Params and Outputs singleton classes |
| plantcv/plantcv/init.py | Updated imports to use _globals module and expose Point class |
| plantcv/plantcv/classes.py | Moved Params/Outputs to _globals.py, renamed Points to Point |
| plantcv/plantcv/deprecation_warning.py | Updated to use importlib.metadata.version instead of direct version import |
| plantcv/plantcv/visualize/time_lapse_video.py | Removed file |
| tests/plantcv/visualize/test_time_lapse_video.py | Removed file |
| plantcv/plantcv/visualize/init.py | Removed time_lapse_video import |
| tests/plantcv/annotate/test_points.py | Updated to use Point instead of Points |
| docs/sharpen.md | Documentation for the new sharpen function |
| docs/updating.md | Added entry for sharpen function signature |
| mkdocs.yml | Added sharpen documentation to navigation |
| 100+ other files | Updated imports from plantcv.plantcv import params/outputs to plantcv.plantcv._globals import params/outputs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import cv2 | ||
| import numpy as np | ||
| from plantcv.plantcv.sharpen import sharpen | ||
|
|
||
|
|
||
| def test_sharpen_zero_amount(test_data): | ||
| """Test for PlantCV.""" | ||
| # Read in test data | ||
| img = cv2.imread(test_data.small_rgb_img) | ||
| sharp_img = sharpen(img, (5, 5), amount = 0, threshold = 0) | ||
| assert np.average(img) == np.average(sharp_img) | ||
|
|
||
| def test_sharpen_any_amount(test_data): | ||
| """Test for PlantCV.""" | ||
| # Read in test data | ||
| img = cv2.imread(test_data.small_rgb_img) | ||
| sharp_img = sharpen(img, (5, 5), amount = 1, threshold = 0) | ||
| assert np.average(img) != np.average(sharp_img) | ||
|
|
||
| def test_sharpen_threshold(test_data): | ||
| """Test for PlantCV.""" | ||
| # Read in test data | ||
| img = cv2.imread(test_data.small_rgb_img) | ||
| zero_thresh = sharpen(img, (5, 5), amount = 1, threshold = 0) | ||
| thresh = sharpen(img, (5, 5), amount = 1, threshold = 100) | ||
| assert np.average(thresh) != np.average(zero_thresh) |
There was a problem hiding this comment.
Incomplete test coverage for the sharpen function. The tests only cover RGB images without ROI. Based on similar functions like gaussian_blur (see tests/plantcv/test_gaussian_blur.py), the test suite should also include: (1) test with ROI on RGB image, (2) test on grayscale image, (3) test with ROI on grayscale image, and (4) tests for sigma_x and sigma_y parameters which are currently not tested at all.
Describe your changes
Added a sharpening function using unsharp masking.
Type of update
This is a new feature.
Associated issues
Closes #1824
For the reviewer
See this page for instructions on how to review the pull request.
plantcv/mkdocs.ymlupdating.md