-
-
Notifications
You must be signed in to change notification settings - Fork 9
FIx clip #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis PR refactors core LUT operations to use explicit per-channel loops with preallocated float32 buffers, standardizes use of float32 in OpenCV operations and LUT generation, and cleans up redundant conversions and unused code across the normalization and arithmetic functions. Class diagram for refactored LUT and normalization functionsclassDiagram
class functions {
+apply_lut(img, value, operation, inplace)
+normalize_lut(img, mean, denominator, dtype, max_value)
+power_lut(img, exponent, inplace)
+multiply_add_lut(img, factor, value, inplace)
+normalize_per_image_lut(img, normalization, eps, max_value)
+to_float_lut(img, max_value)
+_normalize_mean_std_opencv(img, mean, std)
+normalize_per_image_opencv(img, normalization, eps)
}
functions : np.empty_like(img, dtype=np.float32)
functions : per-channel for-loops for LUT application
functions : standardize float32 dtype for OpenCV operations
functions : remove redundant dtype conversions
functions : remove unused code
functions --> cv2.LUT
functions --> cv2.multiply
functions --> cv2.add
functions --> cv2.normalize
functions --> sz_lut
functions --> clip
functions --> create_lut_array
Flow diagram for per-channel LUT application refactorflowchart TD
A[Start: apply_lut or multiply_add_lut called] --> B[Preallocate result array as float32]
B --> C{For each channel}
C -->|i=0..num_channels-1| D[Apply LUT to channel i]
D --> C
C -->|All channels processed| E[Return result array]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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 PR fixes various issues with LUT-based image processing functions to improve type consistency and normalization behavior. Key changes include replacing cv2.merge with manual per-channel processing, updating data types for OpenCV arithmetic, and modifying clipping behavior in normalization routines.
Comments suppressed due to low confidence (2)
albucore/functions.py:733
- The removal of the explicit clipping (previously result.clip(-20, 20)) in the 'image_per_channel' normalization branch may change the expected output range. If this behavior is intended, consider updating the function documentation to clearly reflect the change.
return result
albucore/functions.py:470
- Changing the 'inplace' flag from True to False for the clip function in multiply_add_lut may alter the expected side-effect behavior. Verify that downstream code does not rely on in-place modifications of the LUT array.
luts = clip(np.arange(0, max_value + 1, dtype=np.float32) * factor + value, dtype, inplace=False)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66 +/- ##
=======================================
Coverage ? 93.80%
=======================================
Files ? 17
Lines ? 1873
Branches ? 0
=======================================
Hits ? 1757
Misses ? 116
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary by Sourcery
Unify and streamline LUT-based image processing functions by standardizing on float32 precision, consolidating dtype conversions, and simplifying per-channel processing loops.
Enhancements: