From 1283bc3d3f8ba40bd6c77ddb7bbe750b33456647 Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Mon, 16 Jan 2023 07:49:25 -0600 Subject: [PATCH] fix(api): look up noise coordinates correctly --- api/onnx_web/image.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/api/onnx_web/image.py b/api/onnx_web/image.py index 9b0a5e4b8..21ae24ba1 100644 --- a/api/onnx_web/image.py +++ b/api/onnx_web/image.py @@ -10,6 +10,10 @@ ) +def get_pixel_index(x: int, y: int, width: int) -> int: + return (y * width) + x + + def mask_filter_none(mask_image: Image, dims: Point, origin: Point, fill='white') -> Image: width, height = dims @@ -93,7 +97,7 @@ def noise_source_uniform(source_image: Image, dims: Point, origin: Point) -> Ima for x in range(width): for y in range(height): - i = x * y + i = get_pixel_index(x, y, width) noise.putpixel((x, y), ( int(noise_r[i]), int(noise_g[i]), @@ -115,7 +119,7 @@ def noise_source_normal(source_image: Image, dims: Point, origin: Point) -> Imag for x in range(width): for y in range(height): - i = x * y + i = get_pixel_index(x, y, width) noise.putpixel((x, y), ( int(noise_r[i]), int(noise_g[i]), @@ -145,7 +149,7 @@ def noise_source_histogram(source_image: Image, dims: Point, origin: Point) -> I for x in range(width): for y in range(height): - i = x * y + i = get_pixel_index(x, y, width) noise.putpixel((x, y), ( noise_r[i], noise_g[i],