Sine Curve defaults (or not...)

Perusing the G’MIC standard library, I found the default parameters for the fx_sine_curve filter:

#@gui Sine Curve:fx_sine_curve,fx_sine_curve_preview
#@gui :_=note("<span color="#EE5500"><b>Curve parameters:</b></span>")
#@gui :Preset=choice{1,"Default (Circle)","Alien Rasta","All Round","Carnivorous Plant","Cat Pad","Flower","Flower Cushion","Fly Karateka","Hearts","Moving Leaf","Radioactive Flower","Rosace","Spaceship","Transformer","Tubular Waves","Twisted Heart","Twisted Heart 2","Twisted Tunnel","Waterslide"}
#@gui :_=value(-1)
#@gui :Resolution (%)=float(75,0,100)
#@gui :Periods=float(1,0,3)
#@gui :_=separator()
#@gui :Parameter Settings=choice(1,"Ratios","Multipliers","Offsets","Exponents","Signs","3D Angles")
#@gui :_=note("<small><span color="#EE0055"><b>Ratios:</b></span></small>")
#@gui :Xa/Xb=float(0.5,0,1)_0-
#@gui :Ya/Yb=float(0.5,0,1)_0
#@gui :Za/Zb=float(0.5,0,1)_0
#@gui :_=note("<small><span color="#EE0055"><b>Multipliers:</b></span></small>")
#@gui :Xa-Multiplier=int(1,0,1024)_2-
#@gui :Ya-Multiplier=int(1,0,1024)_2
#@gui :Za-Multiplier=int(0,0,1024)_2
#@gui :Xb-Multiplier=int(800,0,1024)_2
#@gui :Yb-Multiplier=int(800,0,1024)_2
#@gui :Zb-Multiplier=int(1,0,1024)_2
#@gui :_=note("<small><span color="#EE0055"><b>Offsets:</b></span></small>")
#@gui :Xa-Offset (deg.)=float(90,0,360)_0-
#@gui :Ya-Offset (deg.)=float(0,0,360)_0
#@gui :Za-Offset (deg.)=float(0,0,360)_0
#@gui :Xb-Offset (deg.)=float(90,0,360)_0
#@gui :Yb-Offset (deg.)=float(0,0,360)_0
#@gui :Zb-Offset (deg.)=float(0,0,360)_0
#@gui :_=note("<small><span color="#EE0055"><b>Exponents:</b></span></small>")
#@gui :Xa-Exponent=float(1,0,32)_0-
#@gui :Ya-Exponent=float(1,0,32)_0
#@gui :Za-Exponent=float(1,0,32)_0
#@gui :Xb-Exponent=float(1,0,32)_0
#@gui :Yb-Exponent=float(1,0,32)_0
#@gui :Zb-Exponent=float(1,0,32)_0
#@gui :_=note("<small><span color="#EE0055"><b>Signs:</b></span></small>")
#@gui :Xa-Sign=choice("Preserve","Invert","Negative","Positive")_0-
#@gui :Ya-Sign=choice("Preserve","Invert","Negative","Positive")_0
#@gui :Za-Sign=choice("Preserve","Invert","Negative","Positive")_0
#@gui :Xb-Sign=choice("Preserve","Invert","Negative","Positive")_0
#@gui :Yb-Sign=choice("Preserve","Invert","Negative","Positive")_0
#@gui :Zb-Sign=choice("Preserve","Invert","Negative","Positive")_0
#@gui :_=note("<small><span color="#EE0055"><b>3D Angles:</b></span></small>")
#@gui :X-Angle (deg.)=float(0,-180,180)_0-
#@gui :Y-Angle (deg.)=float(0,-180,180)_0
#@gui :Z-Angle (deg.)=float(0,-180,180)_0
#@gui :Zoom=float(1,0,10)_0
#@gui :Focale=int(8,1,20)_0
#@gui :_=separator()
#@gui :_=note("<span color="#EE5500"><b>Rendering parameters:</b></span>")
#@gui :Center=point(50,50,0,1,0,238,85,-170,10)_0
#@gui :_=value(50)
#@gui :_=value(50)
#@gui :Radius=point(68,68,0,1,238,0,85,-170,10)_0
#@gui :Angle=point(75,50,0,1,238,85,0,-170,10)_0
#@gui :_=value(75)
#@gui :_=value(50)
#@gui :Primary Radius (%)=float(3,0,100)
#@gui :Secondary Radius (%)=float(2,0,100)
#@gui :Opacity (%)=float(40,0,100)
#@gui :Color=color(#ffffff)
#@gui :Anti-Aliasing=choice(2,"None","× 1.25","× 1.5","× 2","× 3")
#@gui :_=separator()
#@gui :Preview Background=choice(1,"Image","Black","White")
#@gui :_=separator()

But when I tried to copy them and test them out on an image, it errored, and it seems to be saying something about the number of parameters being wrong (although that’s an assumption on my part), could anyone investigate?

gmic input.png fx_sine_curve 1,75,1,1,0.5,0.5,0.5,1,1,0,800,800,1,90,0,0,90,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,8,50,50,68,68,75,50,3,2,40,255,255,255,2,1 out_1.png
[gmic]./ Start G'MIC interpreter (v.3.5.2).
[gmic]./ Input file 'input.png' at position 0 (1 image 480x480x1x4).
[gmic] *** Error in ./fx_sine_curve/*substitute/ *** Unknown command or filename '1-55'; did you mean '-3d'?

Found an old shell file which coincidentally has some Sine Curve command, like:
gmic input.png fx_sine_curve 12,12,75,1,1,0.5,0.5,0,1,1,0,400,200,1,90,0,0,90,0,0,1,1,1,3,3,1,1,0,0,1,0,0,0,0,0,2,8,50,50,50,50,68,68,75,50,75,50,3,2,40,255,255,255,2,1 o out_00.png

This actually works! Yet the problem is, it seems to not bear proper resemblance to the defaults as ourlined above - so have I been looking at an older version somehow?
I would still need to know the actual defaults before I can proceed.

I possibly had a bad copy, anyway the actual parameters are:

#@gui Sine Curve : fx_sine_curve, fx_sine_curve_preview
#@gui : note = note("<span color="#EE5500"><b>Curve parameters:</b></span>")
#@gui : Preset = choice{1,"Default (Circle)","Alien Rasta","All Round","Carnivorous Plant","Cat Pad","Flower",
#@gui : "Flower Cushion","Fly Karateka","Hearts","Moving Leaf","Radioactive Flower","Rosace","Spaceship",
#@gui : "Transformer","Tubular Waves","Twisted Heart","Twisted Heart 2","Twisted Tunnel","Waterslide"}
#@gui : Previous Preset = value(-1)
#@gui : Resolution (%) = float(75,0,100)
#@gui : Periods = float(1,0,3)
#@gui : sep = separator()
#@gui : Parameter Settings = choice(1,"Ratios","Multipliers","Offsets","Exponents","Signs","3D Angles")
#@gui : note = note("<small><span color="#EE0055"><b>Ratios:</b></span></small>")
#@gui : Xa/Xb = float(0.5,0,1)_0-
#@gui : Ya/Yb = float(0.5,0,1)_0
#@gui : Za/Zb = float(0.5,0,1)_0
#@gui : note = note("<small><span color="#EE0055"><b>Multipliers:</b></span></small>")
#@gui : Xa-Multiplier = int(1,0,1024)_2-
#@gui : Ya-Multiplier = int(1,0,1024)_2
#@gui : Za-Multiplier = int(0,0,1024)_2
#@gui : Xb-Multiplier = int(800,0,1024)_2
#@gui : Yb-Multiplier = int(800,0,1024)_2
#@gui : Zb-Multiplier = int(1,0,1024)_2
#@gui : note = note("<small><span color="#EE0055"><b>Offsets:</b></span></small>")
#@gui : Xa-Offset (deg.) = float(90,0,360)_0-
#@gui : Ya-Offset (deg.) = float(0,0,360)_0
#@gui : Za-Offset (deg.) = float(0,0,360)_0
#@gui : Xb-Offset (deg.) = float(90,0,360)_0
#@gui : Yb-Offset (deg.) = float(0,0,360)_0
#@gui : Zb-Offset (deg.) = float(0,0,360)_0
#@gui : note = note("<small><span color="#EE0055"><b>Exponents:</b></span></small>")
#@gui : Xa-Exponent = float(1,0,32)_0-
#@gui : Ya-Exponent = float(1,0,32)_0
#@gui : Za-Exponent = float(1,0,32)_0
#@gui : Xb-Exponent = float(1,0,32)_0
#@gui : Yb-Exponent = float(1,0,32)_0
#@gui : Zb-Exponent = float(1,0,32)_0
#@gui : note = note("<small><span color="#EE0055"><b>Signs:</b></span></small>")
#@gui : Xa-Sign = choice("Preserve","Invert","Negative","Positive")_0-
#@gui : Ya-Sign = choice("Preserve","Invert","Negative","Positive")_0
#@gui : Za-Sign = choice("Preserve","Invert","Negative","Positive")_0
#@gui : Xb-Sign = choice("Preserve","Invert","Negative","Positive")_0
#@gui : Yb-Sign = choice("Preserve","Invert","Negative","Positive")_0
#@gui : Zb-Sign = choice("Preserve","Invert","Negative","Positive")_0
#@gui : note = note("<small><span color="#EE0055"><b>3D Angles:</b></span></small>")
#@gui : X-Angle (deg.) = float(0,-180,180)_0-
#@gui : Y-Angle (deg.) = float(0,-180,180)_0
#@gui : Z-Angle (deg.) = float(0,-180,180)_0
#@gui : Zoom = float(1,0,10)_0
#@gui : Focale = int(8,1,20)_0
#@gui : sep = separator()
#@gui : note = note("<span color="#EE5500"><b>Rendering parameters:</b></span>")
#@gui : Center = point(50,50,0,1,0,238,85,-170,10)_0
#@gui : Old X-Center = value(50)
#@gui : Old Y-Center = value(50)
#@gui : Radius = point(68,68,0,1,238,0,85,-170,10)_0
#@gui : Angle = point(75,50,0,1,238,85,0,-170,10)_0
#@gui : Old X-Angle = value(75)
#@gui : Old Y-Angle = value(50)
#@gui : Primary radius (%) = float(3,0,100)
#@gui : Secondary radius (%) = float(2,0,100)
#@gui : Opacity (%) = float(40,0,100)
#@gui : Color = color(255,255,255)
#@gui : Anti-aliasing = choice(2,"None","× 1.25","× 1.5","× 2","× 3")
#@gui : sep = separator()
#@gui : Preview background = choice(1,"Image","Black","White")
#@gui : sep = separator()
#@gui : note = note("<small>Author: <i>David Tschumperlé</i>.      Latest Update: <i>2021/03/04</i>.</small>")

Question: Why does the filter output a copy of the input as well as the actual output, and how can I stop that?

There is a function in the GUI to copy the command. That would be one way to capture the defaults (or the parameters you select if you change them). Another method is to view the gmic_stdlib.gmic. The first part shows us the parameters and their default values based on the presets.

  # Get parameters as named variables.
  preset,previous_preset,\
  resolution,periods,dp,\
  ratx,raty,ratz,\
  mxa,mya,mza,mxb,myb,mzb,\
  oxa,oya,oza,oxb,oyb,ozb,\
  pxa,pya,pza,pxb,pyb,pzb,\
  sxa,sya,sza,sxb,syb,szb,\
  rotx,roty,rotz,zoom,focale,\
  xc,yc,prev_xc,prev_yc,xr,yr,xa,ya,prev_xa,prev_ya,\
  radius1,radius2,opacity,\
  colR,colG,colB,\
  antialiasing,\
  preview_background=${1-55}

  if !narg($_is_preview) _is_preview=0 fi
  if [$prev_xc,$prev_yc]!=[$xc,$yc]
    xr,yr,xa,ya,prev_xa,prev_ya+=d=[$xc,$yc]-[$prev_xc,$prev_yc];[d,d,d]
  fi
  if [$prev_xa,$prev_ya]!=[$xa,$ya]
    delta_a:="
      a = [ "$xa" - "$xc", "$ya" - "$yc" ];
      b = [ "$prev_xa" - "$xc", "$prev_ya" - "$yc" ];
      (atan2(a[1],a[0]) - atan2(b[1],b[0]))*180/pi;
    "
    xr,yr:=[$xc,$yc]+rot($delta_a°)*[$xr-$xc,$yr-$yc]
  else delta_a=0 fi
  if [$colR,$colG,$colB]==[0,0,0]" && "$preview_background==1 colR,colG,colB=255
  elif [$colR,$colG,$colB]==[255,255,255]" && "$preview_background==2 colR,colG,colB=0
  fi

  # Manage presets.
  update_params=0
  if $preset!=$previous_preset

    # Set default parameters for presets ('Default (Circle)').
    periods=1
    ratx,raty,ratz=0.5,0.5,0
    mxa,mxb,mya,myb,mza,mzb=1,1,1,1,0,1
    oxa,oxb,oya,oyb,oza,ozb=90,90,0,0,0,0
    pxa,pxb,pya,pyb,pza,pzb=1
    sxa,sxb,sya,syb,sza,szb=0
    rotx,roty,rotz,zoom,focale=0,0,0,2,8

    # Set specific values for each preset.

    # Default (circle)
    if !$preset
      ratx,raty,ratz=0 zoom=1
    # Alien Rasta
    elif $preset==1
      mxa,mxb,mya,myb=1,800,1,800 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2 oxa,oxb,oya,oyb=90,90,0,60
    # All Round
    elif $preset==2
      mxa,mxb,mya,myb=1,200,1,150 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2
    # Carnivorous Plant
    elif $preset==3
      mxa,mxb,mya,myb=9,512,1024,9 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2
    # Cat Pad
    elif $preset==4
      mxa,mxb,mya,myb=80,1,80,1 pxa,pxb,pya,pyb=1,3,1,3
    # Flower
    elif $preset==5
      ratz=0.8 mza,mzb=7,1024 pza,pzb=1.6,2 rotz=45 zoom=1 focale=4
    # Flower Cushion
    elif $preset==6
      mxa,mxb,mya,myb=80,1,1,80 pxa,pxb,pya,pyb=1,3,1,3
    # Fly Karateka
    elif $preset==7
      mxa,mxb,mya,myb=150,1,1,100 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2
    # Hearts
    elif $preset==8
      mxa,mxb,mya,myb=1,80,80,80 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2
    # Moving Leaf
    elif $preset==9
      mxa,mxb,mya,myb=2,200,200,1 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2
    # Radioactive Flower
    elif $preset==10
      mxa,mxb,mya,myb=1,800,1,800 pxa,pxb,pya,pyb=1,3,1,3
    # Rosace
    elif $preset==11
      mxa,mxb,mya,myb=1,10,1,10
    # Spaceship
    elif $preset==12
      mxa,mxb,mya,myb=1,400,1,200 pxa,pxb,pya,pyb=1,3,1,3 sxa,sxb,sya,syb=1,1,0,0
    # Transformer
    elif $preset==13
      mxa,mxb,mya,myb=1,800,800,2 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2
    # Tubular Waves
    elif $preset==14
      mxa,mxb,mya,myb=1,30,1,60 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2
    # Twisted Heart
    elif $preset==15
      mxa,mxb,mya,myb=500,1,1,500 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2
    # Twisted Heart 2
    elif $preset==16
      mxa,mxb,mya,myb=1,80,80,1 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2
    # Twisted Tunnel
    elif $preset==17
      mxa,mxb,mya,myb=1,80,1,40 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2
    # Waterslide
    elif $preset==18
      ratx=0.6 mxa,mxb,mya,myb=9,400,200,9 pxa,pxb,pya,pyb=1,3,1,4 sxa,sxb,sya,syb=0,1,0,2
    fi
  fi

The last part reveals why: the GUI depends on the original image being available for comparison.

fx_sine_curve_preview :
  _is_preview=1
  fx_sine_curve $*
  k[0]

k[0] means keeping the first image in the list (which I guess is the original image) as preview. In other words, use k[1] after the command to keep the processed image.

1 Like

Thanks - very helpful stuff…

“…k[0] means keeping the first image in the list (which I guess is the original image) as preview.”

I learnt something that day👍