i am using python with opencv and numpy, to detect stars in astronomical for example this one1 images. Using template matching I have got it to detect stars with a threshold (click the 2) 2 by drawing a rectangle around a star template. My next goal is to essentially "remove" the stars from the image.
To do this, I have tried blurring the image with different methods, cv2.blur etc, but it doesn't create the effect i am looking for. My next idea was to get rgb data from pixels around the star, average them out, and color in the star with the selected colour. Is this the best option and how would i do this?
my code is as below.
import cv2
import numpy as np
import time
start = time.time()
threshold = 0.4
image = cv2.imread('lag.jpg')
imageG = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
#cv2.imshow('original', image)
#cv2.imshow('greyscale', imageG)
template = cv2.imread('template.jpg', 0)
w, h = template.shape[::-1]
res = cv2.matchTemplate(imageG,template,cv2.TM_CCOEFF_NORMED)
loc = np.where( res >= threshold)
for pt in zip(*loc[::-1]):
a = cv2.rectangle(image, pt, (pt[0] + w, pt[1] + h), (0,0,255), 1)
cv2.imshow('lag.jpg', image)
end = time.time()
final = end - start
print(final)
cv2.waitKey(0)
cv2.destroyAllWindows()