Skip to content
Advertisement

Getting the colour of a particular pixel with opencv

I’m trying to determine the colour of a single pixel in an image using Python and OpenCV. However, when I read the BGR values from that pixel and use those same values to draw a circle back on the image, the colours do not match. Where am I going wrong?

JavaScript

Output:

Note the cyan circle drawn on the yellow rectangle in the centre of the image. I would have expected this circle to match the shape beneath.

JavaScript

the image shown by imshow()

Advertisement

Answer

The problem you have here is that you mixed x and y coordinates.
image has (y, x) so the point you took colors from is y,x.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement