FROMCENTRALPOINTTOBB.m is a function for calculating target bounding box FROMCENTRALPOINTTOBB is a function that calculates the target bounding box given the centroid position and the size of the target INPUT: -centerX target's centroid coordinate (column in the image plane) -centerY target's centroid coordinate (row in the image plane) -width target's width -height target's height -maxX,maxY image limits OUTPUT -bb calculated bounding box in the format [topLeftY, topLeftX, bottomRightY, bottomRightX] read as [rowIndexTopLeft, columnIndexTopLeft, rowIndexBottomRight, columnIndexBottomRight] See also SINGLEFRAMEDSKCF, FROMCENTRALPOINTTOBB University of Bristol Massimo Camplani and Sion Hannuna massimo.camplani@bristol.ac.uk hannuna@compsci.bristol.ac.uk
0001 % FROMCENTRALPOINTTOBB.m is a function for calculating target bounding box 0002 % 0003 % FROMCENTRALPOINTTOBB is a function that calculates the target bounding 0004 % box given the centroid position and the size of the target 0005 % 0006 % INPUT: 0007 % -centerX target's centroid coordinate (column in the image plane) 0008 % -centerY target's centroid coordinate (row in the image plane) 0009 % -width target's width 0010 % -height target's height 0011 % -maxX,maxY image limits 0012 % 0013 % OUTPUT 0014 % -bb calculated bounding box in the format [topLeftY, topLeftX, 0015 % bottomRightY, bottomRightX] read as [rowIndexTopLeft, columnIndexTopLeft, 0016 % rowIndexBottomRight, columnIndexBottomRight] 0017 % 0018 % See also SINGLEFRAMEDSKCF, FROMCENTRALPOINTTOBB 0019 % 0020 % University of Bristol 0021 % Massimo Camplani and Sion Hannuna 0022 % 0023 % massimo.camplani@bristol.ac.uk 0024 % hannuna@compsci.bristol.ac.uk 0025 0026 function bb=fromCentralPointToBB(centerX,centerY,width,height,maxX,maxY) 0027 0028 bb(1)=max(1,centerX-width/2);%column indexes 0029 bb(2)=max(1,centerY-height/2);%row indexes 0030 bb(3)=min(maxX,centerX+width/2);%column indexes 0031 bb(4)=min(maxY,centerY+height/2);%row indexes 0032 bb=floor(bb(:)); 0033 end