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

Feature/flexible sunflare brightness #2183

Merged

Conversation

momincks
Copy link
Contributor

@momincks momincks commented Dec 10, 2024

fix #2067

My approach is to find the weighted brightness from the flare circles and use it to define the max alpha (max brightness) of the spots. The brighter and larger the flare circles, the brighter the spots will be. Max alpha could still be high (>0.8), meaning blocking the object behind it, but for alpha currently in range (0.05, 0.2), max alpha will mostly be around 0.5-0.7.

That should give a more natural look at the whole effect.



RandomSunFlare(
flare_roi=[0,0,1,0.5],
src_radius=400,
src_color=[255,255,255],
angle_range=[0,1],
num_flare_circles_range=[6,10],
method="overlay",
p=1))

Summary by Sourcery

New Features:

  • Introduce a flexible sunflare brightness feature that adjusts the maximum alpha of flare spots based on the weighted brightness and size of flare circles.

Copy link
Contributor

sourcery-ai bot commented Dec 10, 2024

Reviewer's Guide by Sourcery

This PR implements a flexible sunflare brightness effect by calculating a weighted brightness based on flare circles' properties. The implementation modifies the alpha calculation for sun flare spots to create a more natural-looking effect where the brightness of spots correlates with the size and intensity of flare circles.

Class diagram for Sun Flare Brightness Calculation

classDiagram
    class SunFlareOverlay {
        +add_sun_flare_overlay(img, circles, flare_center, src_radius)
        +calculate_weighted_brightness(circles)
        +calculate_max_alpha(weighted_brightness, total_radius_length)
    }

    SunFlareOverlay : float weighted_brightness
    SunFlareOverlay : float total_radius_length
    SunFlareOverlay : float max_alpha

    note for SunFlareOverlay "This class handles the calculation of sun flare brightness using weighted brightness and max alpha."
Loading

File-Level Changes

Change Details Files
Implemented dynamic brightness calculation for sun flare effect
  • Added weighted brightness calculation based on flare circles' alpha and radius
  • Introduced total radius length tracking for normalization
  • Modified alpha calculation to use weighted brightness for maximum value
  • Added scaling factor of 5 to maintain reasonable brightness levels
  • Implemented capping of maximum alpha to 1.0
albumentations/augmentations/functional.py

Assessment against linked issues

Issue Objective Addressed Explanation
#2067 Add transparency/reduce opacity of the sun flare effect so it doesn't completely obscure objects behind it

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 @momincks - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 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.

@ternaus
Copy link
Collaborator

ternaus commented Dec 11, 2024

@momincks Thanks for the PR.

In order to merge the PR you need to use pre-commit hook on your code. https://github.com/albumentations-team/albumentations/blob/main/docs/contributing/coding_guidelines.md#pre-commit-hooks

@ternaus ternaus merged commit f83b98e into albumentations-team:main Dec 11, 2024
14 checks passed
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.

[RandomSunFlare] Add transparency to RandomSunFlare
2 participants