Release of G'MIC 3.0

@Reptorian

Bonjour,

message : On the road to 3.0 - #412 by Reptorian

I can not use the screens settings in the command lines, for example :

gmic cursor 0 Screen_W={*,u} Screen_H={*,v} repeat 5 fx_image_sample 0,0,0 resize $Screen_W,$Screen_H window 100%,100%,0,1 cursor 0 wait 1000 remove done

This line works in the Windows terminal or console but not the cursor.

This line does not work in the MSYS2 and PowerShell terminals and I have to use variables like Garagecoder (message On the road to 3.0 - #411 by garagecoder ).
Nota : You have to adapt this line by adding ./ for msys2 and ./ or .\ For PowerShell at the beginning.

I want to make a small slide show program. Do you have a solution for {*,u} and {*,v} ?

Thank you :o)

I’m not quite sure what you mean - I tested this in a virtual machine windows 10 and it looks OK for me, the cursor disappears. The only problem I had with fullscreen on windows is that the taskbar gets in the way. Sometimes using gmic run "commands here" does the job.

I just added gcd_browse for that. It will be a while before it’s available with gmic up. Perhaps you can get some clues there, it works for me on windows VM. It uses keyboard only, but you can always copy and edit.

@garagecoder
Bonjour,

Thank you for the answer.
The command line does not always work well. For example when the cursor touches a side of the screen. I do not know why.

I will look at your ‘GCD_BROWSE’ script and adapt it as an example in a .bat file that will use PowerShell as a launcher of the Slide Show.

:o)

On windows, I usually put longer commands into the file user.gmic in %AppData%. Otherwise, it becomes more difficult to escape disallowed terminal characters. But good luck anyway!

@garagecoder

There is no problem because I ‘recreate’ the filter from the .bat file.
This is the way I use to avoid the problems of characters, I cross the fingers…
:o)

Edit 20211118
In the archive there is ‘Test_Full-Screen_GMIC-CLI.bat’ to put in the gmic.exe directory.
Click on to launch the Slide Show PowerShell.
This is an example like the post On the road to 3.0 - #463 by samj and the images are simply put to the size of the screen.
The cursor disappears during the Slide Show.

Test_Full-Screen_GMIC-CLI.7z (725 Bytes)

1 Like

I tried this batch file and it does exactly the same as your earlier example. What I did have to do in powershell is use this:

.\gmic.exe run "cursor 0 Screen_W={*,u} Screen_H={*,v} repeat 5 fx_image_sample 0,0,0 resize `$Screen_W,`$Screen_H window 100%,100%,0,1 cursor 0 wait 1000 remove done"

So that is two things: use gmic run "...stuff here..." and put a backtick ` before each $ to escape them.

1 Like

@garagecoder
Bonjour,
Your command line works very well and there is no cursor problem :o)
My previous message script also allows you to display on a system with multiple monitors.
I also like the ability to easily create file lists with a .bat file in a foo.gmic program that I call next.
I will use your advice.
:o)

Ah! Substitution Rule Number 2. Neither the techical reference name nor tutorial name seem conversant with the notion that a $-prefixed selection name resolves to the highest-value image index that is encompassed by the named selection. Being by nature terse, I suppose one might excuse the technical reference, but the tutorial needs upgrading. Throw another one on the TODO list (clunk!).

gmic 1,1,1,3,[127,127,127] name Gray echo "Select Gray: "\$Gray
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input image at position 0, with values '[127,127,127]' (1 image 1x1x1x3).
[gmic]-1./ Set name of image [0] to 'Gray'.
[gmic]-1./ Select gray: 0
[gmic]-1./ Display image [0] = 'Gray'.
[0] = 'Gray':
  size = (1,1,1,3) [12 b of floats].
  data = (127 ^ 127 ^ 127).
  min = 127, max = 127, mean = 127, std = 0, coords_min = (0,0,0,0), coords_max = (0,0,0,0).
[gmic]-1./ End G'MIC interpreter.

The image indices encompassed by named selections track the repositioning of constituent images, and the substitution form reflects such resequencing:

$ gmic 1,1,1,3,[127,127,127] name Gray [Gray]x4 name[1--1:2] LightPink name[2--1:2] DarkGreen fill_color[LightPink] 255,188,250 fill_color[DarkGreen] 79,107,53  echo "Select Gray: "\$Gray  echo "Select LightPink: "\$LightPink  echo "Select DarkGreen: "\$DarkGreen -d0 -luminance sort_list +,i echo "$Select Gray: "\$Gray  echo "Select LightPink: "\$LightPink  echo "Select DarkGreen: "\$DarkGreen -d0

$  gmic 1,1,1,3,[127,127,127] name Gray [Gray]x4 name[1--1:2] LightPink name[2--1:2] DarkGreen fill_color[LightPink] 255,188,250 fill_color[DarkGreen] 79,107,53  echo "Select Gray: "\$Gray  echo "Select LightPink: "\$LightPink  echo "Select DarkGreen: "\$DarkGreen -d0 -luminance sort_list +,i echo "$Select Gray: "\$Gray  echo "Select LightPink: "\$LightPink  echo "Select DarkGreen: "\$DarkGreen -d0
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input image at position 0, with values '[127,127,127]' (1 image 1x1x1x3).
[gmic]-1./ Set name of image [0] to 'Gray'.
[gmic]-1./ Input 4 copies of image [0] at position 1 (4 images [0] = 1x1x1x3, (...),[3] = 1x1x1x3).
[gmic]-5./ Set names of images [1,3] to 'LightPink'.
[gmic]-5./ Set names of images [2,4] to 'DarkGreen'.
[gmic]-2./ Fill images [1,3] with color (255,188,250).
[gmic]-2./ Fill images [2,4] with color (79,107,53).
[gmic]-5./ Select Gray: 0
[gmic]-5./ Select LightPink: 3
[gmic]-5./ Select DarkGreen: 4
[gmic]-5./ Start interactive display of 2d images [0,1,2,3,4].
[gmic]-5./d0/_display2d/ Print images [0,1,2,3,4] = 'Gray, (...), DarkGreen'.
[0] = 'Gray':
  size = (1,1,1,3) [12 b of floats].
  data = (127 ^ 127 ^ 127).
  min = 127, max = 127, mean = 127, std = 0, coords_min = (0,0,0,0), coords_max = (0,0,0,0).
[1] = 'LightPink':
  size = (1,1,1,3) [12 b of floats].
  data = (255 ^ 188 ^ 250).
  min = 188, max = 255, mean = 231, std = 37.3229, coords_min = (0,0,0,1), coords_max = (0,0,0,0).
[2] = 'DarkGreen':
  size = (1,1,1,3) [12 b of floats].
  data = (79 ^ 107 ^ 53).
  min = 53, max = 107, mean = 79.6667, std = 27.0062, coords_min = (0,0,0,2), coords_max = (0,0,0,1).
[3] = 'LightPink':
  size = (1,1,1,3) [12 b of floats].
  data = (255 ^ 188 ^ 250).
  min = 188, max = 255, mean = 231, std = 37.3229, coords_min = (0,0,0,1), coords_max = (0,0,0,0).
[4] = 'DarkGreen':
  size = (1,1,1,3) [12 b of floats].
  data = (79 ^ 107 ^ 53).
  min = 53, max = 107, mean = 79.6667, std = 27.0062, coords_min = (0,0,0,2), coords_max = (0,0,0,1).
[gmic]-5./ Compute luminance of images [0,1,2,3,4].
[gmic]-5./ Sort list of images [0,1,2,3,4] in ascending order, according to the image criterion 'i'.
[gmic]-5./  Gray: 2
[gmic]-5./ Select LightPink: 4
[gmic]-5./ Select DarkGreen: 1
[gmic]-5./ Start interactive display of 2d images [0,1,2,3,4].
[gmic]-5./d0/_display2d/ Print images [0,1,2,3,4] = 'DarkGreen, (...), LightPink'.
[0] = 'DarkGreen':
  size = (1,1,1,1) [4 b of floats].
  data = (99.0701).
  min = 99.0701, max = 99.0701, mean = 99.0701, std = 0, coords_min = (0,0,0,0), coords_max = (0,0,0,0).
[1] = 'DarkGreen':
  size = (1,1,1,1) [4 b of floats].
  data = (99.0701).
  min = 99.0701, max = 99.0701, mean = 99.0701, std = 0, coords_min = (0,0,0,0), coords_max = (0,0,0,0).
[2] = 'Gray':
  size = (1,1,1,1) [4 b of floats].
  data = (127).
  min = 127, max = 127, mean = 127, std = 0, coords_min = (0,0,0,0), coords_max = (0,0,0,0).
[3] = 'LightPink':
  size = (1,1,1,1) [4 b of floats].
  data = (209.488).
  min = 209.488, max = 209.488, mean = 209.488, std = 0, coords_min = (0,0,0,0), coords_max = (0,0,0,0).
[4] = 'LightPink':
  size = (1,1,1,1) [4 b of floats].
  data = (209.488).
  min = 209.488, max = 209.488, mean = 209.488, std = 0, coords_min = (0,0,0,0), coords_max = (0,0,0,0).
[gmic]-5./ End G'MIC interpreter.

Is it possible to programmatically resolve the (possible) vector which a named selection could represent? For example, above, the named selection “LightPink” initially represented a vector of image indices [1,3], and after sorting, that name selection became vector [3,4], reflecting the repositioning of members of the selection. I could imagine circumstances where I could make use of obtaining such dynamically changing vectors, as in: “Where are the members of “LightGreen” now on the image list?”

Probably -named? See doc page : G'MIC - GREYC's Magic for Image Computing: A Full-Featured Open-Source Framework for Image Processing - Reference Documentation - named

@garagecoder
Bonjour,

Tests of the command line On the road to 3.0 - #468 by garagecoder

I tested your command line with Windows and MSYS2 consoles.
Everything works perfectly.
The problem of the cursor seems to me resolved :o)

In the case of the Windows console :

  • ’run’ makes it possible to obtain a correct result. Well done!
  • Do not use the form ‘.\gmic.exe …’ because the problem of the cursor reappears.
  • Do not use a backtick `

In the case of the MSYS2 console :

  • Do not use a backtick ` and/or $

The command lines used that operate during the tests :

Windows console
gmic.exe run "cursor 0 Screen_W={*,u} Screen_H={*,v} repeat 5 fx_image_sample 0,0,0 resize $Screen_W,$Screen_H window 100%,100%,0,1 cursor 0 wait 1000 remove done"

MSYS2 console
./gmic.exe run "cursor 0 repeat 5 fx_image_sample 0,0,0 resize {*,u},{*,v} window 100%,100%,0,1 cursor 0 wait 1000 remove done"

I will test your program ‘gcd_browse’ and if I have remarks I will open a thread on this subject.

You can set gmic as environment path to avoid needing to type in gmic.exe. @samj

This also makes scripting in gmic so much easier as you can make a folder with test pictures. And just redirect cmd to there.

Is it intentionally that custom functions delaunay and delaunay3d are without convex hull resp without the triangles containing convex hull edges. ?

Amazing improvements! Thank you for your incredibly work.

@David_Tschumperle
It might be interesting to know that ilaplacian benefits from better accuracy provided by the math parser. Looking back at my old experiments, I thought I’d test a basic “seamless blend” with the divergence calculated as follows:

gcd_seamless_example :
  sp sp
  +r[0] 1,1,1,100%,2 avg={^} rm.
  ri. .. to_rgba.
  l. W={w} r2dx {round(0.25*w)},2 r2dx $W,0,0,0.5,0.5 endl
  split_opacity. n. 0,1 erode. 3
  f[0] "begin(boundary=1;
    fx0(x,y)=(j(x,y)-i);
    fx1(x,y)=(j(#1,x,y)-i#1);
    bx0(x,y)=(i-j(x,y));
    bx1(x,y)=(i#1-j(#1,x,y));
  );
  lerp(fx0(1,0),fx1(1,0),i#2) -
  lerp(bx0(-1,0),bx1(-1,0),j(#2,-1)) +
  lerp(fx0(0,1),fx1(0,1),i#2) -
  lerp(bx0(0,-1),bx1(0,-1),j(#2,0,-1))"
  k[0] ilaplacian 0 +fc. $avg +[-2,-1] c 0,255

I don’t know how it affects speed, but the image quality does improve I think.

Interesting. I’ve always been a bit disappointed by ilaplacian, as it sometimes renders weird things. It’s actually a bit hard to manage the boundary conditions correctly, and this command probably requires some update.
Anyway, I’ve not tested (yet) your example, but I will !

Indeed, I’m beginning to wonder where the improvement actually lies… my assumption about precision could be nothing to do with it. Perhaps worth looking at regardless :slight_smile:

Edit: yes, it looks like boundaries are the culprit. Using expand_xy with neumann boundary makes problems disappear as well. I see blend_seamless already deals with it. Sorry for the distraction!

Update:
I get it now. The reason is boundary conditions for the second gradient/difference. The first gradient should be neumann, but the second should be dirichlet. This illustrates the problem:
gmic 5,1,1,1,x +g x,1 g. x,-1 f[0] "begin(boundary=1);j(1)-i" f[0] "begin(boundary=0);i-j(-1)"

Doing it all in a single pass within the math parser avoids the issue:
gmic 5,1,1,1,x f "begin(boundary=1);j(1)-i-(i-j(-1))"

Conclusion: if gradient allowed boundary = dirichlet then the problem would be solved.
I imagine you already know this though :slight_smile:

1 Like

Seems I was still wrong. The boundary needs to be periodic, for both first and second differences:
gmic 5,1,1,1,x f "begin(boundary=2);j(1)-i" f "begin(boundary=2);i-j(-1)" ilaplacian 0

That suggests gradient should be recoded to allow this. And probably as a custom command rather than a native one (I don’t see why a custom command would be less performant in that case, after all, this is just about applying some 3x3 kernels)

Yes, I think ideally it should allow all the usual boundaries. Periodic boundary laplacian actually solves the seamless problem completely. No glitches. That can be seen by taking gcd_seamless_example and set boundary=2.

Proof:
gmic sp +r 1,1,1,100%,2 avg={^} rm. f "begin(boundary=2);j(1)+j(-1)+j(0,1)+j(0,-1)-4*i" ilaplacian 0 +fc \$avg add

That’s probably because ilaplacian uses a FFT-based reconstruction, which implicitely considers periodic boundary conditions.

I’ll try to rewrite gradient as a custom command, to allow any kind of boundary conditions.

1 Like