How to use the tifffile.imwrite function in tifffile

To help you get started, we’ve selected a few tifffile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeiss-microscopy / OAD / Scripts / Data_Tools / bftools.py View on Github external
p.plane_count = SizeZ * SizeT * SizeC
        p = writeOMETIFFplanes(p, SizeT=SizeT, SizeZ=SizeZ, SizeC=SizeC, order=dimorder)

        for c in range(SizeC):
            if pixeltype == 'unit8':
                p.Channel(c).SamplesPerPixel = 1
            if pixeltype == 'unit16':
                p.Channel(c).SamplesPerPixel = 2

        omexml.structured_annotations.add_original_metadata(bioformats.omexml.OM_SAMPLES_PER_PIXEL, str(SizeC))

    # Converting to omexml
    xml = omexml.to_xml()

    # write file and save OME-XML as description
    tifffile.imwrite(filepath, img6d, metadata={'axes': dimorder}, description=xml)

    return filepath
github jlevy44 / PathFlowAI / pathflowai / visualize.py View on Github external
def output_image(self, img, filename, tif=False):
		"""Output calculated image to file.

		Parameters
		----------
		img:array
			Image.
		filename:str
			Output file name.
		tif:bool
			Store in TIF format?
		"""
		if tif:
			from tifffile import imwrite
			imwrite(filename, np.array(img), photometric='rgb')
		else:
			img.save(filename)
github jlevy44 / PathFlowAI / build / lib / pathflowai / visualize.py View on Github external
def output_image(self, img, filename, tif=False):
		"""Output calculated image to file.

		Parameters
		----------
		img:array
			Image.
		filename:str
			Output file name.
		tif:bool
			Store in TIF format?
		"""
		if tif:
			from tifffile import imwrite
			imwrite(filename, np.array(img), photometric='rgb')
		else:
			img.save(filename)
github zeiss-microscopy / OAD / jupyter_notebooks / DisplayZsurface / modules / bftools.py View on Github external
p.plane_count = SizeZ * SizeT * SizeC
        p = writeOMETIFFplanes(p, SizeT=SizeT, SizeZ=SizeZ, SizeC=SizeC, order=dimorder)

        for c in range(SizeC):
            if pixeltype == 'unit8':
                p.Channel(c).SamplesPerPixel = 1
            if pixeltype == 'unit16':
                p.Channel(c).SamplesPerPixel = 2

        omexml.structured_annotations.add_original_metadata(bioformats.omexml.OM_SAMPLES_PER_PIXEL, str(SizeC))

    # Converting to omexml
    xml = omexml.to_xml()

    # write file and save OME-XML as description
    tifffile.imwrite(filepath, img6d, metadata={'axes': dimorder}, description=xml)

    return filepath
github sebi06 / BioFormatsRead / bftools.py View on Github external
p.plane_count = SizeZ * SizeT * SizeC
        p = writeOMETIFFplanes(p, SizeT=SizeT, SizeZ=SizeZ, SizeC=SizeC, order=dimorder)

        for c in range(SizeC):
            if pixeltype == 'unit8':
                p.Channel(c).SamplesPerPixel = 1
            if pixeltype == 'unit16':
                p.Channel(c).SamplesPerPixel = 2

        omexml.structured_annotations.add_original_metadata(bioformats.omexml.OM_SAMPLES_PER_PIXEL, str(SizeC))

    # Converting to omexml
    xml = omexml.to_xml()

    # write file and save OME-XML as description
    tifffile.imwrite(filepath, img6d, metadata={'axes': dimorder}, description=xml)

    return filepath
github juglab / PPN2V / scripts / predictPN2V.py View on Github external
for i in range (image.shape[0]):
        im=image[i,...]
        # processing image
        means[i,...], mseEst[i,...] = prediction.tiledPredict(im, net ,ps=args.tileSize, overlap=args.tileOvp,
                                            device=device,
                                            noiseModel=noiseModel)

    if im.shape[0]==1:
        means=means[0]
        mseEst=mseEst[0]

    outpath=args.output
    filename=os.path.basename(f).replace('.tif','_MMSE-PN2V.tif')
    outpath=os.path.join(outpath,filename)
    print('writing',outpath, mseEst.shape)
    imwrite(outpath, mseEst.astype(np.float32), imagej=True)

    outpath=args.output
    filename=os.path.basename(f).replace('.tif','_Prior-PN2V.tif')
    outpath=os.path.join(outpath,filename)
    print('writing',outpath, means.shape)
    imwrite(outpath, means.astype(np.float32), imagej=True)
github VolkerH / Lattice_Lightsheet_Deskew_Deconv / lls_dd / utils.py View on Github external
def write_tiff_createfolder(path: Union[str, pathlib.Path], nparray: np.ndarray, **opt_kwargs):
    """ 
    given a
    path: to a tiff file of type pathlib.Path (or str), and
    nparray: numpy array holding an image/volume
    
    creates all necessary folders in the path (in case they don't exist already)
    and writes the numpy array as a tiff
    """
    if not isinstance(path, pathlib.Path):
        path = pathlib.Path(path)
    path.parent.mkdir(parents=True, exist_ok=True)
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        tifffile.imwrite(str(path), nparray, **opt_kwargs)
        #imsave(str(path), nparray, **opt_kwargs) #