Skip to content

Commit

Permalink
Merge pull request #577 from aleju/jigsaw_seed
Browse files Browse the repository at this point in the history
Rename 'random_state' to 'seed' in generate_jigsaw_destinations()
  • Loading branch information
aleju committed Jan 15, 2020
2 parents feecdc7 + 8e23022 commit 01b0203
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion changelogs/master/added/20191027_jigsaw.md
@@ -1,4 +1,4 @@
# Jigsaw Augmenter #476
# Jigsaw Augmenter #476 #577

* Added function `imgaug.augmenters.geometric.apply_jigsaw()`.
* Added function `imgaug.augmenters.geometric.apply_jigsaw_to_coords()`.
Expand Down
2 changes: 1 addition & 1 deletion checks/check_jigsaw.py
Expand Up @@ -26,7 +26,7 @@ def main():
)
print("Time to generate 128x dest:", gen_time)

destinations = iaa.generate_jigsaw_destinations(10, 10, 1, random_state=1)
destinations = iaa.generate_jigsaw_destinations(10, 10, 1, seed=1)
image_jig = iaa.apply_jigsaw(image, destinations)
ia.imshow(image_jig)

Expand Down
11 changes: 6 additions & 5 deletions imgaug/augmenters/geometric.py
Expand Up @@ -505,7 +505,7 @@ def apply_jigsaw_to_coords(coords, destinations, image_shape):
return result


def generate_jigsaw_destinations(nb_rows, nb_cols, max_steps, random_state,
def generate_jigsaw_destinations(nb_rows, nb_cols, max_steps, seed,
connectivity=4):
"""Generate a destination pattern for :func:`apply_jigsaw`.
Expand All @@ -520,8 +520,9 @@ def generate_jigsaw_destinations(nb_rows, nb_cols, max_steps, random_state,
max_steps : int
Maximum number of cells that each cell may be moved.
random_state : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState
RNG or seed to use. If ``None`` the global RNG will be used.
seed : None or int or imgaug.random.RNG or numpy.random.Generator or numpy.random.BitGenerator or numpy.random.SeedSequence or numpy.random.RandomState
Seed value or alternatively RNG to use.
If ``None`` the global RNG will be used.
connectivity : int, optional
Whether a diagonal move of a cell counts as one step
Expand All @@ -536,7 +537,7 @@ def generate_jigsaw_destinations(nb_rows, nb_cols, max_steps, random_state,
"""
assert connectivity in (4, 8), (
"Expected connectivity of 4 or 8, got %d." % (connectivity,))
random_state = iarandom.RNG(random_state)
random_state = iarandom.RNG(seed)
steps = random_state.integers(0, max_steps, size=(nb_rows, nb_cols),
endpoint=True)
directions = random_state.integers(0, connectivity,
Expand Down Expand Up @@ -5680,7 +5681,7 @@ def _draw_samples(self, batch, random_state):
destinations.append(
generate_jigsaw_destinations(
nb_rows[i], nb_cols[i], max_steps[i],
random_state=random_state)
seed=random_state)
)

samples = _JigsawSamples(nb_rows, nb_cols, max_steps, destinations)
Expand Down

0 comments on commit 01b0203

Please sign in to comment.