forked from evodevosys/AroSpotFindingSuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduce_mask_thumbnails.m
43 lines (37 loc) · 1.26 KB
/
produce_mask_thumbnails.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
31
32
33
34
35
36
37
38
39
40
41
42
43
function [] = produce_mask_thumbnails()
run('Aro_parameters.m');
dye = dyesUsed{1};
if ~exist([ImageDir filesep dye], 'dir')
disp('[ERROR] The images have not been trimmed/placed in the proper folders! Please trim first.');
return;
end
current_files = dir([SegmentationMaskDir filesep '*.tif']);
tif_files = {current_files.name};
tif_files = natsortfiles(tif_files);
num_thumbs = floor(numel(tif_files)/20);
if numel(tif_files)/20 > num_thumbs
num_thumbs = num_thumbs + 1;
end
if num_thumbs < 1
num_thumbs = 1;
end
for i = 1:num_thumbs
image = zeros(400, 500, 1);
for j = 0:3
for k = 0:4
if ((k + 1) + 5*j + 20*(i-1)) <= numel(tif_files)
disp(['[producing thumbnail] ' tif_files{(k + 1) + 5*j + 20*(i-1)}]);
original = imread([SegmentationMaskDir filesep tif_files{(k + 1) + 5*j + 20*(i-1)}]);
thumb = imresize(original, [100, 100]);
start_x = j * 100 + 1;
end_x = start_x + 99;
start_y = k * 100 + 1;
end_y = start_y + 99;
image(start_x:end_x, start_y:end_y, 1) = thumb(:,:);
end
end
end
imwrite(image, [SegmentationMaskDir filesep 'thumbnails' num2str(i) '.bmp']);
end
clear;
return;