Skip to content

Commit

Permalink
fix(api): look up noise coordinates correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 16, 2023
1 parent 604cdf3 commit 1283bc3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions api/onnx_web/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]),
Expand All @@ -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]),
Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit 1283bc3

Please sign in to comment.