Foreground extraction (command line)


#1

Hi, can someone help me with this tutorial? http://opensource.graphics/how-to-code-a-nice-user-guided-foreground-extraction-algorithm/

I’m using this command

.\gmic.exe IMG_7562.jpg 1.png --blur[0] 0.2% -gradient_norm[-1] -fill[-1] ‘1/(1+i^2)’ -watershed[1] [2] -reverse[-2,-1]

but I get an error:

[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Input file ‘IMG_7562.jpg’ at position 0 (1 image 1056x813x1x3).
[gmic]-1./ Input file ‘1.png’ at position 1 (1 image 1056x813x1x3).
[gmic]-2./ Blur image [0] with standard deviation 0.2%, neumann boundary conditions and quasi-gaussian kernel.
[gmic]-3./ Compute gradient norm of images [0,1,2].
[gmic]-3./ Input copy of image [2] at position 3 (1 image 1056x813x1x1).
[gmic]-4./ Fill images [0,1,2,3] with values from image [3].
[gmic]-4./ Input file ‘1/(1+i^2)’ at position 4
[gmic]-4./ *** Error *** Unknown command or filename ‘1/(1+i^2)’.

Most likely, since that time the “-fill” command has changed, but how to use it now is not clear…
Example in this archive: https://www.dropbox.com/s/wzpdt9vcuo1xqfa/gmic-cli-2.2.3-win32.zip?dl=0


(Mica) #2

This looks like a Windows cmd.exe quoting error, that we just discussed here: Help with programming


(Alan Gibson) #3

In the OP, the quotes around 1/(1+i^2) are “smart-quotes”, where the open and close quotes are different characters. For Windows, uses ordinary (non-smart) double-quotes, eg:

gmic toes.png toes.png --blur[0] 0.2% -gradient_norm[-1] -fill[-1] "1/(1+i^2)" -watershed[1] [2] -reverse[-2,-1]

(http://4232.cf) #4

It does not work me
I am interests idea to separate background and figure


#5

What doesn’t work? The quoting? Another way is to escape the offending character like this
1/(1+i^2) → 1/(1+i^^2).

You mentioned this in several threads. Could you explain what you mean by that? Just wondering if you are asking about something specific rather than stating your interest in the topic.


(http://4232.cf) #6

I want to do something similar to this:

But without having to choose background and foreground


#7

Unfortunately, both variants (double quotes and double ^^) doesn’t work.


(Alan Gibson) #8

Please paste the exact command you used, and the error messages.


(http://4232.cf) #9

This is my exit. I do not see changes


#10

.\gmic.exe IMG_7562.jpg 1.png --blur[0] 0.2% -gradient_norm[-1] -fill[-1] ‘1/(1+i^^2)’ -watershed[1] [2] -reverse[-2,-1]
[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Input file ‘IMG_7562.jpg’ at position 0 (1 image 1056x813x1x3).
[gmic]-1./ Input file ‘1.png’ at position 1 (1 image 1056x813x1x3).
[gmic]-2./ Blur image [0] with standard deviation 0.2%, neumann boundary conditions and quasi-gaussian kernel.
[gmic]-3./ Compute gradient norm of images [0,1,2].
[gmic]-3./ Input copy of image [2] at position 3 (1 image 1056x813x1x1).
[gmic]-4./ Fill images [0,1,2,3] with values from image [3].
[gmic]-4./ Input file ‘1/(1+i^^2)’ at position 4
[gmic]-4./ *** Error *** Unknown command or filename ‘1/(1+i^^2)’.

and

.\gmic.exe IMG_7562.jpg 1.png --blur[0] 0.2% -gradient_norm[-1] -fill[-1] “1/(1+i^2)” -watershed[1] [2] -reverse[-2,-1]
[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Input file ‘IMG_7562.jpg’ at position 0 (1 image 1056x813x1x3).
[gmic]-1./ Input file ‘1.png’ at position 1 (1 image 1056x813x1x3).
[gmic]-2./ Blur image [0] with standard deviation 0.2%, neumann boundary conditions and quasi-gaussian kernel.
[gmic]-3./ Compute gradient norm of images [0,1,2].
[gmic]-3./ Input copy of image [2] at position 3 (1 image 1056x813x1x1).
[gmic]-4./ Fill images [0,1,2,3] with values from image [3].
[gmic]-4./ Input file ‘1/(1+i^2)’ at position 4
[gmic]-4./ *** Error *** Unknown command or filename ‘1/(1+i^2)’.


(Morgan Hardwood) #11

@Torvald read about quoting in Windows shell and look closely at what you’re using to quote. Well, @snibgo already explained it, but you’re still using the wrong quotes.


(Alan Gibson) #12

I’m not sure if he’s using the wrong quotes. The forum software is converting ordinary quotes into “smart” quotes, where the open and close characters are different. I don’t know what can be done about that.


#13

@Torvald See my example. You don’t have to quote if you don’t use any special characters or have any spaces. If you would like to use the caret either quote or escape but not both.

gmic sample tiger fill i^^1.5 cut 0,255
gmic sample tiger fill "i^1.5" cut 0,255

#14

I I found out what the problem was. I used “Windows PowerShell”. When I tried the “Command line” - everything worked. I think the problem is how Windows PowerShell processes quotes. Thanks for the help.