Skip to content

Commit

Permalink
add function to perform every augmentation function
Browse files Browse the repository at this point in the history
  • Loading branch information
Henley13 committed Apr 16, 2021
1 parent a901bd8 commit e3932ca
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bigfish/stack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@

from .augmentation import augment_2d
from .augmentation import augment_2d_function
from .augmentation import augment_8_times

from .quality import compute_snr_spots
from .quality import compute_focus
Expand Down Expand Up @@ -167,7 +168,8 @@

_augmentation = [
"augment_2d",
"augment_2d_function"]
"augment_2d_function",
"augment_8_times"]

_quality = [
"compute_snr_spots",
Expand Down
35 changes: 34 additions & 1 deletion bigfish/stack/augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def augment_2d(image):
Parameters
----------
image : np.ndarray
Image to augment with shape (y, x, channels).
Image to augment with shape (y, x, channels) or (y, x, channels).
Returns
-------
Expand Down Expand Up @@ -70,6 +70,39 @@ def augment_2d_function(identity=False):
return random_operation


def augment_8_times(image):
"""Apply every transformation to a 2-d image.
Parameters
----------
image : np.ndarray
Image to augment with shape (y, x, channels).
Returns
-------
images_augmented : List[np.ndarray]
List of images augmented with shape (y, x, channels).
"""
# check input image
check_parameter(image=np.ndarray)
check_array(image, ndim=[2, 3])

# initialization
images_augmented = []

# apply all operators
operations = [_identity,
_flip_h, _flip_v,
_transpose, _transpose_inverse,
_rotation_90, _rotation_180, _rotation_270]
for operation in operations:
augmented_image = operation(image)
images_augmented.append(augmented_image)

return images_augmented


def _identity(image):
"""Do not apply any operation to the image.
Expand Down

0 comments on commit e3932ca

Please sign in to comment.