Apply format kernel to pcv - #1945
Conversation
|
|
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.
There was a problem hiding this comment.
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_kerneltokernel/ksizearguments 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
sharpenROI 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
ksizeis coerced tokfor the OpenCV call, but the debug filename still embeds the originalksize. 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.
Describe your changes
Applies
_format_kernelfunction to kernel/ksize arguments in the mainplantcv.plantcvmodule.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.
plantcv/mkdocs.ymlupdating.md