function Proc = ImagePropertiesInitial(objectID,labeled)
% **********************************************************************************
% *
% * ImagePropertiesInitial(objectID,labeled)
% *
% * objectID = object id
% * labeled = labeled image
% *
% * This function is used to detect the badminton racket among named objects.
% * It uses shape descriptors to detect the badminton racket. It will return some
% * properties of the badminton racket too.
% *
% * Return Values
% *
% * arrOutPut(1) = objectID;
% * arrOutPut(2) = cameraDistance;
% * arrOutPut(3) = majorDist;
% * arrOutPut(4) = minorDist;
% * arrOutPut(5) = rotationAngle;
% *
% * arrOutPut(6) = topY;
% * arrOutPut(7) = bottomY;
% * arrOutPut(8) = leftX;
% * arrOutPut(9) = rightX;
% *
% *
% *
% * Author - I. Janaka Prasad Wijesena
% *
% **********************************************************************************
% this is the size of the image
imageSize = size(labeled);
% now we are going to calculate the avarage of the points. doing this we
% get the center of gravity of the bat. and it is on the bat !!!
gravX = 0;
gravY = 0;
topY = -1;
bottomY = -1;
leftX = -1;
rightX = -1;
area = 0;
rotationAngle = 0;
for m = 1:imageSize(1)
for n = 1:imageSize(2)
if labeled(m,n) == objectID
area = area + 1;
if (topY > m) | (topY == -1)
topY = m;
end
if bottomY < m
bottomY = m;
end
if (leftX > n) | (leftX == -1)
leftX = n;
end
if rightX < n
rightX = n;
end
end
end
end
% round them up
gravX = round((leftX + rightX)/2);
gravY = round((topY + bottomY)/2);
% -------------------------------------------------------------------------------------------------------
% function Proc = ImageEdge(labeled,xLength,yLength,gX,gY,addX,addY)
% move up from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,0,1,gravX,gravY,1,0,objectID);
upPointX = edgePoint(1);
upPointY = edgePoint(2);
% move 1-5 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,5,gravX,gravY,1,0,objectID);
upRightPoint15X = edgePoint(1);
upRightPoint15Y = edgePoint(2);
% move 1-2 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,2,gravX,gravY,1,0,objectID);
upRightPoint12X = edgePoint(1);
upRightPoint12Y = edgePoint(2);
% move 3-3 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,1,gravX,gravY,1,0,objectID);
upRightPoint33X = edgePoint(1);
upRightPoint33Y = edgePoint(2);
% move 2-1 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,2,1,gravX,gravY,1,0,objectID);
upRightPoint21X = edgePoint(1);
upRightPoint21Y = edgePoint(2);
% move 5-1 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,5,1,gravX,gravY,1,0,objectID);
upRightPoint51X = edgePoint(1);
upRightPoint51Y = edgePoint(2);
% -------------------------------------------------------------------------------------------------------
% move up from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,0,gravX,gravY,1,1,objectID);
rightPointX = edgePoint(1);
rightPointY = edgePoint(2);
% move 1-5 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,5,gravX,gravY,1,1,objectID);
downRightPoint15X = edgePoint(1);
downRightPoint15Y = edgePoint(2);
% move 1-2 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,2,gravX,gravY,1,1,objectID);
downRightPoint12X = edgePoint(1);
downRightPoint12Y = edgePoint(2);
% move 3-3 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,1,gravX,gravY,1,1,objectID);
downRightPoint33X = edgePoint(1);
downRightPoint33Y = edgePoint(2);
% move 2-1 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,2,1,gravX,gravY,1,1,objectID);
downRightPoint21X = edgePoint(1);
downRightPoint21Y = edgePoint(2);
% move 5-1 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,5,1,gravX,gravY,1,1,objectID);
downRightPoint51X = edgePoint(1);
downRightPoint51Y = edgePoint(2);
% -------------------------------------------------------------------------------------------------------
% move up from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,0,1,gravX,gravY,1,1,objectID);
downPointX = edgePoint(1);
downPointY = edgePoint(2);
% move 1-5 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,5,gravX,gravY,0,1,objectID);
downLeftPoint15X = edgePoint(1);
downLeftPoint15Y = edgePoint(2);
% move 1-2 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,2,gravX,gravY,0,1,objectID);
downLeftPoint12X = edgePoint(1);
downLeftPoint12Y = edgePoint(2);
% move 3-3 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,1,gravX,gravY,0,1,objectID);
downLeftPoint33X = edgePoint(1);
downLeftPoint33Y = edgePoint(2);
% move 2-1 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,2,1,gravX,gravY,0,1,objectID);
downLeftPoint21X = edgePoint(1);
downLeftPoint21Y = edgePoint(2);
% move 5-1 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,5,1,gravX,gravY,0,1,objectID);
downLeftPoint51X = edgePoint(1);
downLeftPoint51Y = edgePoint(2);
% -------------------------------------------------------------------------------------------------------
% move up from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,0,gravX,gravY,0,1,objectID);
leftPointX = edgePoint(1);
leftPointY = edgePoint(2);
% move 1-5 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,5,gravX,gravY,0,0,objectID);
upLeftPoint15X = edgePoint(1);
upLeftPoint15Y = edgePoint(2);
% move 1-2 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,2,gravX,gravY,0,0,objectID);
upLeftPoint12X = edgePoint(1);
upLeftPoint12Y = edgePoint(2);
% move 3-3 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,1,1,gravX,gravY,0,0,objectID);
upLeftPoint33X = edgePoint(1);
upLeftPoint33Y = edgePoint(2);
% move 2-1 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,2,1,gravX,gravY,0,0,objectID);
upLeftPoint21X = edgePoint(1);
upLeftPoint21Y = edgePoint(2);
% move 5-1 from the gravity till you come to edge, record it
edgePoint = ImageEdge(labeled,5,1,gravX,gravY,0,0,objectID);
upLeftPoint51X = edgePoint(1);
upLeftPoint51Y = edgePoint(2);
% -------------------------------------------------------------------------------------------------------
totalDistance = sqrt((upPointX-upRightPoint15X)*(upPointX-upRightPoint15X) + (upPointY-upRightPoint15Y)*(upPointY-upRightPoint15Y)) + sqrt((upRightPoint12X-upRightPoint15X)*(upRightPoint12X-upRightPoint15X) + (upRightPoint12Y-upRightPoint15Y)*(upRightPoint12Y-upRightPoint15Y)) + sqrt((upRightPoint12X-upRightPoint33X)*(upRightPoint12X-upRightPoint33X) + (upRightPoint12Y-upRightPoint33Y)*(upRightPoint12Y-upRightPoint33Y)) + sqrt((upRightPoint21X-upRightPoint33X)*(upRightPoint21X-upRightPoint33X) + (upRightPoint21Y-upRightPoint33Y)*(upRightPoint21Y-upRightPoint33Y)) + sqrt((upRightPoint21X-upRightPoint51X)*(upRightPoint21X-upRightP