-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPipeline.py
49 lines (35 loc) · 1.23 KB
/
Pipeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import numpy as np
import tifffile as tif
import Seed as s
from Cylinder_Object import Cylinder
import Optimize as opt
import Visualization as vis
from Util import check_bounds
import Settings
#def main():
Settings.init()
default_radius = 4
default_height = 10
# Load in image and seeds
filename = 'testdata.tif'
whole_img = tif.imread(filename)
#seedfilename = 'testdata_maxima_binary.tif'
#seeds = s.get_seeds(seedfilename)
#seed = [37, 39, 7]
#seed = [42, 48, 7]
#seed = [46, 57, 7]
#seed = [53, 84, 5]
seed = [63, 96, 1]
cylinder = Cylinder(default_radius, default_height, psf=2, first=True)
# Correct indices (if negative) and pad cropped image if necessary
indices = cylinder.get_image_indices(seed)
corrected_indices, pad_sequence = check_bounds(indices, whole_img)
cropped_img = whole_img[corrected_indices]
padded_cropped_img = np.pad(cropped_img, pad_sequence, mode='constant')
score, best_theta, best_psi = opt.optimize_angle(cylinder, seed, padded_cropped_img)
cylinder.rotate(best_psi, best_theta)
vis.overlay_cylinder('output.tif', whole_img, cylinder, seed)
#best_score, best_theta, best_psi = Optimize.optimize_angle(cylinder, seeds[257], img)
#fit_score = cylinder._score_correlation(img)
#if __name__ == '__main__':
# main()