422,904 Members | 1,030 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,904 IT Pros & Developers. It's quick & easy.

how to know metrix(x,y) of color in the image with OpenCV

P: 1
i would like to know position of color
EX. i draw rectangle (10,10) to (256,256) green color
and i print(img[10,10]) >> [255,0,0]
but i need to know where position is [255,0,0]
if i have the image some point is green but i don't know position


import cv2
import numpy as np
img = cv2.imread('BG-Black.jpg')

cv2.rectangle(img,(10,10),(256,256),(0,0,255),-1)
cv2.circle(img,(10,10),2,(255,0,0),-1)
cv2.circle(img,(10,256),2,(255,0,0),-1)
cv2.circle(img,(256,10),2,(255,0,0),-1)
cv2.circle(img,(256,256),2,(255,0,0),-1)

print((img[20,20]))

print([0,0,255])

cv2.imshow("img",img)
cv2.waitKey()
cv2.destroyAllWindows()
5 Days Ago #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.