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

Add plasmashadow #2153

Merged
merged 3 commits into from
Nov 18, 2024
Merged

Add plasmashadow #2153

merged 3 commits into from
Nov 18, 2024

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Nov 18, 2024

Adresses: #2105

Summary by Sourcery

Add the PlasmaShadow transformation to apply organic-looking shadow effects using plasma fractal noise patterns, update documentation, and include tests for the new feature.

New Features:

  • Introduce the PlasmaShadow transformation, which applies a plasma-based shadow effect to images, creating organic-looking shadows using a fractal noise pattern.

Enhancements:

  • Refactor the order of parameters in the constructor of several transformations to ensure consistency.

Documentation:

  • Add documentation for the new PlasmaShadow transformation in the README file, including a link to its detailed description.

Tests:

  • Add a test case for the new PlasmaShadow transformation in the augmentation definitions test suite.

Copy link
Contributor

sourcery-ai bot commented Nov 18, 2024

Reviewer's Guide by Sourcery

This PR introduces a new image augmentation transform called PlasmaShadow that creates organic-looking shadows using plasma fractal noise patterns. The implementation follows the existing pattern of other transforms in the codebase and includes comprehensive documentation, parameter validation, and integration with the existing augmentation framework.

Sequence diagram for applying PlasmaShadow

sequenceDiagram
    participant User
    participant PlasmaShadow
    participant fmain
    User->>PlasmaShadow: Call apply(img, intensity, plasma_pattern)
    PlasmaShadow->>fmain: Call apply_plasma_shadow(img, intensity, plasma_pattern)
    fmain-->>PlasmaShadow: Return shadowed image
    PlasmaShadow-->>User: Return shadowed image
Loading

Class diagram for the new PlasmaShadow transform

classDiagram
    class PlasmaShadow {
        +tuple[float, float] shadow_intensity
        +int plasma_size
        +float roughness
        +float p
        +bool|None always_apply
        +get_params_dependent_on_data(params: dict[str, Any], data: dict[str, Any]) dict[str, Any]
        +apply(img: np.ndarray, intensity: float, plasma_pattern: np.ndarray, **params: Any) np.ndarray
        +get_transform_init_args_names() tuple[str, ...]
    }
    PlasmaShadow --|> ImageOnlyTransform
    class ImageOnlyTransform {
        <<abstract>>
    }
Loading

File-Level Changes

Change Details Files
Added new PlasmaShadow transform class for creating organic shadow effects
  • Implemented PlasmaShadow class with configurable shadow intensity, plasma size, and roughness parameters
  • Added parameter validation using InitSchema
  • Created apply_plasma_shadow function for the actual shadow effect implementation
  • Added comprehensive docstring with mathematical formulation and usage examples
albumentations/augmentations/transforms.py
Added functional implementation for plasma shadow effect
  • Implemented apply_plasma_shadow function with clipping decorator
  • Added shadow mask calculation using plasma pattern
albumentations/augmentations/functional.py
Standardized parameter ordering in transform classes
  • Reordered p and always_apply parameters to maintain consistency across transforms
  • Fixed parameter order in super() calls
albumentations/augmentations/transforms.py
Updated documentation and tests
  • Added PlasmaShadow to the list of available transforms in README.md
  • Added PlasmaShadow to the test definitions
README.md
tests/aug_definitions.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: 1 issue found
  • 🟡 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/functional.py Outdated Show resolved Hide resolved
tests/aug_definitions.py Show resolved Hide resolved
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

All modified and coverable lines are covered by tests ✅

Project coverage is 90.33%. Comparing base (b1a79c2) to head (ee6b6ed).
Report is 285 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##           main    #2153       +/-   ##
=========================================
+ Coverage      0   90.33%   +90.33%     
=========================================
  Files         0       48       +48     
  Lines         0     8391     +8391     
=========================================
+ Hits          0     7580     +7580     
- Misses        0      811      +811     

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

@ternaus ternaus merged commit 8ffd89d into main Nov 18, 2024
16 checks passed
@ternaus ternaus deleted the add_plasmashadow branch November 18, 2024 13:55
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