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

RealisticNoise default values #199

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions alodataset/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def apply(self, frame: Frame):


class RealisticNoise(AloTransform):
def __init__(self, gaussian_std: float = 0.02, shot_std: float = 0.2, *args, **kwargs):
def __init__(self, gaussian_std: float = 0.02, shot_std: float = 0.05, same_on_sequence=False, *args, **kwargs):
"""Add an approximation of a realistic noise to the image.

More precisely, we add a gaussian noise and a shot noise to the image.
Expand All @@ -606,10 +606,7 @@ def __init__(self, gaussian_std: float = 0.02, shot_std: float = 0.2, *args, **k
"""
self.gaussian_std = gaussian_std
self.shot_std = shot_std
super().__init__(*args, **kwargs)
assert (
not self.same_on_sequence and not self.same_on_frames
), "Noise should be different for all images at all time steps"
super().__init__(*args, same_on_sequence=same_on_sequence, **kwargs)

def sample_params(self):
"""No parameters to sample"""
Expand Down Expand Up @@ -664,7 +661,7 @@ def sample_params(self):
def apply(self, frame: Frame):
assert frame.normalization == "01", "frame should be normalized between 0 and 1 before color modification"

frame = frame ** self.gamma
frame = frame**self.gamma
frame = frame * self.brightness
# change color by applying different coefficients to R, G, and B channels
C = frame.shape[frame.names.index("C")]
Expand Down