Skip to content

Commit d76fbcc

Browse files
authored
Merge pull request #24 from melissalinkert/fill-color
Add --fill_color option to change the color of missing tiles
2 parents 9f0478e + 256da9e commit d76fbcc

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ Use of a n5 (the default) or zarr `--file_type` will result in losslessly
3131
compressed output. These are the only formats that are currently
3232
supported by the downstream `raw2ometiff`.
3333

34+
## Background color
35+
36+
Any missing tiles are filled with 0 by default, which displays as black.
37+
The fill value can be changed using the `--fill_color` option, which accepts
38+
a single integer between 0 and 255 inclusive. Setting `--fill_color=255`
39+
will cause any missing tiles to display as white.
40+
3441
## Performance
3542

3643
This package is __highly__ sensitive to underlying hardware as well as

isyntax2raw/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class WriteTiles(object):
8080

8181
def __init__(
8282
self, tile_width, tile_height, resolutions, file_type, max_workers,
83-
batch_size, input_path, output_path
83+
batch_size, input_path, output_path, fill_color
8484
):
8585
self.tile_width = tile_width
8686
self.tile_height = tile_height
@@ -90,6 +90,7 @@ def __init__(
9090
self.batch_size = batch_size
9191
self.input_path = input_path
9292
self.slide_directory = output_path
93+
self.fill_color = fill_color
9394

9495
os.makedirs(self.slide_directory, exist_ok=True)
9596

@@ -576,7 +577,7 @@ def write_tile(
576577
request_regions = image.source_view.request_regions
577578
regions = request_regions(
578579
patches[i:i + self.batch_size], envelopes, True,
579-
[0, 0, 0]
580+
[self.fill_color] * 3
580581
)
581582
while regions:
582583
regions_ready = self.wait_any(regions)

isyntax2raw/cli/isyntax2raw.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ def cli():
4545
"--batch_size", default=250, type=int, show_default=True,
4646
help="number of patches fed into the iSyntax SDK at one time"
4747
)
48+
@click.option(
49+
"--fill_color", type=click.IntRange(min=0, max=255), default=0,
50+
show_default=True,
51+
help="background color for missing tiles (0-255)"
52+
)
4853
@click.option(
4954
"--debug", is_flag=True,
5055
help="enable debugging",
@@ -53,7 +58,7 @@ def cli():
5358
@click.argument("output_path")
5459
def write_tiles(
5560
tile_width, tile_height, resolutions, file_type, max_workers, batch_size,
56-
input_path, output_path, debug
61+
input_path, output_path, fill_color, debug
5762
):
5863
level = logging.INFO
5964
if debug:
@@ -65,7 +70,7 @@ def write_tiles(
6570
)
6671
with WriteTiles(
6772
tile_width, tile_height, resolutions, file_type, max_workers,
68-
batch_size, input_path, output_path
73+
batch_size, input_path, output_path, fill_color
6974
) as wt:
7075
wt.write_metadata()
7176
wt.write_label_image()

0 commit comments

Comments
 (0)