Ask Your Question

Distinguishing between white and luminous objects

asked 2018-05-11 08:41:49 -0500

malharjajoo gravatar image

updated 2018-05-23 06:26:47 -0500


Update: Sample Image -

image description image description


I am trying to detect moving white LEDs (non-blinking, always ON) but am having some difficulties when it comes to distinguishing the LEDs from a white object of similar size. The issue is that some of the LEDs appear smaller than the other's (due to varying distances from the camera) and hence making it hard to distinguish them from random white specks.

I did attempt to use sparse optical flow but the issue is with drone's jerky movement, the optical flow tracking loses the points easily.

My current thresholding method: I am currently using simple HSV based thresholding followed by erosion/dilation to detect the LEDs and then fit a contour + bounding rectangle around it.

My question: Is there some colour space (something like LAB perhaps as seen in this tutorial ?) that allows one to distinguish between white coloured and luminous objects ?

edit retag flag offensive close merge delete


Your problem sounds interesting enough. Did you know that in HSV mode, white pixels have a red hue by default? Perhaps you need to differentiate between an almost white with a blue hue, and white with a red hue.

sjhalayka gravatar imagesjhalayka ( 2018-05-11 09:53:31 -0500 )edit

do you have some sample images so we can see what you mean (for example if leds are saturated)

bennog gravatar imagebennog ( 2018-05-12 05:00:05 -0500 )edit

Hi, thanks for replying, I have updated the question with sample images. My main issue is avoiding clutter gets harder as LEDs are at varying distances from the camera.

malharjajoo gravatar imagemalharjajoo ( 2018-05-23 06:27:31 -0500 )edit

Hi, thanks for replying, I have updated the question with sample images. My main issue is avoiding random white specks gets harder as LEDs are at varying distances (and hence some appear smaller) to the camera.

malharjajoo gravatar imagemalharjajoo ( 2018-05-23 06:27:48 -0500 )edit

1st reduce shutter time or close diafragma so image gets a lot darker (the white background is almost saturated) 2nd look for the 4 most brightest spots (combination V and Blue)

If you have the skills replace the white leds for IR leds and put IR fiter in front of the camera (possible need to remove ir cut-off filter from the camera)

bennog gravatar imagebennog ( 2018-05-23 06:50:18 -0500 )edit


My experiment is using LED in visible spectrum, IR leds would have been easy to detect (although I dont see much support in openCV for that ). And how can I reduce shutter time ? These are network/IP cameras.

malharjajoo gravatar imagemalharjajoo ( 2018-05-24 00:37:41 -0500 )edit

Hello, did anyone find a decent solution for this ? I tried using sparse optical flow on the HSV thresholded image, but it gives quite poor results as it only tracks corners very well. I also tried a few other thigns like image histogram equalization ... but they didnt work either.

malharjajoo gravatar imagemalharjajoo ( 2018-06-03 09:40:27 -0500 )edit

can you close the diafragma more ? And then add the darker images to the question. The problem you have now is saturation of the leds.

bennog gravatar imagebennog ( 2018-06-03 09:59:24 -0500 )edit

If you want to do it the lazy way use threshold (252,252,252) on the BGR image.

bennog gravatar imagebennog ( 2018-06-03 10:01:54 -0500 )edit

Hi, I would prefer a more robust solution .... I thought this would have been a common problem, but seems that is not the case...

malharjajoo gravatar imagemalharjajoo ( 2018-06-03 13:14:34 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-05-23 12:14:50 -0500

I tried color detection on Rubik's cube using RGB. Many interesting details. For example, component proportion changes with change of brightness. Also white color has not equal R, G, and B values. This means that these 3 values form a fingerprint. As you have LED, brightness will not change and you will be able to distinguish it from different white colors.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-05-11 08:41:49 -0500

Seen: 408 times

Last updated: May 23 '18