I have a problem with calculating thinness ratio. It gives me value of 0.9 instead of 1.
Thinness ratio is given as a
(4 * pi * area) / (perimeter * perimeter)
For circle, the above equation, should give a result 1.0.
import cv2
import math
image = cv2.imread("circle.png")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cnt = cv2.findContours(gray.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[1]
for c in cnt:
# compute the area of the contour along with the bounding box
# to compute the aspect ratio
area = cv2.contourArea(c)
perimeter = cv2.arcLength(c,True)
ti= (4*area*math.pi)/(perimeter**2)
print(ti)