import cv2
import numpy as np
im = cv2.imread("img/8.bmp")
im_o = cv2.resize(im, (800, 600))
im_gauss = cv2.cvtColor(im_o, cv2.COLOR_RGB2GRAY)
im_gauss = cv2.GaussianBlur(im_gauss, (7, 7), 0)
ret, im = cv2.threshold(im_gauss, 30, 255, 0)
cv2.imshow("o", im)
params = cv2.SimpleBlobDetector_Params()
params.minThreshold = 10
params.maxThreshold = 200
params.filterByArea = True
params.minArea = 16
params.filterByCircularity = True
params.minCircularity = 0.3
params.filterByConvexity = True
params.minConvexity = 0.67
params.filterByInertia = True
params.minInertiaRatio = 0.01
ver = (cv2.__version__).split('.')
if int(ver[0]) < 3:
detector = cv2.SimpleBlobDetector(params)
else:
detector = cv2.SimpleBlobDetector_create(params)
keypoints = detector.detect(im)
im_with_keypoints = cv2.drawKeypoints(im_o, keypoints, np.array([]), (0, 0, 255),
cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)
import numpy as np
import cv2
import matplotlib.pyplot as plt
image = cv2.imread("img/2.bmp", 0)
image1 = cv2.imread("img/2.bmp")
image2 = cv2.resize(image, (800, 600))
cv2.imshow('image1', image2)
circle1 = np.zeros(image.shape[0:2], dtype="uint8")
cv2.circle(circle1, (625, 500), 210, 255, -1)
circle2 = np.zeros(image.shape[0:2], dtype="uint8")
cv2.circle(circle2, (625, 505), 252, 255, -1)
bitwiseXor = cv2.bitwise_xor(circle1, circle2)
mask = bitwiseXor
masked = cv2.bitwise_and(image, image, mask=mask)
im_o = cv2.resize(masked, (800, 600))
im_gauss = cv2.GaussianBlur(masked, (3, 3), 0)
canny = cv2.Canny(im_gauss, 120, 240)
canny1 = cv2.resize(canny, (800, 600))
cv2.imshow('Canny', canny1)
circles = cv2.HoughCircles(canny, cv2.HOUGH_GRADIENT, 1, 10, param1=240, param2=10, minRadius=2, maxRadius=50)
circles = np.uint16(np.around(circles))
for i in circles[0, :]:
cv2.circle(image1, (i[0], i[1]), i[2], (0, 0, 255), 2)
image2 = cv2.resize(image1, (800, 600))
cv2.imshow("HoughCircle", image2)
cv2.waitKey(0)
import numpy as np
import cv2
import matplotlib.pyplot as plt
image = cv2.imread("img/1.bmp", 0)
image1 = cv2.imread("img/1.bmp")
image2 = cv2.resize(image, (800, 600))
cv2.imshow('image1', image2)
circle1 = np.zeros(image.shape[0:2], dtype="uint8")
cv2.circle(circle1, (633, 543), 249, 255, -1)
circle2 = np.zeros(image.shape[0:2], dtype="uint8")
cv2.circle(circle2, (633, 543), 259, 255, -1)
bitwiseXor = cv2.bitwise_xor(circle1, circle2)
mask = bitwiseXor
masked = cv2.bitwise_and(image, image, mask=mask)
im_o = cv2.resize(masked, (800, 600))
im_gauss = cv2.GaussianBlur(masked, (3, 3), 0)
ret, im = cv2.threshold(im_gauss, 60, 255, 0)
cv2.imshow('threshold', im)
kernel = np.ones((3, 3), np.uint8)
opening = cv2.morphologyEx(im, cv2.MORPH_OPEN, kernel)
opening = cv2.morphologyEx(opening, cv2.MORPH_OPEN, kernel)
canny = cv2.Canny(opening, 100, 200)
canny1 = cv2.resize(canny, (800, 600))
cv2.imshow('Canny', canny1)
circles = cv2.HoughCircles(canny, cv2.HOUGH_GRADIENT, 1, 10, param1=200, param2=5, minRadius=6, maxRadius=11)
circles = np.uint16(np.around(circles))
for i in circles[0, :]:
cv2.circle(image1, (i[0], i[1]), i[2], (0, 0, 255), 2)
image2 = cv2.resize(image1, (800, 600))
cv2.imshow("HoughCircle", image2)
cv2.waitKey(0)
import cv2
import numpy as np
image = cv2.imread("img/4.bmp")
image1 = cv2.resize(image, (800, 600))
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow('image1', image1)
circle1 = np.zeros(image.shape[0:2], dtype="uint8")
cv2.circle(circle1, (628, 493), 211, 255, -1)
circle2 = np.zeros(image.shape[0:2], dtype="uint8")
cv2.circle(circle2, (628, 493), 256, 255, -1)
bitwiseXor = cv2.bitwise_xor(circle1, circle2)
mask = bitwiseXor
masked = cv2.bitwise_and(image, image, mask=mask)
im_o = cv2.resize(masked, (800, 600))
im_gauss = cv2.GaussianBlur(im_o, (7, 7), 0)
ret, im = cv2.threshold(im_gauss, 180, 255, 0)
canny = cv2.Canny(im, 64, 128)
cv2.imshow('Canny', canny)
circles = cv2.HoughCircles(canny, cv2.HOUGH_GRADIENT, 1, 10, param1=128, param2=3, minRadius=1, maxRadius=0)
circles = np.uint16(np.around(circles))
for i in circles[0, :]:
cv2.circle(image1, (i[0], i[1]), i[2], (0, 0, 255), 2)
cv2.imshow("HoughCircle", image1)
cv2.waitKey(0)
import cv2
import numpy as np
image = cv2.imread("img/7.bmp")
image1 = cv2.resize(image, (800, 600))
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow('image1', image1)
circle1 = np.zeros(image.shape[0:2], dtype="uint8")
cv2.circle(circle1, (655, 447), 122, 255, -1)
mask = circle1
masked = cv2.bitwise_and(image, image, mask=mask)
im_o = cv2.resize(masked, (800, 600))
im_gauss = cv2.GaussianBlur(im_o, (3, 3), 0)
ret, im = cv2.threshold(im_gauss, 80, 255, 0)
canny = cv2.Canny(im, 100, 200)
cv2.imshow('Canny', canny)
circles = cv2.HoughCircles(canny, cv2.HOUGH_GRADIENT, 1, 20, param1=200, param2=6, minRadius=3, maxRadius=10)
circles = np.uint16(np.around(circles))
for i in circles[0, :]:
cv2.circle(image1, (i[0], i[1]), i[2], (0, 0, 255), 2)
cv2.imshow("HoughCircle", image1)
cv2.waitKey(0)
import cv2
import numpy as np
image = cv2.imread("img/3.bmp")
image1 = cv2.resize(image, (800, 600))
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow('image1', image1)
circle1 = np.zeros(image.shape[0:2], dtype="uint8")
cv2.circle(circle1, (605, 529), 246, 255, -1)
circle2 = np.zeros(image.shape[0:2], dtype="uint8")
cv2.circle(circle2, (605, 529), 204, 255, -1)
bitwiseXor = cv2.bitwise_xor(circle1, circle2)
mask = bitwiseXor
cv2.imshow('Mask', mask)
masked = cv2.bitwise_and(image, image, mask=mask)
im_o = cv2.resize(masked, (800, 600))
im_gauss = cv2.GaussianBlur(im_o, (3, 3), 0)
ret, im = cv2.threshold(im_gauss, 180, 255, 0)
canny = cv2.Canny(im, 64, 128)
cv2.imshow('Canny', canny)
circles = cv2.HoughCircles(canny, cv2.HOUGH_GRADIENT, 1, 10, param1=128, param2=5, minRadius=1, maxRadius=0)
circles = np.uint16(np.around(circles))
for i in circles[0, :]:
cv2.circle(image1, (i[0], i[1]), i[2], (0, 0, 255), 2)
cv2.imshow("HoughCircle", image1)
cv2.waitKey(0)
import cv2
import numpy as np
image = cv2.imread("img/5.bmp")
image2 = cv2.resize(image, (800, 600))
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image = cv2.circle(image, (644, 503), 293, 0, -1)
image1 = cv2.resize(image, (800, 600))
cv2.imshow('image1', image1)
im_gauss = cv2.GaussianBlur(image1, (3, 3), 0)
ret, im = cv2.threshold(im_gauss, 40, 255, 0)
cv2.imshow("o", im)
canny = cv2.Canny(im, 50, 100)
cv2.imshow('Canny', canny)
circles = cv2.HoughCircles(canny, cv2.HOUGH_GRADIENT, 1, 20, param1=100, param2=7, minRadius=6, maxRadius=1)
circles = np.uint16(np.around(circles))
for i in circles[0, :]:
cv2.circle(image2, (i[0], i[1]), i[2], (0, 0, 255), 2)
cv2.imshow("HoughCircle", image2)
cv2.waitKey(0)