Skip to content
Snippets Groups Projects
Commit a58f3f33 authored by Andrey Aristov's avatar Andrey Aristov
Browse files

registration routines

parent 8062e7cc
No related branches found
No related tags found
1 merge request!5fix testing and stuff
from tifffile import imread, imwrite
import matplotlib.pyplot as plt
import imreg_dft as reg
import numpy as np
import scipy.ndimage as ndi
def calculate_padding(image, template):
shi = np.array(image.shape)
sht = np.array(template.shape)
dif = shi - sht
mid = dif // 2
rest = dif - mid
return (tuple((mid[0], rest[0])), tuple((mid[1],rest[1])))
def pad_template(image, template, padding=None):
if padding is None:
padding = calculate_padding(image, template)
padded_template = np.pad(template, padding, 'median')
return padded_template
def unpad_image(image, template=None, padding=None):
if padding is None:
padding = calculate_padding(image, template)
return image[padding[0][0]:-padding[0][1], padding[1][0]:-padding[1][1]]
def scale_tvec(tvec, scale=8):
tvec_8x = tvec.copy()
tvec_8x['tvec'] = tvec['tvec'] * scale
try:
tvec_8x['timg'] = None
except KeyError:
pass
finally:
return tvec_8x
def transform(image, tvec):
fluo = reg.transform_img_dict(image, tvec)
return fluo.astype('uint')
\ No newline at end of file
...@@ -12,3 +12,4 @@ seaborn ...@@ -12,3 +12,4 @@ seaborn
statannot statannot
jupyterlab jupyterlab
czifile czifile
imreg-dft
...@@ -22,7 +22,8 @@ setup( ...@@ -22,7 +22,8 @@ setup(
"pandas", "pandas",
"seaborn", "seaborn",
"statannot", "statannot",
"click" "click",
"imreg-dft"
], ],
python_requires=">=3.8", python_requires=">=3.8",
packages=find_packages(), packages=find_packages(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment