Page 8 of 9
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-09T15:04:01-07:00
by VanGog
Oh so. I have to remember there must not be space after ^ it was not visible and this did not come to my mind.
I almost have what I wanted, but I am not satisfied with the threshold. I must do more complicated calculation to get rid of #FFE98E rectangles. My idea is to select:
convert mapka.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.5%% ^
REM Or use Faster method to extend the area?
-write mpr:basic
and then:
( mpr:input -fuzz 2%% -fill black +opaque "#FFE98E" ) ^
-blur 0x1.6 -threshold 25.5%%
REM extend the mask for blue rectangle too
-write mpr:extra_add
then When I have both layers extended I need to compose them with multiply effect so the blue rectangle should no more exists. It will disappear from the mask. And then I need to contract the final mask about 5 pixels. It is harder task, but you could help me how to make this 3 parts working together in one command.
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-09T15:51:50-07:00
by fmw42
mpr: format images automatically disappear when the command line finishes. You cannot save it from one command to another.
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T02:01:25-07:00
by VanGog
One more problem. Now I need to get mask which will have red instead white
Code: Select all
convert mapka.png -fuzz 8%% -fill black +opaque "#5189CF" ^
-blur 0x1.0 -threshold 4.5%% highway_result_extra_add.png
I do the threshold but I need it come not in white but in different color, e.g red. Is there simple way how to replace the white for red, without using -fuzz and -fill? I believe that all colors in image are indexed in the image header so I just want to replace color in the header, no change to references in the bitmap array.
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T09:32:12-07:00
by VanGog
Also, I need to generate two masks. One with less blur/threshold one with bigger:
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%% highway_result_basic_1.png
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 0x2.4 -threshold 2.5%% highway_result_basic_2.png
So is it possible to make one command? Not to generate those 6 images but only 3 images. But I would like first evaluate-sequence first, and save to one file and then evaluate-sequence second and save to second file.
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T09:46:16-07:00
by fmw42
try this, but not tested, since I am on Mac not Windows. Note the use of -write and then -delete 0-3
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
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T09:54:45-07:00
by VanGog
Wow . Works both:
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 ^
-evaluate-sequence add -blur 0x2.4 -threshold 2.5%% highway_result_basic_2.png
It's great. I worried that it would not be possible.
Also can you answer my question about -fill? What does the fill actually do? If used without -fuzz does it fill every pixel in bitmap array or does it replace only the one color value in the image header
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T10:37:06-07:00
by fmw42
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 0x2.1 -threshold 9%% ^
-blur 0x2.6 -threshold 70%% -write highway_result_basic_1.png ^
-evaluate-sequence add -blur 0x2.4 -threshold 2.5%% highway_result_basic_2.png
Delete the first resulting image from memory after writing it to disk
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 0x2.1 -threshold 9%% ^
-blur 0x2.6 -threshold 70%% -write highway_result_basic_1.png +DELETE ^
-evaluate-sequence add -blur 0x2.4 -threshold 2.5%% highway_result_basic_2.png
-fill will replace the all (rgb as opposed to hsl) colors within fuzz XX% of your selected color with black
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T10:37:55-07:00
by VanGog
Yet one more problem with my code:
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 0x2.1 -threshold 9%% ^
-blur 0x2.6 -threshold 70%% -write highway_result_basic_1.png ^
-evaluate-sequence add -blur 0x2.4 -threshold 2.5%% highway_result_basic_2.png
When I change value 70%% to 90%% it will affect both files. But I need to affect only the file highway_result_basic_1.png when I change this value, because I want the last line to work with images 1-3 not with the last image.
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T10:53:25-07:00
by fmw42
I explained the fix in my previous message. Please read carefully. See the note about +delete
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T12:09:28-07:00
by VanGog
You mean like this?
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 0x2.1 -threshold 9%% ^
-blur 0x2.6 -threshold 90%% -write highway_result_basic_1.png ^
-delete 3 ^
-evaluate-sequence add -blur 0x2.4 -threshold 2.5%% highway_result_basic_2.png
But this still changes the highway_result_basic_2.png . The contraction of first file effects the second file which should not be contracted.
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T12:10:01-07:00
by snibgo
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 0x2.1 -threshold 9%% ^
-blur 0x2.6 -threshold 70%% -write highway_result_basic_1.png ^
-evaluate-sequence add -blur 0x2.4 -threshold 2.5%% highway_result_basic_2.png
The first "-evaluate-sequence add" will replace all of the images so far. So the second "-evaluate-sequence add" has only one image to work with, and that image is the result of the first "add".
See "-clone" for a solution, as well as "-delete".
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T13:16:47-07:00
by VanGog
snibgo wrote:
The first "-evaluate-sequence add" will replace all of the images so far. So the second "-evaluate-sequence add" has only one image to work with, and that image is the result of the first "add".
See "-clone" for a solution, as well as "-delete".
I still got many errors so how should the -clone look like? I give it before -evaluate-sequence but it will probably join the cloned layers too. How to do it correctly?
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 0x2.1 -threshold 9%% ^
-blur 0x1.6 -threshold 90%% -write highway_result_basic_1.png ^
-evaluate-sequence add -blur 0x1.0 -threshold 25%% highway_result_basic_2.png
This gives error
"option require argument -write"
Edit:
Yet I got idea to try MPR because I cannot find out how to use the clone or parenthesis in this command, so I tried this, getting
error that it requires -write
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 ^
-write mpr:basic ^
mpr:basic -blur 0x2.1 -threshold 9%% ^
-blur 0x1.6 -threshold 90%% -write highway_result_basic_1.png ^
mpr:basic -evaluate-sequence add -blur 0x1.0 -threshold 25%% highway_result_basic_2.png
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T15:11:00-07:00
by fmw42
You have missed the key point of my earlier code to fix your problem. You need to
delete the file after writing it to disk, so that it does
not get kept in memory and used by the second -evaluate-sequence. Writing a file to disk (using -write) does not automatically remove it from the command line. So there is still a file in memory from the first -evaluate-sequence. I have highlighted the important changes and the one you missed is in red.
- 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 0x2.1 -threshold 9%% ^
-blur 0x2.6 -threshold 70%% -write highway_result_basic_1.png +delete ^
-evaluate-sequence add -blur 0x2.4 -threshold 2.5%% highway_result_basic_2.png
Perhaps I misunderstood what you are trying to do. If the above does not work, then explain in more detail.
Also you cannot have a blank line in the middle of code because there is a new line without a new line character (^)
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-10T23:19:02-07:00
by VanGog
The empty line was only for stylistic reasons here on forum to separate the two steps visually.
I think I have tried your last code already before and it did not work. I am going to try again.
Yes, i recalled I tried it and it produced error message. I was not able to use the +delete but only -delete 3 because +delete produced some error message. I written that it produced error. Now I tried again and the error of your code is:
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 0x2.1 -threshold 9% -blur 0x2.6 -threshold 70% -write highway_result_basic_1.png +delete -evaluate-sequence add -blur 0x2.4 -threshold 2.5% highway_result_basic_2.png convert.exe: missing an image filename `highway_result_basic_2.png' @ error/convert.c/ConvertImageCommand/3016.
I thought that when I called -evaluate-sequence first time, so the images in parenthesis will be removed by the command and will be changed to one image. If this is truth - as it looks it is - than this is reason of my error. I try to explain that this causes depended action. action 2 is depended on action 1, action 3 is depended on action 2. This is not what I want. I want: action 2 to be depended on action 1, action 3 to be depended on action 1. In other words, now I need: Create 3 images and join them. The resulting image save to memory let's call it "basic", this is action 1. Then I create blur and extend the image, then I blur and contract the image and I save it. (Possibly to remove 2nd image now from memory) This is action 2. Last action is separated and need to take the "basic" image from memory. I create blur and extend the image and save it to second file.
The last code of mine tried to fix it with clone, but I cannot find example how to use the clone or parenthesis in similar way. Snibgo written good advice to me and I think that he understood me what I want so I continued to try it with clone. He wrote I should use -clone and -delete but I cannot find out how to use them in this case. I checked the examples of IM v6.
Re: Sophisticated fuzz with HSL definition?
Posted: 2014-06-11T00:22:55-07:00
by snibgo
Earlier, you said you wanted to combine:
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%% highway_result_basic_1.png
... and ...
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 0x2.4 -threshold 2.5%% highway_result_basic_2.png
The first 4 lines of each command are the same, so this combines them:
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 highway_result_basic_1.png ^
+delete ^
) ^
-evaluate-sequence add -blur 0x2.4 -threshold 2.5%% highway_result_basic_2.png
Each "-evaluate-sequence add" operates on the same three inputs. So, instead, we could "-evaluate-sequence add" just once:
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 ^
( -clone 0 ^
-blur 0x1.6 -threshold 25%% ^
-write highway_result_basic_1.png ^
+delete ^
) ^
-blur 0x2.4 -threshold 2.5%% highway_result_basic_2.png
Personally, I don't combine commands until I am certain they do what I want them to do.