diff --git a/python/imagestack.py b/python/imagestack.py index 19441b1..831395f 100644 --- a/python/imagestack.py +++ b/python/imagestack.py @@ -1,7 +1,7 @@ import glob -import imageio import numpy import progressbar +import skimage.io import skimage.transform import os @@ -13,7 +13,7 @@ def load(fmask, dtype=numpy.float32): return #load the first file - I = imageio.imread(F[0]) + I = skimage.io.imread(F[0]) #generate the image stack if I.ndim == 3: @@ -24,7 +24,7 @@ def load(fmask, dtype=numpy.float32): bar = progressbar.ProgressBar(max_value=len(F)) for i in range(0, len(F)): - I = imageio.imread(F[i]) + I = skimage.io.imread(F[i]) S[i, ...] = I bar.update(i+1) @@ -41,7 +41,7 @@ def save(I, fname, extension = "bmp"): bar = progressbar.ProgressBar(max_value=I.shape[0]) #save the output files for i in range(0, I.shape[0]): - imageio.imwrite(fname + "%03d" % i + "." + extension, I[i, ...]) + skimage.io.imsave(fname + "%03d" % i + "." + extension, I[i, ...]) bar.update(i+1) #rescale a stack of images along X and Y by an integer value n and save to directory dest @@ -59,12 +59,12 @@ def resize(fmask, dest, n, outformat=None): for i in range(0, len(F)): #load the file to memory - I = imageio.imread(F[i]) + I = skimage.io.imread(F[i]) R = skimage.transform.downscale_local_mean(I, (n, n)) if outformat is None: - imageio.imwrite(dest+"/"+os.path.basename(F[i]), R) + skimage.io.imwrite(dest+"/"+os.path.basename(F[i]), R) else: - imageio.imwrite(dest+"/"+os.path.basename(F[i]).split('.')[0] + "." + outformat, R) + skimage.io.imwrite(dest+"/"+os.path.basename(F[i]).split('.')[0] + "." + outformat, R) bar.update(i+1) \ No newline at end of file diff --git a/python/muve-align.py b/python/muve-align.py index 61e435a..45816b1 100644 --- a/python/muve-align.py +++ b/python/muve-align.py @@ -12,6 +12,7 @@ import cv2 import progressbar import scipy.ndimage import sys +import os def press(event): @@ -95,22 +96,18 @@ def align(A, B, max_power=5): #warp_matrix[0, 2] = 0 # return warp_matrix -if len(sys.argv) < 3: - print("usage: muve-align input_mask output_directory") - print("ex: muve-align *.bmp ./aligned") - return - -fmask = sys.argv[1] -out_dir = sys.argv[2] +fmask = "Z:/jack/TinkParaffinLung0.005S/*.png" +out_dir = "Z:/jack/TinkParaffinLung0.005S/aligned" if not os.path.isdir(out_dir): os.mkdir(out_dir) #read the image stack for alignment print("Loading image stack...") -S = imagestack.load(fmask, dtype=numpy.float32) +S = imagestack.load(fmask, dtype=numpy.uint8) + #convert to grayscale -G = imagestack.rgb2gray(S) +G = imagestack.rgb2gray(S.astype(numpy.float32)) # Define the motion model warp_mode = cv2.MOTION_TRANSLATION -- libgit2 0.21.4