The picture above is the sample input I am taking and I want to find the coordinates of all the red pixels in this image and store it in a list and then, later on, iterate this list and draw circles around each of the coordinates which we found above in the image using OpenCV's cv2.circle function. I am doing the following:
coord = []
for i in range(img.shape[0]):
for j in range(img.shape[1]):
if img[i,j,0]!=0 and img[i,j,1]!=0 and img[i,j,2]!=255:
img[i,j,0]=0
img[i,j,1]=0
img[i,j,2]=0
else:
img[i,j,0]=0
img[i,j,1]=0
img[i,j,2]=255
coord.append([i,j])
for l in range(len(coord)):
px=coord[l][0]
py=coord[l][1]
cv2.circle(img,(px,py),5,(0,255,255),1)
But doing the above isn't making a circle on all the coordinates. I guess there is something wrong with the storing of coordinates and accessing them. Can anyone point out the error and help me please.