I had a look for duplicates but I'm not sure similar questions had the answer...
I'm using tifffile in Python to read a multipage tiff (16 bit), take the first channel page/channel, blur it and save it as a 16 bit tiff.
import os
import matplotlib.pyplot as plt
import tifffile as tiff
from scipy import misc
tiff_list = []
for i in files_list[0]:
tiff_list.append(tiff.imread('/filepath_to_tiff_folder/'+i))
blurred_list = []
for i in tiff_list:
blurred_list.append(ndimage.gaussian_filter(i[0], sigma=3))
for i,v in enumerate(blurred_list):
misc.imsave('/filepath/testblur2/'+str(files_list[0][i])+'_Brightfield_Blur.tif', v)
Here, files_list
is just a list of the file names of the tiffs.
The above code works absolutely fine for blurring and saving the tiff, but it saves it as 8 bit instead.
Is there something in the above I can add to keep it 16 bit or do I have to use another method?
You are using scipy, not tifffile, to save the images.
Use tifffile.imsave to save 16-bit images, eg:
from glob import glob
from scipy import ndimage
from tifffile import imread, imsave
for filename in glob('*.tif'):
i = imread(filename)
i = ndimage.gaussian_filter(i[0], sigma=3)
imsave('blurred_' + filename, i)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.