-
Notifications
You must be signed in to change notification settings - Fork 0
/
tophat.m
30 lines (29 loc) · 1.02 KB
/
tophat.m
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
function [] = tophat(input_dir, output_dir)
config = get_config();
write_config(output_dir);
positions = config('positions');
types = config('types');
cycles = config('cycles');
se = strel('disk', config('tophat_size'));
fmt = '%s/%s';
for posidx = 1:numel(positions)
position = positions(posidx);
pos = read_position(input_dir, position);
images = pos('cycles');
for cycleidx = 1:numel(images)
cycle = cycles(cycleidx);
image = images{cycleidx};
for channel=1:size(image, 3)
type = types{channel};
fn = sprintf(fmt, output_dir, sprintf(config('img_cycle'), position, cycle, type));
th = imtophat(image(:,:,channel), se);
write_image(th,fn);
end
end
% top hat the DO as well
image = pos('do');
th = imtophat(image, se);
fn = sprintf(fmt, output_dir, sprintf(config('img_do'), position));
write_image(th, fn);
end
end