Skip to content

Commit

Permalink
Add arguments for flipping output mosaic image (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu-AnChen authored Jun 4, 2021
1 parent f73a8fd commit 2587ea6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ optional arguments:
unusual microscope configurations
--flip-y flip tile positions top-to-bottom to account for
unusual microscope configurations
--flip-mosaic-x flip output image horizontally
--flip-mosaic-y flip output image vertically
--output-channels [CHANNEL [CHANNEL ...]]
output only channels listed in CHANNELS; numbering
starts at 0
Expand Down
10 changes: 8 additions & 2 deletions ashlar/reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,13 +970,15 @@ class Mosaic(object):

def __init__(
self, aligner, shape, filename_format, channels=None,
ffp_path=None, dfp_path=None, combined=False, tile_size=None,
first=False, verbose=False
ffp_path=None, dfp_path=None, flip_mosaic_x=False, flip_mosaic_y=False,
combined=False, tile_size=None, first=False, verbose=False
):
self.aligner = aligner
self.shape = tuple(shape)
self.filename_format = filename_format
self.channels = self._sanitize_channels(channels)
self.flip_mosaic_x = flip_mosaic_x
self.flip_mosaic_y = flip_mosaic_y
self.combined = combined
self.tile_size = tile_size
self.first = first
Expand Down Expand Up @@ -1100,6 +1102,10 @@ def run(self, mode='write', debug=False):
mi_flat[p:p+w] = skimage.exposure.adjust_gamma(
mi_flat[p:p+w], 1/2.2
)
if self.flip_mosaic_x:
mosaic_image = np.fliplr(mosaic_image)
if self.flip_mosaic_y:
mosaic_image = np.flipud(mosaic_image)
if self.verbose:
print()
if mode == 'write':
Expand Down
10 changes: 10 additions & 0 deletions ashlar/scripts/ashlar.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def main(argv=sys.argv):
help=('flip tile positions top-to-bottom to account for unusual'
' microscope configurations')
)
parser.add_argument(
'--flip-mosaic-x', default=False, action='store_true',
help=('flip output image horizontally')
)
parser.add_argument(
'--flip-mosaic-y', default=False, action='store_true',
help=('flip output image vertically')
)
parser.add_argument(
'--output-channels', nargs='*', type=int, metavar='CHANNEL',
help=('output only channels listed in CHANNELS; numbering starts at 0')
Expand Down Expand Up @@ -158,6 +166,8 @@ def main(argv=sys.argv):
mosaic_args['tile_size'] = args.tile_size
if args.quiet is False:
mosaic_args['verbose'] = True
mosaic_args['flip_mosaic_x'] = args.flip_mosaic_x
mosaic_args['flip_mosaic_y'] = args.flip_mosaic_y

try:
if args.plates:
Expand Down

0 comments on commit 2587ea6

Please sign in to comment.