I would combine your two commands like this (Windows BAT syntax). The mask should be black and white only, so I add "-alpha off ".
Code: Select all
convert ^
in.png ^
( +clone ^
-define modulate:colorspace=LCHuv -modulate 100,100,85 ^
ycbcr_hc.png -hald-clut ^
-threshold 50%% ^
) ^
-alpha off ^
-compose CopyOpacity -composite ^
out2.png
The way I do this is:
1. I break your commands into lines, which makes them easier for me to understand. I use BAT files, so "50%" needs to be "50%%".
Code: Select all
convert ^
in.png ^
-define modulate:colorspace=LCHuv -modulate 100,100,85 ^
ycbcr_hc.png -hald-clut ^
-threshold 50%% ^
mask.png
convert ^
in.png ^
mask.png ^
-alpha off -compose CopyOpacity ^
-composite out.png
2. I see that your first command reads in.png and write mask.png. The second command reads these two files, and creates out.png. So my version can read in.png, create the mask as a temporary (in-memory) result, then create the output. So I make a clone of the input to create the mask. I use parentheses ( and ) so the processing will be done to the mask only, not also to in.png.
3. I compare my output with yours, for a certain in.png:
Code: Select all
%IM%compare -metric RMSE out.png out2.png NULL:
The result is zero, meaning they are identical.
I would like to learn more about the multi-line syntax you use. Please point me in the right direction.
See me web pages for many examples.
"convert" commands can be split anywhere there is a space (apart from spaces inside quotes), and its lines can be indented. (Indents are just extra spaces.) They work exactly as if they were on a single line. I split them so I can understand them more easily.
The Windows "for" command can't be split anywhere there is a space, and indenting can cause problems. These days, my usual syntax is something like:
Code: Select all
for /F "usebackq" %%L in (`convert ^
infile ^
{procesing} ^
outfile`) do {something}
The last character on each line apart from the last must be caret ^.