Home > track > WBCstatic.m

WBCstatic

PURPOSE ^

SYNOPSIS ^

function WBCstatic(remote)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function WBCstatic(remote)
0002 
0003 
0004 if (remote==0)
0005     iPath = 'C:\Research\DataSets\LILLYwbcrollingapc\';
0006 else
0007     iPath = '/v1/rich/DataSets/LILLYwbcrollingapc/';
0008 end
0009 
0010 % Appearance threshold
0011 k = 21;
0012 thresh_i  = 50;
0013 thresh_rm = .365;
0014 kh = floor(k/2);
0015 k2 = 2*k-1;
0016 kh2= floor(k2/2);
0017 rm_layer = 2; % number layer of radial kernel
0018 % create filter kernels
0019 [rm_k] = create_radial_mean_kernel(k,rm_layer);
0020 tArea = 20;
0021 cd(iPath);
0022 dataFolders = dir(iPath);
0023 if (remote ==0)
0024     mkdir('Statics');
0025 end
0026 for fo = 3: length(dataFolders)
0027     if (dataFolders(fo).isdir ==1)
0028         dataFolder = dataFolders(fo).name;
0029         
0030         try            
0031             im  = imread(strcat(dataFolder,'/','BG.png'));
0032             amask = imread(strcat(dataFolder,'/','amask.png'));
0033             im = medfilt2(im, [5 5]);
0034             nStatic = 0;
0035             [R, C] = size ( im );
0036             list= zeros(0,2);    
0037             imRGB = [];
0038             imRGB = gray_to_rgb(im);
0039             disp(['Processing ', dataFolder]);
0040             for r = kh2+1:(R-kh2-1)        
0041                 for c = kh2+1:(C-kh2-1)
0042                     if (amask(r,c)==0)
0043                         % crop the image within [sr0:sr1, sc0:sc1]
0044                         r0 = max ( 1, r-kh );
0045                         c0 = max ( 1, c-kh );
0046                         r1 = min ( R, r+kh );
0047                         c1 = min ( C, c+kh );
0048 
0049                         im_sub = im ( r0:r1, c0:c1 );
0050                         radial_mean = compute_radial_mean(im_sub,rm_k);
0051                         if (radial_mean(1)> thresh_rm) && (im(r,c)> thresh_i)
0052                            if (remote == 0)
0053                                 if (radial_mean(1) < thresh_rm)
0054                                     imRGB(r-1,c-1,:)= [0 255 0];
0055                                     imRGB(r-1,c,:)= [0 255 0];
0056                                     imRGB(r,c-1,:)= [0 255 0];
0057                                     imRGB(r,c,:)= [0 255 0];
0058                                 else
0059                                     imRGB(r-1,c-1,:)= [255 0 0];
0060                                     imRGB(r-1,c,:)= [255 0 0];
0061                                     imRGB(r,c-1,:)= [255 0 0];
0062                                     imRGB(r,c,:)= [255 0 0];
0063                                 end
0064                            end
0065                            list = [list; r c];
0066                         end
0067                     end
0068                 end
0069             end
0070             %% Calculate statistical info of detected region
0071             [centroids, areas, eccentricities] = get_DT_cell_location(R,C,list);
0072             
0073             if (~isempty(centroids))
0074                 for ce = 1 : size(centroids,1)
0075                    if areas(ce) > tArea 
0076                         nStatic = nStatic + 1;
0077                    end
0078                 end
0079             end 
0080             
0081             oFiles =strcat(dataFolder,'/','_nStatic.mat'); 
0082             save(oFiles, 'nStatic');
0083             if (remote ==0)
0084                 bgStatic = strcat('Statics/',dataFolder,'.st.png');
0085                 imwrite(imRGB,bgStatic);
0086             end
0087             
0088         catch
0089            disp(['BG file in ', dataFolder ,' is not available']);  
0090         end      
0091     end    
0092 end
0093 
0094 
0095 
0096 
0097 
0098 end

Generated on Thu 17-Mar-2011 14:45:51 by m2html © 2005