Skip to content

Commit

Permalink
Always try converting to image before saving/scaling for improved per…
Browse files Browse the repository at this point in the history
…formance
  • Loading branch information
folterj committed Feb 16, 2024
1 parent 0e4eb25 commit 6a60571
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions OmeSliCC/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ def combine_images(sources: list[OmeSource], params: dict):


def get_source_image(source: OmeSource):
return source.asarray()
image = source.asarray()
image_size = image.size * image.itemsize
if image_size < psutil.virtual_memory().total:
image = np.asarray(image) # pre-computing is way faster than dask saving/scaling
return image


def get_source_image_dask(source: OmeSource, chunk_size=(10240, 10240)):
Expand Down Expand Up @@ -246,9 +250,6 @@ def save_tiff(filename: str, image: np.ndarray, metadata: dict = None, xml_metad
dimension_order: str = 'yxc',
resolution: tuple = None, resolution_unit: str = None, tile_size: tuple = None, compression: [] = None,
combine_rgb=True, pyramid_sizes_add: list = []):
image_size = image.size * image.itemsize
if image_size < psutil.virtual_memory().total:
image = np.asarray(image) # pre-computing is way faster than dask saving/scaling
x_index = dimension_order.index('x')
y_index = dimension_order.index('y')
size = image.shape[x_index], image.shape[y_index]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For support and discussion, please use the [Image.sc forum](https://forum.image.

- Import WSI files: Omero, Ome.Tiff, Tiff, Zarr, Ome.Zarr/NGFF, common slide formats, common image formats
- Export images: Tiff, Ome.Tiff, Zarr, Ome.Zarr, common image formats, thumbnails
- Integrated Dask support
- Zarr image compression (lossless/lossy)
- Image scaling using target pixel size
- Omero credentials helper
Expand Down

0 comments on commit 6a60571

Please sign in to comment.