Sophisticated fuzz with HSL definition?

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?".
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: Sophisticated fuzz with HSL definition?

Post by VanGog »

Thanks. Your code works. I learned something definitely. But the actions which I want to do are more complicated so I must begin from begin and change the way how I do it. I think I have thought how to do it best. But now I am having this problem:

Code: Select all

convert map.png -write mpr:input +delete ^
  ( -fuzz 8%% -fill black +opaque "#5189CF" ) ^
  ( -fuzz 8%% -fill black +opaque "#FFE57D" ) ^
  -evaluate-sequence add ^
    -blur 0x1.0 -threshold 4.5%% -fill red -opaque white highway_result_extra_add.png
Error: missing image filename highway_result_extra_add.png

I have feeling like doing the same mistakes still around, but we have a proverb in my language saying "repetition is mother of wisdom".
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Sophisticated fuzz with HSL definition?

Post by snibgo »

Each fuzz has no input.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sophisticated fuzz with HSL definition?

Post by fmw42 »

As snibgo said, you need your mpr image created in the first line as input to each parenthesis. Any parenthesis processing needs an image or a clone or an mpr image. That is why it is called processing on the side. It is like its own convert command and has to have an image on which to work.

convert map.png -write mpr:input +delete ^
( mpr:input -fuzz 8%% -fill black +opaque "#5189CF" ) ^
( mpr:input -fuzz 8%% -fill black +opaque "#FFE57D" ) ^
-evaluate-sequence add ^
-blur 0x1.0 -threshold 4.5%% -fill red -opaque white highway_result_extra_add.png
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: Sophisticated fuzz with HSL definition?

Post by VanGog »

I am back to learn how to work with multiple layers. Just tried examples from page 8 and they do not work for me suddenly. I have saved the batch files when I did this years ago but they do not work. For me. The colors in -fill are correct as I checked it again.

Now this command:

Code: Select all

convert map.png -write mpr:input +delete ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#FFE168" ) ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#E5bC4C" ) ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#FFF1B3" ) ^
  -evaluate-sequence add -blur 0x1.6 -threshold 25%% -write t1.png ^
  -evaluate-sequence add -blur 0x2.4 -threshold 2.5%% -write t2.png
>convert map.png -write mpr:input +delete ( mpr:input -fuzz 2% -fill black +opaque "#FFE168" ) ( mpr:input -fuzz 2% -fill black +opaque "#E5bC4C" ) ( mpr:input -fuzz 2% -fill black +opaque "#FFF1B3" ) -evaluate-sequence add -blur 0x1.6 -threshold 25% -write t1.png -evaluate-sequence add -blur 0x2.4 -threshold
2.5% -write t2.png
convert.exe: option requires an argument `-write' @ error/convert.c/ConvertImage
Command/2996.

>pause

This command is original from batch file which should work but it generated empty (black) images

Code: Select all

convert map.png -write mpr:input +delete ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#FFE168" ) ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#E5bC4C" ) ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#FFF1B3" ) ^
  -evaluate-sequence add -blur 0x1.6 -threshold 25%% -write highway_result_basic_1.png ^
  -delete 0-3 ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#FFE168" ) ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#E5bC4C" ) ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#FFF1B3" ) ^
  -evaluate-sequence add -blur 0x2.4 -threshold 2.5%% highway_result_basic_2.png
IM ver. 6.7.5-1 Q8

When no-one of these commands works then I tried this:

Code: Select all

convert -size 64x64 canvas:black +write mpr:input ^
  ( mpr:input -size 64x64 xc: -draw "circle 22,32 5,32" ) ^
  ( mpr:input -size 64x64 xc: -draw "circle 41,32 58,32" ) ^
  -evaluate-sequence add -write t.png
and it also says error I must use -write option

Edit on the other hand if I change -evaluate-sequence add for
-compose lighten
it works and creates images like highway_result_basic_1-0.png highway_result_basic_1-1.png highway_result_basic_1-2.png
however I wanted one image where the three masks are joined to one so I used -evaluate-sequence add ... I also thought is should I try -clone 0-2 and then the sequence, but fails coz -evaluate-sequence wants -write argument.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sophisticated fuzz with HSL definition?

Post by fmw42 »

Once you do -evaluate-sequence once, you no longer have the previous images. So you need to clone them to use in new paren operations for each evaluate-sequence. The null: is needed to remove temporary images from the command line.

Code: Select all

convert map.png -write mpr:input +delete ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#FFE168" ) ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#E5bC4C" ) ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#FFF1B3" ) ^
  ( -clone 0-2 -evaluate-sequence add -blur 0x1.6 -threshold 25%% -write t1.png +delete ) ^
  -evaluate-sequence add -blur 0x2.4 -threshold 2.5%% t2.png
or

Code: Select all

convert map.png -write mpr:input +delete ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#FFE168" ) ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#E5bC4C" ) ^
  ( mpr:input -fuzz 2%% -fill black +opaque "#FFF1B3" ) ^
  ( -clone 0-2 -evaluate-sequence add -blur 0x1.6 -threshold 25%% -write t1.png +delete ) ^
  ( -clone 0-2 -evaluate-sequence add -blur 0x2.4 -threshold 2.5%% -write t2.png ) ^
  null:
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Sophisticated fuzz with HSL definition?

Post by fmw42 »

Note: The above has been edited to correct a mistake.
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: Sophisticated fuzz with HSL definition?

Post by VanGog »

Once you do -evaluate-sequence once, you no longer have the previous images.
That is important information.
Could someone add this to the description?
http://www.imagemagick.org/script/comma ... e-sequence
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Sophisticated fuzz with HSL definition?

Post by snibgo »

This is the way that all image-processing operations work. They replace the input image(s).

Some operations (such as "-blur") replace each input with a new output. Some operations (such a "-evaluate-sequence" and "-layers merge") replace all of the inputs with a single output. If you want to do an operation while keeping the input, use "clone".
snibgo's IM pages: im.snibgo.com
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: Sophisticated fuzz with HSL definition?

Post by VanGog »

Ok, this is why I was confused because I expected IM layers works similarly like Photoshop, where all layers stay in memory and do not merge them-self or remove them-self until user does it.
Post Reply