".ome.tif" to ".tif" or ".jpg"

78 Views Asked by At

I'm trying to automate some image analysis, the microscope I use takes 4 images along a well, at 5 different z locations, and spits the image out as a stack saves as ".oms.tif". I'm trying to stitch these images together so that they make one stack and I can actually analyse it. I found a package called "imgstitch" but it seems like it doesn't support ".oms.tif"; I tried to convert the files using glob.glob, but I get an error at the end of the script: OSError: cannot write mode I;16 as JPEG

Here is the code so far:

    for name in glob.glob("*ome.tif"):
        im = Image.open(name)
        name = str(name).rstrip("ome.tif")
        im.save(name + ".jpg")
    
    keyword = 'Red_'
 
    for filename in os.listdir(old_directory):
        if keyword in filename and filename.endswith(".jpg"):
            source = os.path.join(old_directory, filename)
            destination = os.path.join(new_directory, filename)
            dest = shutil.copyfile(source, destination)

    file_dir = listdir(new_directory)
    newlist = []

    for names in file_dir:
        if names.endswith(".tif"):
            newlist.append(names)
        
    
    stitch_images_and_save(new_directory, newlist, 1, new_directory)

Long story short, I either need to convert the .oms.tif files to .tif or .jpg, or I need to find a wat to be able to stitch these images together.

0

There are 0 best solutions below