I'm working on finding coordinates using color, let's say blue in my case, and giving out the coordinates of that point in the image which has that color.
I'm using this code:
#!/usr/bin/env python3
import cv2
import numpy as np
#Load image
img = cv2.imread('image.png')
#Define the blue color we want to find
blue = [255,0,0]
#Get X and Y cooridinates of ALL blue pixels
X,Y = np.where(np.all(img==blue, axis=2))
zipped = np.column_stack((X,Y))
#Get the number of coordinates founded
print(len(zipped))
I'm getting all the pixels colored in the blue region while I'm in need of just one coordinate in that specific location.
This image contains image_with_blue_coordinates the coordinates in blue (but every blue point contains at least 6-to-8 blue pixels) so I'm getting all of the coordinates, while I need just the center pixel.
Any idea on how to deal with this issue and get only 36 x,y coordinates instead of 1342?
Thanks in advance
Reference : Find the coordinates in an image where a specified colour is detected