示例#1
0
def test_OmeTiffWriter_compare_tile_plane_rgb_nl_large(tmp_path):
    im_array = da.from_array(
        np.random.randint(0, 255, (2**13, 2**13, 3), dtype=np.uint8),
        chunks=(1024, 1024, 3),
    )
    reg_image = reg_image_loader(im_array, 0.5)

    rts = RegTransformSeq(TFORM_FP)
    ometiffwriter = OmeTiffWriter(reg_image, reg_transform_seq=rts)
    ometiletiffwriter = OmeTiffTiledWriter(reg_image, reg_transform_seq=rts)

    by_tile_fp = ometiletiffwriter.write_image_by_tile(
        gen_project_name_str(),
        output_dir=str(tmp_path),
    )

    by_plane_fp = ometiffwriter.write_image_by_plane(
        gen_project_name_str(),
        output_dir=str(tmp_path),
    )

    im_tile = imread(by_tile_fp)
    im_plane = imread(by_plane_fp)

    assert np.array_equal(im_tile, im_plane)
示例#2
0
def test_OmeTiffWriter_compare_tile_plane_rgb_nl(
    simple_transform_affine_nl, tmp_path
):
    reg_image = reg_image_loader(
        np.random.randint(0, 255, (1024, 1024, 3), dtype=np.uint8), 1
    )

    rts = RegTransformSeq(simple_transform_affine_nl)
    ometiffwriter = OmeTiffWriter(reg_image, reg_transform_seq=rts)
    ometiletiffwriter = OmeTiffTiledWriter(reg_image, reg_transform_seq=rts)

    by_tile_fp = ometiletiffwriter.write_image_by_tile(
        gen_project_name_str(),
        output_dir=str(tmp_path),
    )

    by_plane_fp = ometiffwriter.write_image_by_plane(
        gen_project_name_str(),
        output_dir=str(tmp_path),
    )

    im_tile = imread(by_tile_fp)
    im_plane = imread(by_plane_fp)

    assert np.array_equal(im_tile, im_plane)
示例#3
0
def test_OmeTiffWriter_by_tile(complex_transform, tmp_path):
    reg_image = reg_image_loader(np.ones((4096, 4096), dtype=np.uint8), 0.5)
    rts = RegTransformSeq(complex_transform)

    ometiffwriter = OmeTiffTiledWriter(reg_image, reg_transform_seq=rts)

    by_tile_fp = ometiffwriter.write_image_by_tile(
        gen_project_name_str(),
        output_dir=str(tmp_path),
        zarr_temp_dir=tmp_path,
    )
    by_tile_image = reg_image_loader(by_tile_fp, 2)
    assert by_tile_image.shape == (1, 1024, 1024)
示例#4
0
def test_OmeTiffWriter_compare_tile_plane(simple_transform_affine, tmp_path):
    reg_image = reg_image_loader(np.ones((1024, 1024), dtype=np.uint8), 1)
    rts = RegTransformSeq(simple_transform_affine)
    ometifftilewriter = OmeTiffTiledWriter(reg_image, reg_transform_seq=rts)
    ometiffwriter = OmeTiffWriter(reg_image, reg_transform_seq=rts)

    by_tile_fp = ometifftilewriter.write_image_by_tile(
        gen_project_name_str(),
        output_dir=str(tmp_path),
        zarr_temp_dir=tmp_path,
    )
    by_tile_image = reg_image_loader(by_tile_fp, 2)

    by_plane_fp = ometiffwriter.write_image_by_plane(
        gen_project_name_str(),
        output_dir=str(tmp_path),
    )
    by_plane_image = reg_image_loader(by_plane_fp, 2)

    ch0_im_tile = by_tile_image.read_single_channel(0)
    ch0_im_plane = by_plane_image.read_single_channel(0)

    assert by_plane_image.shape == by_tile_image.shape
    assert np.array_equal(ch0_im_tile, ch0_im_plane)