[Python] Saving .tif Image Incorrectly using Python3 and imageio

Discussão em 'Python' iniciado por Stack, Agosto 14, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to save an altered z-stack .tif file in Python3. Here's my code where I checked that the the functions worked as intended.

    #libraries
    import imageio as ii

    #import initial image
    fname='101_nuc1syg1.tif'
    adata = ii.volread(fname)

    #check to make sure volread works
    ii.volsave('temp.tif', adata)



    Which results in this:

    [​IMG]

    And now when I try to do a simple threshold, using the following code:

    #now doing very simple thresholding
    bdata = adata < adata[0].mean()

    bdata = bdata +0

    ii.volsave('temp.tif', bdata)


    I get this:

    [​IMG]

    Any idea how to save a tif file properly after performing image operators on it?

    EDIT: Note that I am able to extract each stack and save them as separate .png files, but I would prefer to have them as a single .tif file.

    Data from: https://www.nature.com/articles/s41467-020-15987-2

    Continue reading...

Compartilhe esta Página