[magick-users] Working with one channel only?

Fred Weinhaus fmw at alink.net
Wed Sep 5 14:55:56 PDT 2007


>Hi,
>
>I would like to write a script for an advanced 'Unsharp Mask'
>technique, which I need very frequently. This technique requires
>the image to be available in HSL color space (which is no problem),
>but then only the 'L' channel shall be modified. How does one go
>about there using ImageMagick?
>
>TIA,
>
>Claus


Hello Claus,

I have done similar kinds of things with only the L channel from HSL. 
See my scripts: omnistretch, redist, bcimage at:

http://www.fmwconcepts.com/imagemagick/index.html


Here is what I have done:

Separate channels:

convert $infile -colorspace HSL -channel R -separate $tmp0
convert $infile -colorspace HSL -channel G -separate $tmp1
convert $infile -colorspace HSL -channel B -separate $tmp2

Do your unsharp masking processing on $tmp2

The recombine channels

convert $tmp0 -colorspace $colormodel $tmp0 -compose CopyRed -composite \
	$tmp1p -compose CopyGreen -composite \
	$tmp2p -compose CopyBlue -composite \
	-colorspace RGB $outfile

$tmp0, $tmp1, $tmp2 are predefined temporaries that the script will 
automatically delete when the script finishes.

I learned all this from Anthony Thyssen.   Anthony has explained this 
conversion on his page at

http://www.imagemagick.org/Usage/channels/

see especially the section on Combining non-RGB Channel Images


When you finish your script, I would like to see what you are doing, 
if it is not a private thing. I assume you are doing unsharp masking 
on just the L channel, but I would like to understand what more you 
might be doing in addition.

Fred


More information about the Magick-users mailing list