Image processing in bright lights

We are working on a project which requires us to detect and hit a ball. We are trying to accomplish the task by detecting the position of ball by processing the input from a camera. The problem is that we are required to do this in very bright lights. The bright lights are making it difficult to detect the white colored ball.

1. Is there a way we can write the code such that it automatically reduces the intensity of lights in the image?
2. Is there an efficient way to extract only the V component from the HSV image?

We have very limited experience with image processing so any alternative approach to detecting the object will also be helpful

• Why slam has been tagged? Oct 22 '14 at 9:15
• @croco removed the slam tag. Oct 22 '14 at 14:00

First, you need to identify whether your camera is up to the task or not. If the camera, seeing the very bright lights, just gives you a complete "white" for all different colors, there is absolutely nothing you can do in software to compensate for it.

That said, the first step is to adjust your camera. If you don't want to get in the coding yet, just take a photo of your bright lights with that camera, open it with gimp for example and reduce its brightness. If you as a human can start to distinguish the colors, then you can also do that in software. If reducing brightness simply gives you gray color, then the color information is simply lost at the time the camera took the photo.

Take this with a grain of salt though, as taking a photo with the camera and a video are different things.

Solution 1: If your camera is controllable, you might be able to change settings on it to reduce the sensor exposures to light before producing the image/video. This completely solves your problem, because then it's as if you are not in bright lights any more.

Solution 2: If you can distinguish colors, even if barely, then you can process the image by your own software and reduce the brightness. For this, you need to convert the format of the image received by your camera to HSL and then reduce the Lightness before converting it back to the format your image processing algorithm understands. If your camera outputs RGB for example, you can search for "RGB to HSL" on the internet for code in many languages freely available.

You may be getting ahead of yourself; this seems to be a mostly photography-based question. It sounds like you have a setup like this:

light source -> scene with ball -> camera -> computer -> ball-hitting program


You should be troubleshooting this from left to right, starting with the light source (which it sounds like you already did -- it can't be changed).

The next step would be to see if you can change the scene itself -- use a different ball color to hopefully get more contrast.

If that's not possible, see if the camera settings can be adjusted to make the ball easier to see (in other words, look through the camera yourself to see whether the image is OK).

And if the camera can't be improved, then you'd be stuck with writing some image pre-processing code to somehow turn up the contrast to the point where you can see the ball.