Repository navigation
test: raise coverage of ImageSpatial from 62% to 97% and ImageProcessing from 72% to 98% - #223
Merged
Merged
Conversation
…ing from 72% to 98% The tests use small synthetic images with values worked out directly in NumPy: rank filters are compared with scipy.ndimage, the similarity measures with their formulae, and the interactive thresholds are driven with simulated mouse events. Four bugs are recorded as strict xfail tests: canny ignores sigma, th0 and th1, sad, ssd and ncc wrap around on uint8 images, the z similarity metrics change the caller's template and fail on uint8 images, and blend loses float64. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 192 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
OpenCV 5.1 gives 0.0156 at the match, not 0, from float32 sums of squares. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Some OpenCV 5.1 builds have cv2.ximgproc without its segmentation module. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second of three changes lifting coverage of the last
Image*.pymodules.ImageSpatial.pygoes from 62% to 97% andImageProcessing.pyfrom 72% to 98%.The tests are in two new files,
tests/test_image_spatial_extra.pyandtests/test_image_processing_extra.py. They use small synthetic images and work the expected values out directly in NumPy, so nothing is mocked:ImageSpatial:convolve(every mode, padding with a value, image andKernelkernels),gradients,direction,Harris_corner_strength,window,zerocross,scalespace,pyramid,cannyon a square,rankfilterandmedianfilter(compared withscipy.ndimage),distance_transform,labels_binary(4 and 8 connectivity),labels_MSER,labels_graphseg, the six similarity measures (compared with their formulae) andsimilarity, which must peak at the template's position.ImageProcessing:apply,apply2,clip,roll,invert,LUT,normhist,stretch, everythresholdmethod and the automaticotsu,triangleandpercentilechoices, the deprecatedthresh,t=andopt=forms,threshold_adaptive,blend,chooseandpaste(every method and position, mono and color). The interactive threshold is driven with simulated mouse events on its slider, and the notebook-widget version runs whereipywidgetsis installed.Four bugs found while writing these are recorded as strict
xfailtests, not fixed here, so whoever fixes one has to remove its marker:cannyignoressigma,th0andth1: it takes its thresholds from the mean of the image.sad,ssdandnccwrap around at 256 onuint8images (ncccan exceed 1).similaritywith azmetric subtracts the mean from the template in place, which changes the caller's template, and fails onuint8images.blend(dtype="double"), and blending float64 images, return float32.Testing
pytest tests: 1926 passed, 33 skipped, 12 xfailed.black,ruff checkandmypyreport no issues. Nothing is mocked exceptplt.showin the interactive threshold tests, which plays the part of the user dragging the slider. The graph segmentation test needsopencv-contrib-pythonand the notebook-widget test needsipywidgets; each is skipped without its package. Not run: CI on Windows or OpenCV 4 (CI will).This change was written with AI assistance (Claude Code) and the diff has been read by the maintainer.
🤖 Generated with Claude Code