-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix salt and pepper #2328
Fix salt and pepper #2328
Conversation
Reviewer's Guide by SourceryThis pull request introduces a fix to the SaltAndPepper augmentation, addressing issues with incorrect noise application and ensuring proper handling of different image types. The changes include modifications to the mask generation logic and the application of noise to the image. Sequence diagram for improved Salt and Pepper noise applicationsequenceDiagram
participant Transform as SaltAndPepper Transform
participant Params as Parameter Generation
participant Noise as Noise Application
participant Image as Image Data
Transform->>Image: Get image dimensions
Image-->>Transform: Return height, width
Transform->>Params: Generate noise parameters
Params-->>Transform: Return total_amount and salt_ratio
Transform->>Noise: Generate noise positions
Noise->>Noise: Create salt and pepper masks
Noise-->>Transform: Return masks
Transform->>Image: Apply salt and pepper noise
Note over Image: Handle multi-channel images
Image-->>Transform: Return modified image
Flow diagram for Salt and Pepper noise generationflowchart TD
A[Get image dimensions] --> B[Calculate area]
B --> C[Generate noise parameters]
C --> D[Calculate number of pixels]
D --> E[Generate noise positions]
E --> F[Create salt mask]
E --> G[Create pepper mask]
F & G --> H[Reshape masks to 2D]
H --> I[Apply masks to image]
I --> J{Is image 3D?}
J -->|Yes| K[Expand masks to match channels]
J -->|No| L[Apply directly]
K & L --> M[Return modified image]
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.
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: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Summary by Sourcery
Tests:
SaltAndPepper
transform to verify correct application and expected behavior with different image types (uint8, float32, single-channel).