I wish to approximately count the total number of storage tanks (i.e. the white circles) in this satellite image.
I have tried using OpenCV to tackle this task, but I have been experiencing some problems. Here is my current code:
import numpy as np
import cv2
import matplotlib.pyplot as plt
image_color= cv2.imread("satellite.jpg")
lower_bound = np.array([0,0,10])
upper_bound = np.array([255,255,195])
image = image_color
mask = cv2.inRange(image_color, lower_bound, upper_bound)
mask = cv2.threshold(mask, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]
plt.imshow(mask)
circles = cv2.HoughCircles(image=mask, method=cv2.HOUGH_GRADIENT, dp=1.2,
minDist=1, param1=50, param2=50, minRadius=1,
maxRadius=10)
if circles is not None:
circlesRound = np.round(circles[0, :]).astype("int")
for (x, y, r) in circlesRound:
cv2.circle(image_color, (x, y), r, (0, 255, 0), 4)
plt.imshow(image_color)
else:
print ('No circles found')
But I'm getting no circles.
Sorry, I'm still really new to OpenCV. Any sort of insight would be greatly appreciated.
question from:
https://stackoverflow.com/questions/65894829/best-way-to-find-circles-in-image-using-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…