0

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.

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
AndSS
  • 11
  • 1
  • The error suggests the images are 16-bit which you cannot save in an 8-bit JPEG. As PNG format supports 16-bit, maybe that is an option? – Mark Setchell Mar 07 '23 at 22:30
  • you might try the stitching package. It relies on opencv which should be capable of reading your tifs – Lukas Weber Mar 09 '23 at 06:32

0 Answers0