Skip to content
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

Update sharpen #2150

Merged
merged 3 commits into from
Nov 18, 2024
Merged

Update sharpen #2150

merged 3 commits into from
Nov 18, 2024

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Nov 18, 2024

Addresses: #2110

Summary by Sourcery

Enhance the Sharpen transform by adding support for a Gaussian interpolation method alongside the existing kernel-based method. Update the transform's parameters to accommodate the new method, including options for kernel size and sigma. Implement a new function, sharpen_gaussian, to apply the Gaussian sharpening technique.

New Features:

  • Introduce a new sharpening method using Gaussian interpolation in the Sharpen transform.

Enhancements:

  • Refactor the Sharpen transform to support multiple sharpening methods, including kernel-based and Gaussian interpolation.

Copy link
Contributor

sourcery-ai bot commented Nov 18, 2024

Reviewer's Guide by Sourcery

This PR enhances the Sharpen transform by introducing two different sharpening methods: a traditional kernel-based approach using Laplacian operator and a new Gaussian interpolation method. The implementation includes updated parameters, improved documentation, and a new functional method for Gaussian sharpening.

Updated class diagram for Sharpen transform

classDiagram
    class Sharpen {
        +tuple[float, float] alpha
        +tuple[float, float] lightness
        +Literal["kernel", "gaussian"] method
        +int kernel_size
        +float sigma
        +get_params() dict[str, Any]
        +apply(np.ndarray img, float alpha, np.ndarray|None sharpening_matrix, **params) np.ndarray
        +get_transform_init_args_names() tuple[str, ...]
    }
    note for Sharpen "Added method, kernel_size, and sigma attributes. Updated apply and get_params methods."
Loading

File-Level Changes

Change Details Files
Added a new Gaussian interpolation sharpening method alongside the existing kernel-based approach
  • Added 'method' parameter to select between 'kernel' and 'gaussian' approaches
  • Introduced new parameters 'kernel_size' and 'sigma' for Gaussian method
  • Updated get_params() to handle both sharpening methods
  • Modified apply() to support both sharpening implementations
albumentations/augmentations/transforms.py
Implemented new Gaussian sharpening functionality
  • Added sharpen_gaussian function using OpenCV's GaussianBlur
  • Implemented weighted addition of original and blurred images
albumentations/augmentations/functional.py
Enhanced documentation and validation
  • Added comprehensive mathematical formulations for both sharpening methods
  • Updated docstring with detailed explanations and examples
  • Added validation for kernel size to ensure odd values
  • Expanded references section with relevant literature
albumentations/augmentations/transforms.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ternaus - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

albumentations/augmentations/transforms.py Show resolved Hide resolved
albumentations/augmentations/transforms.py Show resolved Hide resolved
Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 81.48148% with 5 lines in your changes missing coverage. Please review.

Project coverage is 90.16%. Comparing base (b1a79c2) to head (e2c1c73).
Report is 282 commits behind head on main.

Files with missing lines Patch % Lines
albumentations/augmentations/transforms.py 86.95% 3 Missing ⚠️
albumentations/augmentations/functional.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main    #2150       +/-   ##
=========================================
+ Coverage      0   90.16%   +90.16%     
=========================================
  Files         0       48       +48     
  Lines         0     8267     +8267     
=========================================
+ Hits          0     7454     +7454     
- Misses        0      813      +813     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ternaus ternaus merged commit 348ae35 into main Nov 18, 2024
16 checks passed
@ternaus ternaus deleted the update_sharpen branch November 18, 2024 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant