1
0
Fork 0

generate noise channel-wise

This commit is contained in:
Sean Sube 2023-01-14 15:34:57 -06:00
parent 0b46ce4090
commit e9620fd62e
1 changed files with 3 additions and 7 deletions

View File

@ -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))