Home > SuperSegger > segmentation > removeDebris.m

removeDebris

PURPOSE ^

removeDebris : removes false positives from microcolony mask

SYNOPSIS ^

function [ mask_mod ] = removeDebris( mask_bg, phase, aK, CONST )

DESCRIPTION ^

 removeDebris : removes false positives from microcolony mask
 It uses the brightness of the halos versus the darkness of the ecoli
 and the curvature of the image  

 INPUT : 
   mask_bg : background mask.
   phase : normalized phase image.
   aK : texture/pebble measure (uses im_xx from the curveFilter).
 OUTPUT : 
   mask_mod : modified mask.
 
 Copyright (C) 2016 Wiggins Lab
 Written by Stella Stylianidou & Paul Wiggins.
 University of Washington, 2016
 This file is part of SuperSegger.

 SuperSegger is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 SuperSegger is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ mask_mod ] = removeDebris( mask_bg, phase, aK, CONST )
0002 % removeDebris : removes false positives from microcolony mask
0003 % It uses the brightness of the halos versus the darkness of the ecoli
0004 % and the curvature of the image
0005 %
0006 % INPUT :
0007 %   mask_bg : background mask.
0008 %   phase : normalized phase image.
0009 %   aK : texture/pebble measure (uses im_xx from the curveFilter).
0010 % OUTPUT :
0011 %   mask_mod : modified mask.
0012 %
0013 % Copyright (C) 2016 Wiggins Lab
0014 % Written by Stella Stylianidou & Paul Wiggins.
0015 % University of Washington, 2016
0016 % This file is part of SuperSegger.
0017 %
0018 % SuperSegger is free software: you can redistribute it and/or modify
0019 % it under the terms of the GNU General Public License as published by
0020 % the Free Software Foundation, either version 3 of the License, or
0021 % (at your option) any later version.
0022 %
0023 % SuperSegger is distributed in the hope that it will be useful,
0024 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0026 % GNU General Public License for more details.
0027 %
0028 % You should have received a copy of the GNU General Public License
0029 % along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.
0030 
0031 
0032 
0033 INTENSITY_DIF = CONST.superSeggerOpti.INTENSITY_DIF;
0034 PEBBLE_CONST = CONST.superSeggerOpti.PEBBLE_CONST;
0035 debugFlag = false;
0036 pad = 6;
0037 
0038 ss = size( phase );
0039 label_bg = bwlabel( mask_bg );
0040 props = regionprops( label_bg,  'BoundingBox', 'Centroid' );
0041 num_reg = numel( props );
0042 
0043 %initialize
0044 I_K = nan( [1,num_reg] );
0045 I_p = nan( [1,num_reg] );
0046 I_m = nan( [1,num_reg] );
0047 
0048 
0049 for ii = 1:num_reg
0050     
0051     bb = props(ii).BoundingBox;
0052     
0053     [xx,yy] = getBBpad( bb,ss,pad );
0054     
0055     mask_ii  = (label_bg( yy,xx)==ii);
0056     phase_ii = phase(yy,xx);
0057     aK_ii = aK(yy,xx);
0058     
0059     mask_p2 = bwmorph( mask_ii, 'dilate', 2 );
0060     mask_p1 = bwmorph( mask_ii, 'dilate', 1 );
0061     mask_m2 = bwmorph( mask_ii, 'erode', 2 );
0062     mask_m1 = bwmorph( mask_ii, 'erode', 1 );
0063     
0064     
0065     inner_outline = mask_m1-mask_m2; 
0066     outer_outline = mask_p2-mask_p1;
0067     
0068     sss = sum(inner_outline(:));
0069     if sss > 0
0070         I_m(ii) = sum(inner_outline(:).*double(phase_ii(:)))/sss;
0071     end
0072     
0073     sss = sum(outer_outline(:));
0074     if sss > 0
0075         I_p(ii) = sum(outer_outline(:).*double(phase_ii(:)))/sum(outer_outline(:));
0076     end
0077     
0078     sss = sum(mask_ii(:));
0079     if sss > 0
0080         I_K(ii) = sum(mask_ii(:).*double(aK_ii(:)))/sss;
0081     end
0082     
0083     
0084 end
0085 
0086 
0087 DI = I_p-I_m; % change in intensity of outer and inner outline.
0088 keeper = find(and(DI>INTENSITY_DIF,I_K>PEBBLE_CONST));
0089 mask_mod = ismember(label_bg, keeper);
0090 
0091 
0092 if debugFlag
0093     
0094     figure(8);
0095     clf;        
0096     halo_keep = find( DI>INTENSITY_DIF );
0097     pebble_keep = find( I_K>PEBBLE_CONST );
0098     imshow( comp( phase, mask_bg, ismember( label_bg,halo_keep ), ismember( label_bg,pebble_keep) ) );
0099        
0100     for ii = 1:num_reg
0101         text( props(ii).Centroid(1),props(ii).Centroid(2), [num2str( -I_m(ii)+I_p(ii), '%2.2g' ),',',num2str( I_K(ii), '%2.2g' )] );
0102     end    
0103     
0104     figure(9);
0105     clf    
0106     imshow( comp( phase, ~ismember( label_bg, keeper)));
0107 end
0108 
0109 end

Generated on Thu 19-Jan-2017 13:55:21 by m2html © 2005