Skip to content

Commit

Permalink
generate gaussian noise instead of blank images
Browse files Browse the repository at this point in the history
  • Loading branch information
mwawrzos committed Jul 15, 2024
1 parent 1ef4f71 commit ae66dc3
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ def _sample_random_positive_integer(self, mean: int, stddev: int) -> int:
break
return n

def _random_resize(self, image):
def _get_next_image(self):
width = self._sample_random_positive_integer(
self._image_width_mean, self._image_width_stddev
)
height = self._sample_random_positive_integer(
self._image_height_mean, self._image_height_stddev
)
return image.resize((width, height))

def _get_next_image(self):
return Image.new("RGB", (100, 100), color="white")
shape = width, height, 3
noise = self.rng.integers(0, 256, shape, dtype=np.uint8)
return Image.fromarray(noise)

def _encode(self, image):
buffered = BytesIO()
Expand All @@ -59,6 +58,5 @@ def _encode(self, image):

def __next__(self) -> str:
image = self._get_next_image()
image = self._random_resize(image)
base64_string = self._encode(image)
return base64_string

0 comments on commit ae66dc3

Please sign in to comment.