Home > SuperSegger > frameLink > merge2Regions.m

merge2Regions

PURPOSE ^

merge2Regions : merges reg1 and reg2 into one in the mask_cell

SYNOPSIS ^

function [data_c,resetRegions] = merge2Regions (data_c, list_merge, CONST)

DESCRIPTION ^

 merge2Regions : merges reg1 and reg2 into one in the mask_cell
 regions need to be remade after this in order to have the right
 properties.
 INPUT :
      data_c : current data (seg/err) file.
      reg1 : id of region 1
      reg2 : id of region 2 
      CONST : segmentation parameters

 OUTPUT :
      data_c : data_c with merged regions
      resetRegions : true if regions were merged and linking should
      re-run.

 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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [data_c,resetRegions] = merge2Regions (data_c, list_merge, CONST)
0002 % merge2Regions : merges reg1 and reg2 into one in the mask_cell
0003 % regions need to be remade after this in order to have the right
0004 % properties.
0005 % INPUT :
0006 %      data_c : current data (seg/err) file.
0007 %      reg1 : id of region 1
0008 %      reg2 : id of region 2
0009 %      CONST : segmentation parameters
0010 %
0011 % OUTPUT :
0012 %      data_c : data_c with merged regions
0013 %      resetRegions : true if regions were merged and linking should
0014 %      re-run.
0015 %
0016 % Copyright (C) 2016 Wiggins Lab
0017 % Written by Stella Stylianidou, Paul Wiggins.
0018 % University of Washington, 2016
0019 % This file is part of SuperSegger.
0020 %
0021 % SuperSegger is free software: you can redistribute it and/or modify
0022 % it under the terms of the GNU General Public License as published by
0023 % the Free Software Foundation, either version 3 of the License, or
0024 % (at your option) any later version.
0025 %
0026 % SuperSegger is distributed in the hope that it will be useful,
0027 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0028 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0029 % GNU General Public License for more details.
0030 
0031 resetRegions = 0;
0032 masksum = 0*data_c.regs.regs_label;
0033 
0034 for i = 1 : numel(list_merge)
0035     mask1 = (data_c.regs.regs_label == list_merge(i));
0036     masksum = (masksum+mask1);
0037 end
0038 
0039 masksum_  = imdilate(masksum,strel('square',3));
0040 masksum__  = imerode(masksum_,strel('square',3));
0041 
0042 labels =  bwlabel(masksum__);
0043 if max(labels(:)) == 1
0044     segsInMask = data_c.segs.segs_label;
0045     segsInMask(~masksum__) = 0;
0046     segsInMask = logical(segsInMask);
0047     data_c.segs.segs_good(segsInMask) = 0;
0048     data_c.segs.segs_bad(segsInMask) = 1;
0049     data_c.mask_cell = double((data_c.mask_cell + masksum__)>0);
0050     resetRegions = true;
0051 end
0052 
0053 
0054 end

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