Skip to content

Apply format kernel to pcv - #1945

Open
joshqsumner wants to merge 6 commits into
v5.0from
apply-format_kernel-to-pcv
Open

Apply format kernel to pcv#1945
joshqsumner wants to merge 6 commits into
v5.0from
apply-format_kernel-to-pcv

Conversation

@joshqsumner

Copy link
Copy Markdown
Contributor

Describe your changes
Applies _format_kernel function to kernel/ksize arguments in the main plantcv.plantcv module.

Type of update
This is a feature enhancement.

Associated issues
Part of #1911

Additional context
Builds off of #1944

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 Jun 8, 2026
@joshqsumner joshqsumner added enhancement Enhancements to existing features merge in order Set of PRs that need to be merged sequentially labels Jun 8, 2026
@deepsource-io

deepsource-io Bot commented Jun 8, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 0a9cf06...6d26d42 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Coverage  

Code Review Summary

Analyzer Status Updated (UTC) Details
Python Jul 22, 2026 7:56p.m. Review ↗
Code coverage Jul 22, 2026 7:56p.m. Review ↗

Code Coverage Summary

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

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


Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes kernel/ksize handling across several plantcv.plantcv image-processing functions by routing inputs through _format_kernel, enabling more flexible user inputs (int/tuple/ndarray) while updating documentation and a sharpen ROI test accordingly.

Changes:

  • Apply _format_kernel to kernel/ksize arguments in multiple filters and morphology wrappers (e.g., blur, sharpen, Sobel/Laplace, erosion/dilation, ROI-aware functions).
  • Update docstrings and user docs to describe the broadened kernel specification options.
  • Update sharpen ROI test to exercise integer kernel input.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/plantcv/test_sharpen.py Updates a sharpen ROI test to pass an integer kernel size.
plantcv/plantcv/stdev_filter.py Coerces ksize via _format_kernel before calling generic_filter; updates docstring.
plantcv/plantcv/sobel_filter.py Coerces ksize via _format_kernel before calling cv2.Sobel; updates docstring.
plantcv/plantcv/sharpen.py Coerces ksize via _format_kernel before unsharp masking.
plantcv/plantcv/segment_image_series.py Coerces ksize via _format_kernel for time-block propagation logic.
plantcv/plantcv/opening.py Coerces kernel via _format_kernel before calling skimage opening functions; adjusts import.
plantcv/plantcv/median_blur.py Uses _format_kernel for flexible median filter sizing and updates debug filename.
plantcv/plantcv/laplace_filter.py Coerces ksize via _format_kernel before calling cv2.Laplacian.
plantcv/plantcv/get_kernel.py Adds explicit type validation for _format_kernel inputs.
plantcv/plantcv/gaussian_blur.py Coerces ksize via _format_kernel before calling cv2.GaussianBlur.
plantcv/plantcv/erode.py Coerces ksize via _format_kernel before calling _erode; updates debug filename.
plantcv/plantcv/dilate.py Coerces ksize via _format_kernel before calling _dilate; updates debug filename.
plantcv/plantcv/closing.py Updates docstring to reflect standardized kernel specification.
docs/stdev_filter.md Updates docs to describe flexible ksize specification.
docs/sobel_filter.md Updates docs to describe flexible ksize specification for Sobel.
docs/sharpen.md Updates docs to describe flexible ksize specification for sharpen.
docs/segment_image_series.md Updates docs to describe flexible ksize specification for time blocks.
docs/median_blur.md Updates docs to describe flexible ksize specification for median blur.
docs/laplace_filter.md Updates docs to describe flexible ksize specification for Laplace.
docs/gaussian_blur.md Updates docs to describe flexible ksize specification for Gaussian blur.
docs/erode.md Minor documentation punctuation/wording adjustment.
Comments suppressed due to low confidence (1)

plantcv/plantcv/laplace_filter.py:42

  • ksize is coerced to k for the OpenCV call, but the debug filename still embeds the original ksize. If callers pass a tuple/array, the filename will not reflect the actual kernel size used.
    _debug(visual=lp_filtered,
           filename=os.path.join(params.debug_outdir,
                                 str(params.device) + '_lp_out_k' + str(ksize) + '_scale' + str(scale) + '.png'),
           cmap='gray')

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plantcv/plantcv/stdev_filter.py
Comment thread plantcv/plantcv/sobel_filter.py Outdated
Comment thread plantcv/plantcv/sobel_filter.py Outdated
Comment thread plantcv/plantcv/get_kernel.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancements to existing features merge in order Set of PRs that need to be merged sequentially ready to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants