-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_code.m
More file actions
557 lines (506 loc) · 23.4 KB
/
Copy pathmain_code.m
File metadata and controls
557 lines (506 loc) · 23.4 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
%Courtesy: Original code by Prof. Anand T. N. C. Associate Professor in the Department of Mechanical Engineering at IIT Madras
clear all;
close all;
clc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Input Variables %
%========================================================================%
fileName='' ;% Enter filename here: if using one file only
%this file is processed. If using many files,
%this file is read to determine directory
numFiles='all' ;% process 1 file or all files: 'all' or 'one'
filesLike='/User/clonedDirectory/SampleImages/Image/*.tif' ;% if numfiles = 'all' give a filter to choose the files in the directory
binSize=5 ; %size of bin while plotting histograms
scale=10 ;% Enter magnification in micron per pixel. Enter 1 to get value in pixels
preFilter='none' ;% preprocessing filter to remove speckles or noise etc:
% 'none', 'avg' ,'median', 'peak'; defaults to 'none'
filtSize=[3 3] ;% size of preprocessing filter (typically [3 3]
bitDepth=8 ;% 8 bit or 16 bit images - can modify code to get this
% info from arrays itself. Currenlty all images are
% converted to 8 bit before region growing. Will be
% updated in future versions
numWorkers=1 ;% number of threads to run in parallel. Use 1 for serial. distrib_computing_toolbox required to run in parallel (>1). Preferences of Parallel Computing Toolbox should support the number
% when numWorkers=1, if matlab takes a long time create a pool due to the parfor statement in the prog, go to
% Home->Preferences->Parallel Computing Toobox and uncheck the "Automatically
% create a parallel pool..." option
deletePool=0 ;% 0 to keep parallel threads open (e.g. if you plan to run the program again soon. 1 to close the parallel pool (e.g. when running remotely)
%%%%%%%%%%%%%%%%%%% Droplet sizing options %%%%%%%%%%%%%%%%%%
% The values here determine the accuracy of the technique
subtMin = 0 ;% 0 = don't subtract; 1 = subtract minimum of image
refImage= 0 ;% 1 if you are supplying a recorded image, 0 to
% calculate a reference image. Calculating is common
refImFile=' ' ;% name of the file containing the reference image (Required only if refImage=1)
refImCalc='slidMax' ;% 'slidMax' , 'maxOfImage' , Filter used to calculate the reference image
filtxy= [170 170 ] ;% Dimension of the filter - required for sliding maximum % filter. The filter size should be about 1.5 times the
% largest particle dimension in pixels. Setting inmo
% to 4 below will bring up an imtool which can be used
% to find out this value
inmo=0 ;% Interactive mode: options 0 to 4. Interactive mode
% will show many images (>2) and wait for user input (=4): that slows down
% the code
normalize=1;% Normalize image after subtracting background. 0 to
% turn off. Default is 1: normalizing takes into
% account some of the difference in laser intensity
% accross the image
globThreshPerc=48 ;% Global threshold in percentage of maximum value:
% Increase if the image is noisy, reduce or increase if droplets
% are being split into parts and recognized as more
% than one droplet: if multiple green circles come up
% in the same region in the processed image. Reduce if
% droplets are not circled in Figure
fillHoles=0 ;% Fill holes due to dark regions in center of drop. 1=on; 0=off.
% Filling holes slows the code, but may be required for large droplets
lowThresPerc = 42; %Percentage of maximum value in the region. This value
% should be lower than globThreshPerc. Very low values
% will make droplets merge together. Shown in blue in
% Figure
highThresPerc = 70 ;% Percentage of maximum value in the region. Shown in
% green/red in figure
maxLowDist = 200 ;% maximum distance of pixel from centroid while
% enlarging low threshold area. Same value is also used
% for high threshold area. Choose this based on size
% of largest droplet expected. Low values will
% artificially reduce droplet size. High values
% increase processing time
%%%%%%%%%%%%%%%%%%%%%%%% Post-processing options %%%%%%%%%%%%%%%%%%%%%%%%%%
maxAreaRatio = 1.25 ;% Maximum allowed ratio of low Theshold are to high
% threshold area. High values will allow more
% defocussed droplets to be sized. Droplets which meet
% this criterion are shown with highThresPerc area
% green. Droplets which do not meet are shown with red
figsave=0 ;% 0 or 1. 1=save figure showing droplets and histograms
% for each image in subdir. Saving figures slows down the code
% A single histogram of all droplets from all images
% is saved by default
subdir='processed' ;% name of subfolder in which proessed images are saved
subsub='histo' ;% name of subsubdirectory in which histograms are saved
datfile='dropletdatafile' ;% name of file in current directory in which
% droplet size data is saved. Can be used to
% post-process with different options quickly
dropletData(10000,21) = 0; % Size of array which has droplet data: set the first
% value to expected number of droplets in a directory
% Second value is 21
smallestAllowed = 2 ;% Smallest allowed area in pixels
ellipticityAllowed = 0.6 ; % Range: 0 to 1; Allowed deviation from circle; Values close to 1
% will ignore non-circular droplets
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Code starts here %
%========================================================================%
writtenon=date;
warning('off', 'Images:initSize:adjustingMag'); % Tells matlab not to display warning about image being too large to display at 100%
disp('************** Starting Droplet Sizing Algorithm *******************');
save('parameters.mat','writtenon','preFilter','fileName','numFiles','filesLike' ...
,'filtSize','bitDepth','subtMin','refImage','refImFile','refImCalc' ...
,'filtxy','normalize','globThreshPerc','lowThresPerc','highThresPerc','maxLowDist');
disp('Processing parameters saved in parameters.mat file');
fid=fopen(datfile,'w');
time0=tic;
% Create a parallel pool if none exists
if numWorkers>1
if license('test','distrib_computing_toolbox')
if isempty(gcp('nocreate'))
if verLessThan('matlab', '8.2')
matlabpool numWorkers;
else
pool = parpool(numWorkers);
end
else
pool=gcp;
if pool.NumWorkers~=numWorkers
if verLessThan('matlab', '8.2')
matlabpool(close);
matlabpool numWorkers;
else
delete(pool);
pool = parpool(numWorkers);
end
end
end
else
disp('Not able to find parallel license');
end
end
if(inmo)
disp('**** Running in interactive mode.****');
else
disp('**** Running in batch mode. Figures will not be displayed ****');
end
if(~figsave)
disp('**** No figures will be saved ****');
end
switch numFiles
case {'all'}
direc = which(fileName); %better to use fullfile?
mkdir([fileparts(direc)],subdir);
fileList = dir([fileparts(direc) filesep filesLike]);
fileNames = {fileList.name}';
cd(subdir);
mkdir(subsub);
cd ..;
otherwise
direc = which(fileName);
mkdir([fileparts(direc)],subdir);
fileNames{1}=fileName;
cd(subdir);
mkdir(subsub);
cd ..;
disp('You have chosen only 1 file to process');
end
% Creating mask to check if areas are within maxLowDist
distMask=false(maxLowDist*2); % creating square matrix
x0=maxLowDist;
y0=maxLowDist;
for xi=1:size(distMask,1)
for yi=1:size(distMask,2)
distan=sqrt( (xi-x0)^2 + (yi-y0)^2 );
if(distan<maxLowDist)
distMask(xi,yi)=true;
end
end
end
% imshow(distMask)
h=1
for index=1:length(fileNames)
time1=tic;
clear lig1 f;
close all
I=imread(fileNames{index});
disp(['**** Image ' num2str(index) ': Processing file: ',cell2mat(fileNames(index)),' ****']);
I=I(:,:,1);
[Ix Iy]=size(I);
% Preprocessing
preProcStart=tic;
switch preFilter
case {'avg'}
h = fspecial('average', filtSize);
I1=filter2(h, I);
case {'median'}
I1=medfilt2(I,filtSize);
I1=I1(ceil(0+filtSize(1)/2):ceil(size(I1,1)-filtSize(1)/2), floor(0+filtSize(2)/2):floor(size(I1,2)-filtSize(2)/2));
case {'peak'}
disp('Peak filter not coded yet.. Stopping!')
break
otherwise
if(index==1)
disp('No preprocessing filter chosen. Continuing')
end
I1=I;
end
if subtMin==1
I2=I2-min(min(I1));
else
I2=I1;
end
preProcend=toc(preProcStart);
disp(['Took ' num2str(preProcend) ' s to preprocess file ']);
% Reference Image
refImgCalcStart=tic;
if(refImage==1)
refImg=imread(refImFile);
else
switch(refImCalc)
case {'slidMax'}
refImg=ordfilt2(I1,filtxy(1)*filtxy(2),ones(filtxy(1),filtxy(2)));
case {'maxOfImage'}
refImg=double(max(max(I1)))*ones(Ix,Iy);
otherwise
disp('No background image chosen.. Stopping!')
break
end
end
I3=refImg-I2;
if (normalize~=0)
I4=double(I3)./double(refImg)*(2^bitDepth-1);
else
I4=I3;
end
I4disp=I4;
refImgCalcEnd=toc(refImgCalcStart);
disp(['Took ' num2str(refImgCalcEnd) ' s to create/process reference image']);
%Global Thresholding %% would it be better to subtract min and then have
%as percentage of Max values instead of bitdepth?
I5=I4;
globThresh=globThreshPerc/100*(2^bitDepth-1);
% I5(I5<globThresh)=0;
% Thresholding and filling holes
bw=im2bw(uint8(I5),globThresh/(2^bitDepth -1));
if(fillHoles)
bwFill=imfill(bw,'holes');
diffFill=bwFill-bw;
bw=bwFill;
props = regionprops(bwFill,I4,'BoundingBox','MaxIntensity');
if(~isempty(props))
temp=I4;
for i=1:size(props,1)
bbox=props(i).BoundingBox;
temp(max(1,floor(bbox(2))):min(size(temp,2),ceil(bbox(2)+bbox(4))),max(1,floor(bbox(1))):min(size(temp,1),ceil(bbox(1)+bbox(3))))=props(i).MaxIntensity;
end
I4(find(diffFill))=temp(find(diffFill));
end
if(inmo>3)
figure();
imshowpair(uint8(I4),uint8(temp),'montage');
imshowpair(uint8(255*bw),uint8(temp),'montage');
end
end
% Plotting Figures
if(inmo)
if(inmo>3)
imtool(I);
disp('Press any key to continue');
pause;
end
if(inmo>2)
procfig=figure('visible','off');
set(gcf,'units','normalized','outerposition',[0 0 1 1]) % Maximize window
ll=0.05;bb=0.07;ww=0.1;hh=0.1; % changing left, bottom, width, height of subplots below
h=subplot(2,3,1); imshow(I);
title('Original Image','fontsize',12,'fontweight','bold');
p = get(h, 'pos'); p(1)=p(1)-ll;p(2)=p(2)-bb; p(3)=p(3)+ww; p(4)=p(4)+hh;
set(h, 'pos', p);
h=subplot(2,3,2); imshow(I2);
title('Preprocessed Image','fontsize',12,'fontweight','bold');
p = get(h, 'pos'); p(1)=p(1)-ll;p(2)=p(2)-bb; p(3)=p(3)+ww; p(4)=p(4)+hh;
set(h, 'pos', p);
h=subplot(2,3,3); imshow(refImg);
title('Reference Image','fontsize',12,'fontweight','bold');
p = get(h, 'pos'); p(1)=p(1)-ll;p(2)=p(2)-bb; p(3)=p(3)+ww; p(4)=p(4)+hh;
set(h, 'pos', p);
h=subplot(2,3,4); imshow(uint8(I3));
title('Subtracted Image','fontsize',12,'fontweight','bold');
p = get(h, 'pos'); p(1)=p(1)-ll;p(2)=p(2)-bb; p(3)=p(3)+ww; p(4)=p(4)+hh;
set(h, 'pos', p);
h=subplot(2,3,5); imshow(uint8(I4disp));
title('Normalized Subtracted Image','fontsize',12,'fontweight','bold');
p = get(h, 'pos'); p(1)=p(1)-ll;p(2)=p(2)-bb; p(3)=p(3)+ww; p(4)=p(4)+hh;
set(h, 'pos', p);
h=subplot(2,3,6); imshow(uint8(bw*255));
if(fillHoles)
title('Thresholded and Filled Image','fontsize',12,'fontweight','bold');
else
title('Thresholded Image','fontsize',12,'fontweight','bold');
end
p = get(h, 'pos'); p(1)=p(1)-ll;p(2)=p(2)-bb; p(3)=p(3)+ww; p(4)=p(4)+hh;
set(h, 'pos', p);
figure(procfig);
drawnow;
end
end
centres = regionprops(bw, 'centroid');
seeds=cat(1,centres.Centroid);
I6=uint8(I4);
lastFilledRow=find(any(dropletData,2),1,'last');
if(isempty(lastFilledRow))
lastFilledRow=0;
end
lowThresVal=lowThresPerc/100*max(max(I6));
disp(['Finding low and high threshold areas for ' num2str(size(seeds,1)) ' blobs. This could take a while..']);
funcstart=tic;
maxLowDistSq=maxLowDist^2;
totCol=size(dropletData,2);
parfor numBlobs=lastFilledRow+1:lastFilledRow+size(seeds,1) %%% parfor
localVar=zeros(1,totCol);
initPos=round([seeds(numBlobs-lastFilledRow,2),seeds(numBlobs-lastFilledRow,1)]); %%% y value, x value
[lowThRegion]=modRegionGrowing(I6, initPos,lowThresVal,maxLowDist,1,distMask);
lowThCentreProp = regionprops(lowThRegion,I6,'Area','BoundingBox','Centroid', 'Eccentricity','EquivDiameter','MaxIntensity');
if(~isempty(lowThCentreProp))% If low theshold does not give an area, skipping calculations
highThresVal=highThresPerc/100*lowThCentreProp.MaxIntensity;
[highThRegion]=modRegionGrowing(I6, initPos,highThresVal,maxLowDist,1,distMask);
highThCentreProp = regionprops(highThRegion,'Area','BoundingBox','Centroid', 'Eccentricity','EquivDiameter');
values=struct2array(highThCentreProp); % Checking if high threshold gives an area
else
values=[];
end
if(isempty(values))
continue
else % If high theshold does not give an area, skipping writing that line
localVar(1)=index;
localVar(2)=lowThCentreProp.Area;
localVar(3:6)=lowThCentreProp.BoundingBox;
localVar(7:8)=lowThCentreProp.Centroid;
localVar(9)=lowThCentreProp.Eccentricity;
colNum=10;
localVar(colNum+1)=highThCentreProp.Area;
localVar(colNum+2:colNum+5)=highThCentreProp.BoundingBox;
localVar(colNum+6:colNum+7)=highThCentreProp.Centroid;
localVar(colNum+8)=highThCentreProp.Eccentricity;
if(localVar(2)/localVar(11))<maxAreaRatio
localVar(20)=1;
localVar(21)= sqrt((localVar(2)+localVar(colNum+1))/2*4/pi); % Calculating equivalent dia of circle from average area
end
dropletData(numBlobs,:)=localVar;
end
end
funcend=toc(funcstart);
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Post-processing %
%========================================================================%
% The portion above does not need to be rerun while making changes below
if(inmo||figsave)
f=figure('visible','off');
set(gcf,'units','normalized','outerposition',[0 0 1 1]); % Maximize window
ll=0.05;bb=0.07;ww=0.1;hh=0.1; % changing left, bottom, width, height of subplots below
h=subplot(1,1,1); imshow(I);
hold('on');
for ii=lastFilledRow+1:lastFilledRow+size(seeds,1)
if(dropletData(ii,1)==index)
if(dropletData(ii,20))
h=rectangle('Curvature', [1 1],'Position',[dropletData(ii,(3)),dropletData(ii,(4)),dropletData(ii,(5)),dropletData(ii,(6))],...
'EdgeColor','b','LineWidth',2) ;
h=rectangle('Curvature', [1 1],'Position',[dropletData(ii,(12)),dropletData(ii,(13)),dropletData(ii,(14)),dropletData(ii,(15))],...
'EdgeColor','g','LineWidth',2) ;
diams1(ii)=dropletData(ii,21);
elseif any(dropletData(ii,:))
h=rectangle('Curvature', [1 1],'Position',[dropletData(ii,(3)),dropletData(ii,(4)),dropletData(ii,(5)),dropletData(ii,(6))],...
'EdgeColor','b','LineWidth',2) ;
h=rectangle('Curvature', [1 1],'Position',[dropletData(ii,(12)),dropletData(ii,(13)),dropletData(ii,(14)),dropletData(ii,(15))],...
'EdgeColor','r','LineWidth',2) ;
end
end
end
if(figsave)
title('Number of droplets vs. diameter in pixel. Only maxAreaRatio applied. Not all droplets shown here are finally counted','fontsize',12,'fontweight','bold');
cd(subdir); saveas(f,fileNames{index}); cd ..;
end
if inmo
figure(f)
title('Number of droplets vs. diameter in pixel. Only maxAreaRatio applied. Not all droplets shown here are finally counted','fontsize',12,'fontweight','bold');
end
clear f;
end
if(inmo>1||figsave)
ff = figure('visible','off');
if(exist('diams1'))
mm=max(diams1);
lastx=ceil(mm/binSize)*binSize;
xx=(0:binSize:lastx);
N=histc(diams1,xx);
bar(xx,N,'histc');
h = findobj(gca,'Type','patch');
set(h,'FaceColor',[0 .3 .5],'EdgeColor','k');
title('Number of droplets vs. diameter in pixel. Only maxAreaRatio applied','fontsize',12,'fontweight','bold');
xlim([0 lastx]);
end
if(figsave)
cd(subdir); cd(subsub); saveas(ff,fileNames{index}); cd ..; cd ..;
end
if(inmo)
figure(ff)
end
end
timeend=toc(time1);
disp(['Took ' num2str(timeend) ' s to process file ' cell2mat(fileNames(index)) '. ' num2str(funcend) ' s of this time was spent in the region growing routine']);
end
cd(subdir);
disp('**** Saving array dropletData with all droplet data in the chosen subdir ****');
save dropletData;
cd ..;
%%
dropletData = dropletData(any(dropletData,2),:); % Removing empty rows
dropletData = unique(dropletData,'rows'); % Removing duplicate rows
d32=zeros(length(fileNames),1);
d2=zeros(length(fileNames),1);
d3=zeros(length(fileNames),1);
dropsPerImg=zeros(length(fileNames),1);
allDiams=zeros(size(dropletData,1),1);
for jj=1:size(dropletData,1)
if(dropletData(jj,2)/dropletData(jj,11))<maxAreaRatio % Col 20==1
if((dropletData(jj,2)+dropletData(jj,11))/2>=smallestAllowed)
ellRat=(dropletData(jj,5)+dropletData(jj,14))/(dropletData(jj,6)+dropletData(jj,15));
if ellRat>1
ellRat=1/ellRat;
end
if ellRat > ellipticityAllowed
dropletData(jj,20)=4;% accepted droplets
dropletData(jj,21)= sqrt((dropletData(jj,2)+dropletData(jj,11))/2*4/pi); % Calculating equivalent dia of circle from average area
allDiams(jj)=dropletData(jj,21)*scale;
else
dropletData(jj,20)=3;% rejected based on ellipticity ratio
end
else
dropletData(jj,20)=2; % rejected based on smallest size allowed
end
end
im=dropletData(jj,1);
if dropletData(jj,20)==4
d2(im)=d2(im)+allDiams(jj).^2;
d3(im)=d3(im)+allDiams(jj).^3;
dropsPerImg(im)=dropsPerImg(im)+1;
end
end
numRejAreaRatio=sum(dropletData(:,20)==0);
numRejSmallSize=sum(dropletData(:,20)==2);
numRejEllipt=sum(dropletData(:,20)==3);
numAccepted=sum(dropletData(:,20)==4);
% Calculating SMD
d32=d3./d2;
d32all=sum(d3)/sum(d2);
disp(['**** Post-processed ' num2str(size(dropletData,1)) ' droplets. Rejected ' num2str(numRejAreaRatio) ' based on area ratio, '])
disp(['**** ' num2str(numRejSmallSize) ' as they did not meet smallest acceptable size, and ' num2str(numRejEllipt) ' as they were not circular enough. ****' ]);
disp(['**** Accepted ' num2str(numAccepted) ' droplets out of ' num2str(size(dropletData,1)) '. ****']);
disp(['**** Average SMD of these droplets from all images is ' num2str(d32all) ' micron ****']);
allDiams=allDiams(any(allDiams,2),:);
% Plotting histogram of all droplets
allDrops = figure('visible','off');
mm=max(allDiams);
lastx=ceil(mm/binSize)*binSize;
xx=(0:binSize:lastx);
N=histc(allDiams,xx);
bar(xx,N,'histc');
h = findobj(gca,'Type','patch');
set(h,'FaceColor',[0 .3 .5],'EdgeColor','k');
title('Number of droplets vs. diameter in micron','fontsize',12,'fontweight','bold');
if(isempty(lastx))
lastx=0.001;
end
xlim([0 lastx]);
cd(subdir); cd(subsub);
saveas(allDrops,'Histogram.png');cd ..; cd ..;
if(inmo)
figure(allDrops);
end
% Plotting histogram of statistics per image
figNumDrops=figure('visible','off');
xx=(1:length(fileNames));
[AX,H1,H2] = plotyy(xx,dropsPerImg, xx,d32,'bar','plot');
xt=[1:1:length(fileNames)];
set(AX,'xtick',xt);
%set(H1,'Marker','*','MarkerSize',8);
set(H2,'Marker','o','Color','m','MarkerSize',8,'MarkerFaceColor',[1 0 0]);
set(AX(2),'ycolor','m')
grid on;
xlabel(AX(1),'Image number') % label x-axis
ylabel(AX(1),'Number of droplets accepted in image') % label left y-axis
ylabel(AX(2),'SMD from image') % label right y-axis
title('Number of droplets accepted vs. Image number','fontsize',12,'fontweight','bold');
cd(subdir); cd(subsub);
saveas(figNumDrops,'numberOfDroplets.png');cd ..; cd ..;
if(inmo)
figure(figNumDrops);
end
%%
% Writing unscaled SMD values to file
fprintf(fid,'%s\t',d32all);
fprintf(fid,'\n');
fprintf(fid,'\n');
fprintf(fid,'%s\t',d32);
fprintf(fid,'\n');
% SMD
% eccentricity
% size filter
fclose(fid);
if(deletePool)
if ~isempty(gcp('nocreate'))
if(~exist('pool'))
pool=gcp;
end
if verLessThan('matlab', '8.2')
matlabpool(close);
else
delete(pool); % stop parallel pool
end
end
end
progEnd=toc(time0);
disp(['**** Processing Complete: Took ' num2str(progEnd) ' s to process ' num2str(index) ' files ****']);