[note: SO images display, and image background CSS makes hard to see the subtile differences between files.]
Given the following gray scale input.png
:

1a. To make black pixels of this image transparent and linearly keep the white pixels as they are, run this command:
convert source.png -alpha copy -fx '#fff' result.png
1b. To make white pixels transparent and linearly keep the black as they are, use:
convert source.png -alpha copy -channel alpha -negate +channel result.png
Manual:
- convert – is the ImageMagic command (one of several)
- source.png – is the greyscale source image.
- -alpha copy – it copy contents of the previous file into the alpha channel.
- -channel alpha – it specify that following operators only should affect the alpha channel.
- -negate – it invert the current channel (channel alpha).
- +channel – Specify that following operators only affect the opposite channel. For us, it switch focus from the alpha channel, to the color channel. (color channel is initially the default)
- -fx '#000' – Replace current channel (for us, the color channel) contents with black pixels, so the end result actually fully depends on the alpha channel. If not included, all semi-transparent pixels in generated image will retain colors, from #FFF (white) to #000 (black).
Result of 1b:

Wiping out plains:
An additional processing could wipe out most of the flat plains, which appears around greys (#DDDDDD
) with opacity:~50%. This could be done by :
convert input.png -fuzz 8% -transparent "#DDDDDD" grey_no.8pc.png
convert grey_no.8pc.png -alpha copy -channel alpha -negate +channel result.grey_no.png
so the plains avoid an useless #DDDDDD, opacity:50%
overlay.

See also:
- ImageMagick options: http://www.imagemagick.org/script/command-line-options.php