extractSegmentedPatchV3

PURPOSE ^

EXTRACTSEGMENTEDPATCHV3.m function manage the alignment of segmented

SYNOPSIS ^

function [ reshapedSegmentedMask, insidePatchIndexes, finalSegmentedMask] =extractSegmentedPatchV3( segmentedMask,outOfBoundSize,centralPoint, shapeDSKCF_struct,maxSize )

DESCRIPTION ^

 EXTRACTSEGMENTEDPATCHV3.m function manage the alignment of segmented
 patches to accumulate object binary masks as in [1]


   EXTRACTSEGMENTEDPATCHV3 is used to accumulate the segmented target
   masks and align them correctly in case of target close to the borders
   for example or change in scale while those silhouette are accumulated

   INPUT:
   - segmentedMask   segmented binary mask of the current frame
   - outOfBoundSize  size of the patch to be assigned if the vector
   containing the segmented masks is empty
   - centralPoint center of the current tracking target
   -shapeDSKCF_struct data structure containing shape information (see INITDSKCFSHAPE) 
   - maxSize image size
   OUTPUT
   -reshapedSegmentedMask segmented mask with adjusted size according to
   the accumulated mask vector
   -insidePatchIndexes index of the mask inside the patch (needed to be
   re-adjusted in case of object close to borders of change of scale)see
   also ADDSEGMENTATIONRESULTS
   -finalSegmentedMask a copy of input segmentedMask

  See also INITDSKCFSHAPE, ADDSEGMENTATIONRESULTS


  [1] S. Hannuna, M. Camplani, J. Hall, M. Mirmehdi, D. Damen, T.
  Burghardt, A. Paiement, L. Tao, DS-KCF: A real-time tracker for RGB-D
  data, Journal of Real-Time Image Processing


  University of Bristol
  Massimo Camplani and Sion Hannuna

  massimo.camplani@bristol.ac.uk
  hannuna@compsci.bristol.ac.uk

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ reshapedSegmentedMask, insidePatchIndexes, finalSegmentedMask] = ...
0002     extractSegmentedPatchV3( segmentedMask,outOfBoundSize,centralPoint, shapeDSKCF_struct,maxSize )
0003 % EXTRACTSEGMENTEDPATCHV3.m function manage the alignment of segmented
0004 % patches to accumulate object binary masks as in [1]
0005 %
0006 %
0007 %   EXTRACTSEGMENTEDPATCHV3 is used to accumulate the segmented target
0008 %   masks and align them correctly in case of target close to the borders
0009 %   for example or change in scale while those silhouette are accumulated
0010 %
0011 %   INPUT:
0012 %   - segmentedMask   segmented binary mask of the current frame
0013 %   - outOfBoundSize  size of the patch to be assigned if the vector
0014 %   containing the segmented masks is empty
0015 %   - centralPoint center of the current tracking target
0016 %   -shapeDSKCF_struct data structure containing shape information (see INITDSKCFSHAPE)
0017 %   - maxSize image size
0018 %   OUTPUT
0019 %   -reshapedSegmentedMask segmented mask with adjusted size according to
0020 %   the accumulated mask vector
0021 %   -insidePatchIndexes index of the mask inside the patch (needed to be
0022 %   re-adjusted in case of object close to borders of change of scale)see
0023 %   also ADDSEGMENTATIONRESULTS
0024 %   -finalSegmentedMask a copy of input segmentedMask
0025 %
0026 %  See also INITDSKCFSHAPE, ADDSEGMENTATIONRESULTS
0027 %
0028 %
0029 %  [1] S. Hannuna, M. Camplani, J. Hall, M. Mirmehdi, D. Damen, T.
0030 %  Burghardt, A. Paiement, L. Tao, DS-KCF: A real-time tracker for RGB-D
0031 %  data, Journal of Real-Time Image Processing
0032 %
0033 %
0034 %  University of Bristol
0035 %  Massimo Camplani and Sion Hannuna
0036 %
0037 %  massimo.camplani@bristol.ac.uk
0038 %  hannuna@compsci.bristol.ac.uk
0039 
0040 stPointX=1;
0041 stPointY=1;
0042 endPointY=size(segmentedMask,1);
0043 endPointX=size(segmentedMask,2);
0044 
0045 stPointXMask=1;
0046 stPointYMask=1;
0047 endPointYMask=size(segmentedMask,1);
0048 endPointXMask=size(segmentedMask,2);
0049 
0050 %clip the groundflor
0051 segmentedMask(round(endPointYMask*0.85):end,round(endPointXMask*0.60):end)=0;
0052 segmentedMask(round(endPointYMask*0.85):end,1:round(endPointXMask*0.4))=0;
0053 
0054 if(isempty(shapeDSKCF_struct.cumulativeMask))
0055     cumulativeSize=outOfBoundSize;
0056 else
0057     cumulativeSize=size(shapeDSKCF_struct.cumulativeMask);
0058 end
0059 
0060 if(size(segmentedMask)==cumulativeSize)
0061     reshapedSegmentedMask=segmentedMask;
0062 else
0063     extremaBB(1:2)=centralPoint-cumulativeSize(2:-1:1)/2;
0064     extremaBB(3:4)=centralPoint+cumulativeSize(2:-1:1)/2;
0065     extremaBB=floor(extremaBB(:));
0066     reshapedSegmentedMask=repmat(0,cumulativeSize);
0067     
0068     %CASE1: object on the left
0069     if(extremaBB(1)<0)%problem with x placement
0070         diffSize=min(size(segmentedMask,2)-cumulativeSize(2),0);
0071         %%dif size is negative or zero
0072         stPointX=max(1,abs(extremaBB(1))+diffSize);
0073         minSize=min(size(segmentedMask,2),cumulativeSize(2));
0074         endPointX=stPointX+minSize-1;
0075         stPointXMask=1;
0076         endPointXMask=stPointXMask+minSize-1;
0077     end
0078     
0079     %CASE1: object on the right
0080     if(extremaBB(3)>maxSize(1))
0081         minSize=min(size(segmentedMask,2),cumulativeSize(2));
0082         offset=extremaBB(3)-maxSize(1);
0083         endPointX=cumulativeSize(2)-offset;
0084         stPointX=max((endPointX-minSize+1),1);
0085         endPointXMask=minSize;
0086         numberOfFinalElement=endPointX-stPointX;
0087         stPointXMask=endPointXMask-numberOfFinalElement;
0088     end
0089     
0090     %CASE3: object on the top
0091     if(extremaBB(2)<0)%problem with x placement
0092         
0093         diffSize=min(size(segmentedMask,1)-cumulativeSize(1),0);
0094         stPointY=max(1,abs(extremaBB(2))+diffSize);
0095         minSize=min(size(segmentedMask,1),cumulativeSize(1));
0096         endPointY=stPointY+minSize-1;
0097         stPointYMask=1;
0098         endPointYMask=stPointYMask+minSize-1;
0099     end
0100     
0101     %CASE1: object on the bottom
0102     if(extremaBB(4)>maxSize(2))
0103         minSize=min(size(segmentedMask,1),cumulativeSize(1));
0104         offset=extremaBB(4)-maxSize(2);
0105         endPointY=cumulativeSize(1)-offset;
0106         stPointY=max((endPointY-minSize+1),1);
0107         numberOfFinalElement=endPointY-stPointY;
0108         stPointYMask=endPointYMask-numberOfFinalElement;
0109     end
0110     
0111     reshapedSegmentedMask(stPointY:endPointY,stPointX:endPointX)=segmentedMask(stPointYMask:endPointYMask,stPointXMask:endPointXMask);
0112     
0113 end
0114 
0115 selectedSize=[length(stPointY:endPointY),length(stPointX:endPointX)];
0116 
0117 minSIZE=[min(size(segmentedMask,1),cumulativeSize(1)), min(size(segmentedMask,2),cumulativeSize(2))];
0118 
0119 
0120 if(selectedSize(2)<minSIZE(2))%cumulativeSize(2))
0121     diffLeft=stPointX-1;
0122     diffRight=minSIZE(2)-endPointX;%cumulativeSize(2)-endPointX;
0123     endPointX=endPointX+diffRight;
0124     stPointX=stPointX-diffLeft;
0125 end
0126 
0127 if(selectedSize(1)<minSIZE(1) )%cumulativeSize(1))
0128     diffUp=stPointY-1;
0129     diffDown=minSIZE(1)-endPointY;%cumulativeSize(1)-endPointY;
0130     endPointY=endPointY+diffDown;
0131     stPointY=stPointY-diffUp;
0132 end
0133 
0134 selectedSizeFinal=size(reshapedSegmentedMask);
0135 
0136 if(selectedSizeFinal(2)>cumulativeSize(2))%)
0137     diff=selectedSizeFinal(2)-minSIZE(2);
0138     diffLIMIT=selectedSizeFinal(2)-cumulativeSize(2);
0139     endPointXLIMIT=endPointX-diffLIMIT;
0140     endPointX=endPointX-diff;
0141     stPointX=1;
0142     reshapedSegmentedMask=reshapedSegmentedMask(:,stPointX:endPointXLIMIT);
0143 end
0144 
0145 if(selectedSizeFinal(1)>cumulativeSize(1))%cumulativeSize(2))
0146     diff=selectedSizeFinal(1)-minSIZE(1);
0147     diffLIMIT=selectedSizeFinal(1)-cumulativeSize(1);
0148     endPointYLIMIT=endPointY-diffLIMIT;
0149     endPointY=endPointY-diff;
0150     stPointY=1;
0151     reshapedSegmentedMask=reshapedSegmentedMask(stPointY:endPointYLIMIT,:);
0152 end
0153 
0154 
0155 insidePatchIndexes=[stPointX,stPointY,endPointX,endPointY];
0156 
0157 
0158 finalSegmentedMask=segmentedMask;
0159 end

Generated on Thu 24-Nov-2016 18:03:21 by m2html © 2005