Removing a shadow from an image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
shadow_man
Posts: 2
Joined: 2018-08-15T15:27:00-07:00
Authentication code: 1152

Removing a shadow from an image

Post by shadow_man »

Hi there,

I've been trying to remove a shadow from an image for some time as well as make the background transparent, but have had a great deal of difficulty.

Here are two starter images:
Image

and
Image

I have been successful in removing backgrounds and making these images transparent, seen in cases here:

Image
and
Image respectively.

This was done using this script:

Code: Select all

convert Last\ Shot\ \(2018\)-f6179a7a-7b21-41a5-87bf-885268f78e04\ \(1\).jpg -alpha set -bordercolor white -border 1 -fill none -fuzz 3% -draw "color 0,0 floodfill" result1_fill.png
However, the bottom shadow has been a real tricky problem to solve, mainly because it is not entirely black, and although always at the bottom of the shoe, it never fully is one colour or another, or is sometimes blocked by a shoe part.

I was thinking of setting up a meta mask and cutting off the bottom of the shoes, but this didn't work as I expected. I then tried adding a background of black with a higher than usual fuzz (around 10%) to try and get the background and shadow all one colour. Once done, i was going to set the black to transparent. Yet this did not work either.

Anyone have any suggestions that could help?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Removing a shadow from an image

Post by fmw42 »

Shadows are particularly hard to remove as per isolating the objects from the background. I am not sure there is any good way to do that in Imagemagick when the shadow color is close to the object color. I will defer to anyone with a good suggestion.

You could try one of tools such as clipping magic --- https://clippingmagic.com
shadow_man
Posts: 2
Joined: 2018-08-15T15:27:00-07:00
Authentication code: 1152

Re: Removing a shadow from an image

Post by shadow_man »

fmw42, do you think there is someway to isolate that image itself though? Some set of trim/bordering function?

I've tried a few with little results...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Removing a shadow from an image

Post by fmw42 »

No, I have never had much success in these situations. If the shoes are a different color from the shadow and the background is white, then you have a chance. But not with either near black or near white shoes.
Post Reply