1 year ago

#385976

test-img

subUser

How to detect some pixels with desired color?

I have a problem: There is a map where crystals randomly appear and I somehow need to find crystal coordinates(need only one crystal's pixel coordinate), I tried to do it by the color of a specific pixel, but after some time, the pixel shade appears and it does not find it (with axis = 2). Can anyone help I would be very grateful.Maybe some size parameter should be used as it doesn't change. (python)

import cv2
import numpy as np

im = cv2.imread('photos\\temp_3.png')

# Define the blue colour we want to find - remember OpenCV uses BGR ordering
crystal = [0,248,0]

# Get X and Y coordinates of all blue pixels
Y, X = np.where(np.all(im==crystal,axis=2))

print(X, Y)

photo examples:

enter image description here

enter image description here

enter image description here

python

opencv

computer-vision

0 Answers

Your Answer

Accepted video resources