1

I am trying to distinguish car lights from the light reflection from street at night images. For example, in an image like this:

enter image description here

I tried changing to some other color spaces, but it didn't work. For example, cvtColor(image, gray, CV_HSV2BGR_FULL); made it like:

enter image description here

However, in this post it works fine. Is there any way I can do something similar for this image? I am using OpenCV3.1 with C++ on Windows (Python would also be great).

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Hadi GhahremanNezhad
  • 2,377
  • 5
  • 29
  • 58
  • 1
    It looks to me like the other post works because there is a significant difference between the values of the white headlights and the grey of the reflected light. In the image you are showing, the white of the headlight and the reflected light are very nearly the same value. (If you have access to the RAW format, you might be able to change that; maybe.) Can you work with shapes, instead? – Van Jun 18 '19 at 16:53
  • 1
    The other post uses a color video source, whereas your source looks grayscale even though there is blue lettering at the top. That means color space conversions may be less helpful. – rob3c Jun 18 '19 at 17:28
  • @rob3c the source image here is actually RGB, but with low quality. I think that is the problem. – Hadi GhahremanNezhad Jun 18 '19 at 18:15
  • @Van thank you! It seems you are right about that. – Hadi GhahremanNezhad Jun 18 '19 at 18:18

1 Answers1

1

In general, a reflection is a light source. As far as light propagation is concerned, the light source is the direction the photons are coming from. It might be a source or a reflection.

Thus, a better view on the problem would be to think more about what you are trying to detect. In the post you referenced, the problem is much simpler, since the reflections are not blown out (reaching maximum brightness), while the light sources are (or they are close enough). In your image, due to the low quality of the capture, the reflections and the light sources have similar brightness.

To emphasize why this is a problem, your approach is a local approach. Think about a very small patch (e.g. 3x3 pixels) from your image. Could you tell if it's from a reflection or not?

Therefore, a better view would be to think about shapes. You want to detect car lights, which seem to be round, of about the same size and white.

I would suggest something like a blob detector finely tuned to your problem, or to use your technique to threshold the image, and then run a CCA and measure the circularity/size of the components.

You can also consider doing some cropping/filling in the city lights with black since the camera seems fixed.

Paul92
  • 8,827
  • 1
  • 23
  • 37