3

I'm doing a real time image processing at about 20 FPS. I'm trying to filter 3 colors (using opencv, python). Those are: red, blue and yellow from a frame in which the light is not always constant (meaning sometimes the ambiental light can make my red pixel (B=119, G=84, R=199), and sometimes (R=60, G=0, B=0) - this is when the light comes right in front of the camera).

I know about a formula like so : if 2R-B-G is grater or equal to 0, then the pixel will go high (it remains unchanged). If the pixel goes negative, i should make it black. The problem is that this involves a pixel by pixel processing and i'm not sure it is what i'm searching for. I would like to try this approach but i don't know how could i do it a little bit faster (masking and cv2.bitwise_and() after each pixel checked is the only ideea that I have, and it will take ages)

For the moment, i am just creating a binary_mask

cv2.inRange(bgr_sliced_img, (low_blue, low_green, low_red), (upper_blue, upper_green, upper_red))

The problem with this is that it is impossible to adjust the parameters so that i get the red /blue/ yellow values visible in darker images as well as in bright images without seeing other wrong objects.

I've read this and i don't really know how could i use the median intensity in my frame. I think this is close to what i want, but i have no ideea how could i implement this.

I will provide 3 pictures that ilustrates the problem . The traffic stop sign is red, but because of ambiental light, its red is changed.

I would like to find some algorithm that will "see" the red color in each 3 pictures without the need of manual modifying parameters.

*I should mention that i'm searching for the traffic sign in a region of interest of about 100x100 pixels, not in the entire image

STOP_C

STOP_B

STOP_A

Cătălina Sîrbu
  • 1,253
  • 9
  • 30

0 Answers0