I work with image processing in OpenCV in python. My main problem is light deflection. Can these deflections be removed with some method? I implemented a lot of code here, but cant find this particular lights deflections effect. 1)I implemented grayscale, sobel filter, median blur, histogram analysis for plates detections, but this deflections cause that my histogram is bad for edges from sobel filtering, removing these flashes cause that it should works good. An input image:
Asked
Active
Viewed 9,087 times
2
-
This question appears to be too broad. Have you done some research in this topic? – marol Jul 09 '14 at 07:38
-
Yes, i implemented a lot of code here, but cant find this particular lights deflections effect. 1)I implemented grayscale, sobel filter, median blur, histogram analysis for plates detections, but this deflections cause that my histogram is bad for edges from sobel filtering, removing these flashes cause that it should works good. – user2667455 Jul 09 '14 at 07:47
-
That's good, so please edit your question that everybody can see what have you tried. Here on stack overflow you should present at least some research you had done before posting any question to help everyone write better answers. – marol Jul 09 '14 at 07:51
-
And what about threshold operation? Have you tried Otsu Threshold method? I think it will definetely mark those areas with lot of light (like vehicle lights). – marol Jul 09 '14 at 07:55
-
Related: http://stackoverflow.com/a/23026349/2545927 – kkuilla Jul 09 '14 at 08:06
-
yes, but the problem is that, when on image plate is also in good light it will also mark this plate: – user2667455 Jul 09 '14 at 08:09
-
Can you identify the headlights/ front of the car? Then you could create a bounding box around that and do a histogram equalisation or something on the rest of the image. – kkuilla Jul 09 '14 at 08:09
-
I think that this is very good idea, thank You, but i have no idea how to create boudning box for cars. – user2667455 Jul 09 '14 at 08:11
-
I'm just thinking out loud now.. What can you identify? Can you identify the number plate? If so, you have a triangle between the headlights and the number plate. The angles between the headlights and the number plate should be fairly stable. You can then calculate the angle and the relative distance between the number plate and all your light objects. Exclude the ones that don't have the correct angles and relative distances. – kkuilla Jul 09 '14 at 08:15
-
1Read section III of [Vehicle Detection under Day and Night Illumination](http://imagelab.ing.unimore.it/imagelab/pubblicazioni/iia1999.pdf).I am suggesting something similar. Look at the angle between two light sources to detect the headlights. Remove all others. – kkuilla Jul 09 '14 at 08:36
1 Answers
10
Use a colorspace transformation. For instance, if you transform your image to the HSV space, you'll see the "light" components in the V("value") channel:
This is the HSV image:
This is the V channel:
This is the regions of the V channel above a certain level (i.e. a thresholded image):
Now, you can use this kind of stuff to get things done by removing the high values of this V channel, then merging the channels back again. Good luck!
NOTE: as you see, I'm not giving you the code. I think that this should be easy to program if you search the documentation on OpenCV's cvtColor
, split
/merge
or threshold
methods ;)

Яois
- 3,838
- 4
- 28
- 50
-
Could you explain how HSV would help, please? What would be the difference between this method and working on the grey scale? Your thresholding has segmented the headlights **and** the shadows and the requirement was to remove the shadows only... – kkuilla Jul 09 '14 at 08:18
-
-
i made these steps, but problem is for plate well lighted: http://postimg.org/image/ozw2z8nyn/ It also mark plate as area to remove – user2667455 Jul 09 '14 at 08:24
-
@kkuilla the binary image was just an example of how the V channel discriminates (the L channel in HSL too) brightness. However I'm just answering the OP question "Can these deflections be removed with some method?", not doing his/her work though. – Яois Jul 09 '14 at 08:25
-
i made these steps, but problem is for plate well lighted: http://postimg.org/image/ozw2z8nyn/ It also mark plate as area to remove – user2667455 Jul 09 '14 at 08:28
-
@user2667455 either your plate is to illuminated in the image or you chose a low threshold value. In the first case, there is nothing to do with this approach. Play with the threshold! ;) – Яois Jul 09 '14 at 08:28
-
@KeillRandor Fair enough. My thought was that using HSV doesn't add any value. It seems like we get the same result with thresholding HSV as you get with thresholding grey scale. – kkuilla Jul 09 '14 at 08:32
-
i will try play with thresholds, will write about result. THANK YOU GUYS!!!!! – user2667455 Jul 09 '14 at 08:33
-
@kkuilla I disagree. With a 3 channel image (BGR, HSV or whatever) you can have up to 3 times **more information** than using greyscale. In the particular case of HSV /HSL you can discriminate the illumination information from the color. In a greyscale image, everything is mixed and the amount of information per pixel about brightness is less. – Яois Jul 09 '14 at 08:49
-
@KeillRandor You answer suggest that we threshold the `V` component which, in my humble opinion, (and yes, I may be wrong) is very similar to thresholding a greyscale. I struggle to see differences between a greyscale version of the original image and the `V` component. I might be thick but I don't understand how the `V` component only (as suggested in the answer) adds any value. – kkuilla Jul 09 '14 at 09:01
-
@kkuilla I think this a very interesting discussion :) I am no expert in color representation at all, but I just don't see how a linear transformation (RGB2Gray) can be the same as the V channel in HSV, which comes from a nonlinear transformation. http://www.rapidtables.com/convert/color/rgb-to-hsv.htm – Яois Jul 09 '14 at 10:02
-
@kkuilla as an example, see this RGB picture http://en.wikipedia.org/wiki/HSL_and_HSV#mediaviewer/File:Fire_breathing_2_Luc_Viatour.jpg and the produced "V channel image": http://en.wikipedia.org/wiki/HSL_and_HSV#mediaviewer/File:Fire-breather_HSV_V.jpg – Яois Jul 09 '14 at 10:06
-
@KeillRandor Mathematically, yes you are right. They are different. Let me re-phrase my comment. I don't think the difference between `V` you show in the answer and a grey scale version of the original image is large enough to aid the removal of the reflection. That's what I really meant.. ;-) – kkuilla Jul 09 '14 at 10:45