0001 function [madeChanges, data_c, data_r] = splitAreaErrors (data_c, data_r, CONST, time, verbose)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 DEBUG_FLAG = 1;
0035
0036 DA_MIN = CONST.trackOpti.DA_MIN;
0037 DA_MAX = CONST.trackOpti.DA_MAX;
0038
0039 madeChanges = 0;
0040
0041 splitRegions = [];
0042
0043 for regNum = 1 : data_c.regs.num_regs;
0044 rCellsFromC = data_c.regs.map.r{regNum};
0045 rCells = unique(data_r.regs.revmap.f{regNum});
0046
0047 if ~isempty(rCellsFromC)
0048 cCellsFromR = unique([data_r.regs.map.f{rCellsFromC}]);
0049 else
0050 cCellsFromR = [];
0051 end
0052
0053 rCells = unique([rCellsFromC, rCells]);
0054 cCells = unique([regNum, cCellsFromR]);
0055
0056 data_r.regs.dA.f(rCells);
0057 data_c.regs.dA.r(cCells);
0058
0059 if numel(rCells) > 0 && numel(cCells) > 0
0060 fromArray = repmat(rCells, [1, numel(cCells)]);
0061 toArray = repmat(cCells, [1, numel(rCells)]);
0062
0063 deltaSize = ([data_c.regs.props(toArray).Area] - [data_r.regs.props(fromArray).Area]) ./ [data_r.regs.props(fromArray).Area];
0064
0065 for i = find(deltaSize > DA_MAX)
0066 if ~ismember(toArray(i), splitRegions)
0067 if (DEBUG_FLAG)
0068 toMask = (data_c.regs.regs_label == toArray(i));
0069 fromMask = (data_r.regs.regs_label == fromArray(i));
0070
0071 figure(4);
0072
0073 [fromX, fromY] = getBBpad(data_c.regs.props(toArray(i)).BoundingBox, size(data_c.mask_cell), 20);
0074 [toX, toY] = getBBpad(data_r.regs.props(fromArray(i)).BoundingBox, size(data_r.mask_cell), 20);
0075
0076 xMax = max([toX, fromX]);
0077 xMin = min([toX, fromX]);
0078 yMax = max([toY, fromY]);
0079 yMin = min([toY, fromY]);
0080
0081 x = xMin : xMax;
0082 y = yMin : yMax;
0083
0084 toMask = toMask(y, x) .* data_c.mask_cell(y, x);
0085 fromMask = fromMask(y, x) .* data_r.mask_cell(y, x);
0086
0087 background = zeros(size(y, 2), size(x, 2));
0088 imshow(cat(3, background + 0.5 * data_c.mask_cell(y, x) + 0.5 * toMask, background + 0.5 * toMask+ 0.5 * fromMask, background + 0.5 * data_r.mask_cell(y, x) + fromMask), []);
0089
0090 figure(5);
0091 imshow(cat(3, ag(data_c.phase(y, x)), background, ag(data_c.segs.segs_bad(y, x))), []);
0092
0093 end
0094
0095 [data_c, success] = splitAtBestSeg(data_c, toArray(i), CONST);
0096
0097 if success
0098 madeChanges = 1;
0099
0100 disp (['Frame ', num2str(time), ' : split region ', num2str(toArray(i)), ' due to abnormal growth speed.']);
0101 else
0102 if verbose
0103 disp (['Frame ', num2str(time), ' : could not find segment to split region ', num2str(toArray(i)), '.']);
0104 end
0105 end
0106
0107 splitRegions = [splitRegions, toArray(i)];
0108 end
0109 end
0110 end
0111 end
0112