示例#1
0
    def __init__(self, input_file):

        self.input_file = input_file

        render_context = softwarerendercontext.SoftwareRenderContext()
        render_backend = softwarerenderbackend.SoftwareRenderBackend()

        self.pixel_engine = pixelengine.PixelEngine(render_backend,
                                                    render_context)
        self.pixel_engine["in"].open(input_file)

        self.num_levels = self.pixel_engine["in"].numLevels()
示例#2
0
    def __init__(self, tile_width, tile_height, resolutions, max_workers,
                 batch_size, fill_color, nested, input_path, output_path):
        self.tile_width = tile_width
        self.tile_height = tile_height
        self.resolutions = resolutions
        self.max_workers = max_workers
        self.batch_size = batch_size
        self.fill_color = fill_color
        self.nested = nested
        self.input_path = input_path
        self.slide_directory = output_path

        render_context = softwarerendercontext.SoftwareRenderContext()
        render_backend = softwarerenderbackend.SoftwareRenderBackend()

        self.pixel_engine = pixelengine.PixelEngine(render_backend,
                                                    render_context)
        self.pixel_engine["in"].open(input_path, "ficom")
        self.sdk_v1 = hasattr(self.pixel_engine["in"], "BARCODE")
示例#3
0
    def __init__(self, tile_width, tile_height, resolutions, file_type,
                 max_workers, batch_size, input_path, output_path):
        self.tile_width = tile_width
        self.tile_height = tile_height
        self.resolutions = resolutions
        self.file_type = file_type
        self.max_workers = max_workers
        self.batch_size = batch_size
        self.input_path = input_path
        self.slide_directory = output_path

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

        render_context = softwarerendercontext.SoftwareRenderContext()
        render_backend = softwarerenderbackend.SoftwareRenderBackend()

        self.pixel_engine = pixelengine.PixelEngine(render_backend,
                                                    render_context)
        self.pixel_engine["in"].open(input_path, "ficom")
示例#4
0
def main():
    """
    Main Method
    :return: None
    """
    parser = argparse.ArgumentParser()

    parser.add_argument("-i", "--input", dest='input', help="Image File")

    parser.add_argument("-t",
                        "--tif",
                        dest="tif",
                        choices=['TIFF', 'BIGTIFF'],
                        default="BIGTIFF",
                        help="TIFF/BIGTIFF")

    parser.add_argument("-s",
                        "--sparse",
                        dest='sparse',
                        type=bool,
                        default=False,
                        help="If the image should be sparse or not")
    parser.add_argument("-l",
                        "--startlevel",
                        dest='startlevel',
                        type=int,
                        default=0,
                        help="Level at which to do the conversion")

    args = parser.parse_args()

    # Initializing the pixel engine
    render_context = softwarerendercontext.SoftwareRenderContext()
    render_backend = softwarerenderbackend.SoftwareRenderBackend()
    pixel_engine = pixelengine.PixelEngine(render_backend, render_context)
    pixel_engine["in"].open(args.input)
    start_level = int(args.startlevel)
    if args.tif == 'BIGTIFF':
        tiff_type = 1
    else:
        tiff_type = 0
    sparse = int(args.sparse)
    if not (0 <= sparse <= 1 and 0 <= tiff_type <= 1):
        print("Invalid arguments passed")
        return
    tiff_file_handle = get_tiff_handle(tiff_type, args.input, sparse)

    num_levels = pixel_engine["in"].numLevels()
    if 0 <= start_level < num_levels:
        print("Generating TIFF, Please Wait.....")
        result = create_tiff_from_isyntax(pixel_engine, tiff_file_handle,
                                          start_level, int(num_levels), sparse)
        # Close the TIFF file handle.
        LIBTIFF.TIFFClose(tiff_file_handle)
        if result == 0:
            print("TIFF Successfully Generated")
        else:
            print("Error in generating TIFF")
    else:
        print("Invalid start_level Input")
    pixel_engine["in"].close()