Skip to content

Downsampling OME-TIFF with PyVips and Generating Patches for Deep Learning #509

Open
@Fighting-bruceCHN

Description

@Fighting-bruceCHN

Hi,

I am currently working with a large OME-TIFF file (2_CD8.ome.tiff) that is quite high in resolution (9.59 GiB, Shape: (110319, 53873, 3)). For my downstream deep learning tasks, I need to downsample this image to a more manageable resolution.

I am using the following PyVips code to downsample:

import pyvips

def downsample_ome_tiff(input_file, output_file, downsample_factor=2):
    image = pyvips.Image.new_from_file(input_file, access="sequential")
    downsampled_image = image.resize(1.0 / downsample_factor)
    downsampled_image.write_to_file(output_file, Q=85, tile=True, pyramid=True)

input_tiff = '/path/to/2_CD8.ome.tiff'
output_tiff = '/path/to/2_CD8_downsampled.ome.tiff'
downsample_ome_tiff(input_tiff, output_tiff)

I would like to know if there are any improvements or alternative methods to downsample the OME-TIFF file. Additionally, I need guidance on how to generate patches from the downsampled image for deep learning purposes.

Thank you for your assistance!

Warm regards,
Aobo Tan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions