Create (semi-) transparency on "shaded" areas of 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
blindcoder
Posts: 8
Joined: 2013-06-14T00:10:37-07:00
Authentication code: 6789

Create (semi-) transparency on "shaded" areas of an image

Post by blindcoder »

Hello.

I have this images and many more like it: https://docs.google.com/file/d/0B5ZUp1_ ... h2X2c/edit
What I want to achieve is getting all black areas transparent and all "shaded" areas (ie: the part behind the trees) either also transparent or ideally semi-transparent
Currently I use this command to get the transparency:

Code: Select all

convert screenshot.jpg -black-threshold 1% -transparent black screenshot_transparent.png
But that leaves me with a lot of opaque shaded areas.

I'm happy for any suggestion!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Create (semi-) transparency on "shaded" areas of an imag

Post by snibgo »

I don't know what defines the parts you want to be transparent.

If I assume you want black (0% level) to be fully tansparent, with transparency reducing to zero at 20% level, this (Windows script) would do the trick.

Code: Select all

convert ^
  Fri_Jun_21_08_38_06_CEST_2013.jpg ^
  ( +clone -level 0,20%% ) ^
  -compose CopyOpacity -composite ^
  f.png
But parts of the trees, and the figure's trousers, are partially transparent.
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Create (semi-) transparency on "shaded" areas of an imag

Post by anthony »

It may be better to put it in a different colorspace. Say something that separates luminance from chroma or saturation.
HSB, Lab, Luv are all possibilities.

This way a darker color does not effect results as much.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply