Skip to content

Commit

Permalink
Fix for issue #244 where segmentation masks had incorrect random eras…
Browse files Browse the repository at this point in the history
…ing patches applied.
  • Loading branch information
mdbloice committed Mar 28, 2023
1 parent 5bd2d32 commit 587159f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions Augmentor/Operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1893,27 +1893,27 @@ def perform_operation(self, images):
PIL.Image.
"""

def do(image):
w, h = images[0].size

w, h = image.size
w_occlusion_max = int(w * self.rectangle_area)
h_occlusion_max = int(h * self.rectangle_area)

w_occlusion_max = int(w * self.rectangle_area)
h_occlusion_max = int(h * self.rectangle_area)
w_occlusion_min = int(w * 0.1)
h_occlusion_min = int(h * 0.1)

w_occlusion_min = int(w * 0.1)
h_occlusion_min = int(h * 0.1)
w_occlusion = random.randint(w_occlusion_min, w_occlusion_max)
h_occlusion = random.randint(h_occlusion_min, h_occlusion_max)

w_occlusion = random.randint(w_occlusion_min, w_occlusion_max)
h_occlusion = random.randint(h_occlusion_min, h_occlusion_max)
random_position_x = random.randint(0, w - w_occlusion)
random_position_y = random.randint(0, h - h_occlusion)

def do(image):

if len(image.getbands()) == 1:
rectangle = Image.fromarray(np.uint8(np.random.rand(w_occlusion, h_occlusion) * 255))
else:
rectangle = Image.fromarray(np.uint8(np.random.rand(w_occlusion, h_occlusion, len(image.getbands())) * 255))

random_position_x = random.randint(0, w - w_occlusion)
random_position_y = random.randint(0, h - h_occlusion)

image.paste(rectangle, (random_position_x, random_position_y))

return image
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.autodoc'
]

# Add any paths that contain templates here, relative to this directory.
Expand Down

0 comments on commit 587159f

Please sign in to comment.