Remove shadow edges from image

Hi guys,

Hoping for some advice on how I might possibly solve this one

I have an image which has the edges of an object but it also has false edges that are from the shadow cast from the light on the object. What techniques are available that can be used to remove the shadow edges reliably but leave the real edges?

A few things come to mind but interested in other peoples thoughts

  • Possibly find the outer contour of the object and then the next one inside it should be the real contour / edge I need. I could use findcontours and hierarchy option in opencv- I don’t think it will work that well as the shadow edges touch the real edges
  • Check for what is moving in the image and remove those edges? I think I’d possibly need more LEDs surrounding the part? not sure how best to implement this

My setup is the following. single LED at 6 o clock to the camera but I could add more LEDs if it simplified things

Thanks

Yep. Removing shadows using better lighting can be easier. If your object is colored, you could also get the contours from the chroma plane (HS from HSV or AB from LAB).

Can you post some images?

Difficult to upload an image as the part is under an NDA.

What I can say is that the part is highly reflective - like a mirror so colour is not an option as the light from above gets reflected all over the place. I’m only interested in the edges to match a CAD model to it. This part works. Just need to get rid of the false edges due to the shadows.

Does that help or do you really need an image of some sort to get a better feel for the problem?

an image would be incredibly more helpful than paraphrasing.

it should be the data you have to deal with. if you have to show us data that you don’t use (“random examples from the internet”), please make sure they’re as close to your situation as humanly possible. I’m saying that to ward off problems because this is a common issue with people looking for help.

I agree - OK so let me get you an image I can show that better explains the problem

Ok - a very simple part but hopefully it shows you the problem. The part look like a table on its side in real life. (Have to break it up into 4 posts as I don’t have rights to upload in one post)


Image above with lighting LED at 6 o clock


Image above shows the edges based upon the image above it

image_with_no shadows
Image of object with coaxial light - no shadows but not practical for our setup so we have to use LEDs from anges


The edges we actually want - (I can filter out the small noise edges). If you look at the difference between this one and the other edge image, you can see the extra edges that are shadows that I am trying to remove (on the top and right hand side of the part)

so you want to deal with edges, not levels. and you don’t want edges from shadows.

you don’t need to remove the shadow, just soften it. that means no direct lighting. bounce the light off a diffuse surface. a softbox gives you soft lighting/shadows.

since object and background are of the same brightness, which gives poor contrast, I’d also recommend changing that.

Hi,

Sorry missed your reply. We have been looking a flat dome lights etc that might be able to get rid of the shadows but these lights are expensive and operating distance may be an issue.

Suppose we had no option but to light the part using our existing LED setup which resulted in shadows. Are there any techniques / approached that work well in removing theses shadow edges. The only one I know off is multi flash where you take images with LEDs at certain angles (north ,south, east & west) and process to produce a depth edge map. Any other alternatives? (both traditional and deep learning.

Thanks in advance

You can try a DIY solution using a tracing paper, white sheet, or other matte translucent material. Or buy a cheap led panel used for camera lighting on Amazon (~20$)

OK - So basically it looks like it’s not possible to solve this in the software world by processing the image in some way after taking the image. Would that be fair to say based upon your feedback?

To say that it’s “impossible” you should make some research in the publications (so I don’t recommend putting this thread as a reference in a PhD thesis).

But it’s sure that you need some extra information, not just “there’s some shadow somewhere in the image and it needs to be eliminated”.

My experience of over 15 years in the field says, that it’s always easier to get better images and process them than to process some complicated scenes.

Another solution I can think of could be to change the color of the background. For example if you use black background, the shadow issue is solved.

Appreciate the inputs. I would agree with you. Acquiring an image that is shadow free is much easier than trying to solve the problem afterwards. I’ll put some more effort into how we light the scene

Can you use two sets of LED lights, and take two images, one with LED1, and the second with LED2? position the two LEDs in opposite to each other ( 0, and 180 degrees on the object ).
Then, you should be able to negate one image from another, and the object you want should be visible in the result.

OK interesting - I can take 2 images with 2 LEDs 180 from each other.

In terms of negating the image could you just give me your thoughts on this approach and some high level details. Or do you mean “Anding” the images together so what is commong in both carries through to the final image?

you can try taking the pixelwise max. do not add, do not subtract.

for any pixel that is in shadow in one picture but illuminated in the other, it will make the pixel look illuminated.

OK - that’s a very good idea - I could see how that could work!

pixelwise max is a good idea.
Another one: If you know which side is ‘better’ in each image, you can split the two images, and merge the “good” sides.