Skip to main content
. 2023 Jul 19;23(14):6533. doi: 10.3390/s23146533
Algorithm 3: CalculatingHCT(img, dp, minDist, param1, param2, minRadius, maxRadius, centerx,  centery, radius)
//Detecting a circle to calculate the center of both CA and FA using HCT
Input
(1)   img: an input image
(2)   dp: The inverse ratio of the accumulator resolution to the image resolution
(3)   minDist: Minimum distance between the centers of the detected circles
(4)   param1:  The higher threshold of the two passed to the Canny edge detector
(5)   param2:  Accumulator threshold for the circle centers at the detection stage
(6)   minRadius: Minimum circle radius
(7)   maxRadius: Maximum circle radius
Output
(8)   centerx: x coordinate of the first circles center
(9)   centery: y coordinate of the first circles center
(10) radius: radius of the first circle
Begin
1.    grayConvertToGrayscale(img)
2.    bluredApplyGaussianBlur(gray)
3.    edgesApplyCannyEdgeDetection(blurred, param1)
4.    h, wget the height and width of edges
5.    accumulatorcreate a 3D zero array of size (h, w, maxRadius  minRadius)
6.    For each edge point xedge, yedge in edges do
7.    For r in rangeminRadius, maxRadius do
8.    For theta in range0, 360 do
9.    axedger costheta
10.  byedger sintheta
11.  If a and b are within the image boundaries then
12.  accumulatora, b, rminRadiusaccumulatora, b, rminRadius + 1
13.  End for
14.  End for
15.  End for
16.  max_accumulator_valuefind the maximum value in accumulator
17.  circlesfind the a, b, r such that accumulatora, b, r>param2  max_accumulator_value
18.  centerx, centery, radiuscircles0
19.  Return centerx, centery, radius
END