加入2个表格后计算百分比

时间:2018-11-10 20:02:41

标签: apache-pig

我有两个表,我想查看每本书的客户总数和性别总数。找到之后,我想获得性别客户的百分比。

img = cv2.imread(image_path)
img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
blur = cv2.GaussianBlur(img, (1, 1), 1000)
flag, thresh = cv2.threshold(blur, 120, 255, cv2.THRESH_BINARY)
im2, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
contours = sorted(contours, key=cv2.contourArea, reverse=True)[:1]
perimeters = [cv2.arcLength(contours[i],True) for i in range(len(contours))]
listindex=[i for i in range(1) if perimeters[i]>perimeters[0]/2]
num_of_layers = len(listindex)
imgcont = img.copy()
[cv2.drawContours(imgcont, [contours[i]], 0, (0,255,0), 5) for i in listindex]
M = cv2.moments(contours[0])
cx = int(M['m10']/M['m00'])
cy = int(M['m01']/M['m00'])
plt.plot(cx,cy)
plt.imshow(imgcont, cmap='gray')   

0 个答案:

没有答案