Skip to content

Questions about some codes #26

Description

@cxy2333-hue

In your code:
` def add_noise(self, img: mge.Tensor) -> Tuple[mge.Tensor, float]:
"""
Args:
- img: [-black, camera_value_scale]

    Returns:
        - noisy_img
        - iso
    """

    N = img.shape[0]
    isos = np.random.uniform(*self.opts.iso_range, size=(N, ))
    k, b = self.noise_func(isos, value_scale=self.opts.camera_value_scale)
    k = k.reshape(-1, 1, 1, 1)
    b = b.reshape(-1, 1, 1, 1)

    shot_noisy = megengine.random.poisson((img / k).clip(0, 1)) * k
    read_noisy = megengine.random.normal(size=img.shape) * math.sqrt(b)
    noisy = shot_noisy + read_noisy
    noisy = F.round(noisy)

    return noisy

It seems that clip(0,1) should not be used in the codeshot_noisy = megengine.random.poisson((img / k).clip(0, 1)) * k`, since most of (img / k)'s range is not between 0 and 1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions