generate noise channel-wise
This commit is contained in:
parent
0b46ce4090
commit
e9620fd62e
|
@ -26,13 +26,9 @@ def blend_source_histogram(source_image: Image, dims: Tuple[int, int], sigma = 2
|
|||
stats = ImageStat.Stat(source_image)
|
||||
sum_r, sum_g, sum_b = stats.sum
|
||||
|
||||
rng_r = random.choice(256, p=np.divide(np.copy(hist_r), sum_r))
|
||||
rng_g = random.choice(256, p=np.divide(np.copy(hist_g), sum_g))
|
||||
rng_b = random.choice(256, p=np.divide(np.copy(hist_b), sum_b))
|
||||
|
||||
noise_r = rng_r.integers(0, size=width * height)
|
||||
noise_g = rng_g.integers(0, size=width * height)
|
||||
noise_b = rng_b.integers(0, size=width * height)
|
||||
noise_r = random.choice(256, p=np.divide(np.copy(hist_r), sum_r), size=width*height)
|
||||
noise_g = random.choice(256, p=np.divide(np.copy(hist_g), sum_g), size=width*height)
|
||||
noise_b = random.choice(256, p=np.divide(np.copy(hist_b), sum_b), size=width*height)
|
||||
|
||||
noise = Image.fromarray(zip(noise_r, noise_g, noise_b))
|
||||
|
||||
|
|
Loading…
Reference in New Issue