Skip to content

Image sharpening#1825

Merged
nfahlgren merged 41 commits intov5.0from
image-sharpening
Feb 13, 2026
Merged

Image sharpening#1825
nfahlgren merged 41 commits intov5.0from
image-sharpening

Conversation

@joshqsumner
Copy link
Contributor

@joshqsumner joshqsumner commented Oct 27, 2025

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.

  • PR functionality reviewed in a Jupyter Notebook
  • All tests pass
  • Test coverage remains 100%
  • Documentation tested
  • New documentation pages added to plantcv/mkdocs.yml
  • Changes to function input/output signatures added to updating.md
  • Code reviewed
  • PR approved

@joshqsumner joshqsumner added this to the PlantCV v5.0 milestone Oct 27, 2025
@joshqsumner joshqsumner added new feature New feature ideas and solutions work in progress Mark work in progress labels Oct 27, 2025
@joshqsumner joshqsumner changed the base branch from main to v5.0 October 27, 2025 16:36
@deepsource-io
Copy link

deepsource-io bot commented Oct 27, 2025

DeepSource Code Review

DeepSource reviewed changes in the commit range a3a0eab..125cc85 on this pull request. Below is the summary for the review, and you can see the individual issues we found as review comments.

For detailed review results, please see the PR on DeepSource ↗

PR Report Card

Security × 0 issues Overall PR Quality   

Reliability × 0 issues
Complexity × 0 issues
Hygiene × 0 issues
Coverage × 0 issues

Code Review Summary

Analyzer Status Summary Details
Python 1 existing issue fixed. Review ↗
Test coverage No new issues detected. Review ↗
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

Language Line Coverage Branch Coverage
New Code Overall New Code Overall
Aggregate
100%
[✓ above threshold]
100%
100%
100%
Python
100%
[✓ above threshold]
100%
100%
100%

➟ Additional coverage metrics may have been reported. See full coverage report ↗

@joshqsumner joshqsumner added ready to review and removed work in progress Mark work in progress labels Oct 28, 2025
@joshqsumner
Copy link
Contributor Author

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 plantcv.plantcv into plantcv.plantcv.module and making _globals to define params/outputs. That worked eventually for this PR but it's probably indicative of something we could take more care in actually fixing.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 sharpen function implementing unsharp masking for image sharpening
  • Refactored global singleton instances (params and outputs) into a dedicated _globals.py module
  • Renamed the Points class to Point for 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.

Comment on lines +1 to +26
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)
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@joshqsumner joshqsumner mentioned this pull request Feb 6, 2026
8 tasks
@nfahlgren nfahlgren merged commit db9d162 into v5.0 Feb 13, 2026
5 checks passed
@nfahlgren nfahlgren deleted the image-sharpening branch February 13, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature ideas and solutions ready to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sharpening images

3 participants