-
Notifications
You must be signed in to change notification settings - Fork 0
/
O_LoadImages_Shixuan_BG.m
86 lines (78 loc) · 2.44 KB
/
O_LoadImages_Shixuan_BG.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function [O]=O_LoadImages_Shixuan_BG(O, BG)
DirName=O.DirName;
FileType=O.FileType;
if strcmpi(O.FileType,'Operetta')
Ri=O.ImageID.Row;
Ci=O.ImageID.Column;
Fi=O.ImageID.Field;
Ti=O.ImageID.Time;
if O.LoadingPie
figure(998)
clf
end
for k=O.ImagedChannels'
if O.LoadingPie
figure(998)
pie(k/max(O.ImagedChannels))
title('Loading Images','fontsize',14,'color','r')
drawnow
end
ImageName=['r' sprintf('%02d',Ri) 'c' sprintf('%02d',Ci) ...
'f' sprintf('%02d',Fi) 'p01-ch' num2str(k) 'sk' num2str(Ti) 'fk1fl1.tiff'];
im=double(imread([DirName '\Images\' ImageName]));
% CHANGE HERE
im = im-BG{k}; %substract background
%%%%%%%%%%%%%
IM{k}=im;
WS{k}=[];
O.BW{k}=[];
O.BW_spots{k}=[];
end
else
Nums=O.ImageID;
BaseName=O.Image_Retrieval_data.Image_File_Base_Name;
NumberLengths=O.Image_Retrieval_data.NumberLengths;
if O.LoadingPie
figure(998)
clf
end
for k=O.ImagedChannels'
if O.LoadingPie
figure(998)
pie(k/max(O.ImagedChannels))
title('Loading Images','fontsize',14,'color','r')
drawnow
end
Nums.Channal=k;
[im]=O_Get_Image_File(O.DirName,Nums,NumberLengths,BaseName,FileType);
IM{k}=im;
WS{k}=[];
O.BW_spots{k}=[];
end
end
ImageNormalizarionParameters.Magnification=O.Magnification;
ImageNormalizarionParameters.FlatField_Correction=O.FlatField_Correction;
if O.FlatField_Correction==1
ImageNormalizarionParameters.flat=O.flat;
end
O.Original_IM=IM;
ImageNormalizarionParameters.flat.Multipicative_Biase=[];
ImageNormalizarionParameters.flat.Additive_Biase=[];
for k=O.ImagedChannels'
ImageNormalizarionParameters.CWidth_alpha=O.General_Thresholds.CloseW(k);
ImageNormalizarionParameters.OWidth_alpha=O.General_Thresholds.OpenW(k);
[BG]=O_NormalizeImages(IM{k},ImageNormalizarionParameters);
IM{k}=BG.BG;
if O.Selected_ch>0 % Selected_ch is the Display_Channal from the GUI
if O.General_Thresholds.OpenW(O.Selected_ch)>0 && ...
k==O.Selected_ch
O.CalcDark2.SmallIM=BG.SmallIM;
O.CalcDark2.imo=BG.imo;
O.CalcDark2.a=BG.imresize_alpha;
end
end
end
O.NewImageSelected=false;
O.IM=IM;
O.WS=WS;
O.ImageSize=sqrt(sum((size(IM{1})).^2));