| Fred Weinhaus on wrote...
| |
| | >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.
| |
|
| You can also do the modifications in one command, but joining these
| operations together. I did this recently in the IM forums.
|
| Here is a copy of the final... modify just the 'L' channel
| command...
| It splits up the image, clones the 'L' image into a separate
| parenthesis, then swaps your changes for the original and
| recombines them back together again.
|
| convert $infile -colorspace HSL -channel RGB -separate +channel \
| \( +clone ...L CHANNEL MODIFICATIONS HERE.... \
| \) +swap +delete \
| \( -clone 0 -colorspace HSL \
| -clone 0 -compose CopyRed -composite \
| -clone 1 -compose CopyGreen -composite \
| -clone 2 -compose CopyBlue -composite \
| \) -delete 0-2 -colorspace RGB $outfile
|
| Unfortunately as you see above the IM -combine can NOT handle
| combining non-RGB greyscale channel images. This is a known bug
| that has been reported, but one not simple to fix, as IM needs
| some way to determine what colorspace the greyscale channel images
| need to produce.
|
| I shall add the above to the IM Examples section...
| Combining non-RGB Channel Images
| http://www.imagemagick.org/Usage/channels/#combine_other
|
| It should appear in a day or so.
|
Addendum...
Some operations are channel operators. For example -fx
the new color lookup table -clut, and so on.
If you can adjust a single channel without effecting others, you do NOT
need to separate the image channels. simplifying the complexity caused
by the -combine operators short commings.
For example here I negate the lumance channel only...
convert $infile -colorspace HSL \
-channel B -negate +channel \
-colorspace RGB $outfile
this will also be in IM Examples in the next day or so.
Anthony Thyssen ( System Programmer ) <[EMAIL PROTECTED]>
-----------------------------------------------------------------------------
The Butterfly Effect :-
When a butterfly creating turbulence in England,
can cause a typhoon in Hong Kong! - "Chaos"
-----------------------------------------------------------------------------
Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users