Release of G'MIC 3.1

Tested now with latest pre-release. It doesn’t happen with latest pre-release.

1 Like

Speaking of gcd(), I think that function can be improved to use multiple arguments:

See this code - C++ Program for GCD of more than two (or array) numbers - GeeksforGeeks

EDIT: There could also be lcd(a,b)

int lcm(int a, int b)
{
    return (a * b) / gcd(a, b);
}

One could say that for many functions. Maybe take a look at what could take an arbitrary number but isn’t currently.

I checked.

I only see gcd() could be using a improvement. As for lcm()/lcd(), there are codes for 2 inputs, and multiple inputs.

Only for the linux version Gimp plugin. Maybe include a readme advice note.

The zipped downloaded Gimp plugin is now a dynamic version, two files gmic_gimp_qt & libgmic.so.3 There are new linux users who will unzip and pop those files into the Gimp user profile and wonder why the plugin does not work.

At a basic level give advice as to where the libgmic.so.3 goes.

Better is zip the files straight into a gmic_gimp_qt folder which would then go into the Gimp user profile and advice on making a symlink for that lib file, say as root

ln -s ~/.config/GIMP/2.10/plug-ins/gmic_gimp_qt/libgmic.so.3 /usr/lib/libgmic.so.3

Then an update only requires replacing the gmic_gimp_qt folder.

Actually, this shouldn’t be necessary.
When I compile the plug-in, I use

  LIBS += -Wl,-rpath,. $$GMIC_PATH/libgmic.so

which means the libgmic.so file is also searched in the same folder as the binary.
Maybe this has not been ported to the CMakeLists.txt file.
How are you compiling the plug-in ?

Just tested here, uninstalled everything related to gmic on my system, then:

$ unzip gmic_gimp2.10_ubuntu20-04_focal_amd64.zip 
Archive:  gmic_gimp2.10_ubuntu20-04_focal_amd64.zip
  inflating: gmic_gimp_qt            
  inflating: libgmic.so.3            
  inflating: README                  

$ sudo cp gmic_gimp_qt libgmic.so.3 /usr/lib/gimp/2.0/plug-ins/

$ gimp ~/work/img/lena.bmp &
[1] 7009
(focal-base r3096)tschumperle@C302L-G17P17:~/Downloads$ 
$ gimp: LibGimpBase-WARNING: gimp: gimp_wire_read(): error
Icon theme "elementary" not found.

And the plug-in runs correctly.
I should however unzip the files in a gmic_gimp_qt folder, you are right.

This is a kubuntu 20.04 / Gimp 2.10.30 from a PPA / your gmic 3.1.0 (3.0.2 the same)

A question: Could there be improvement on speed of accessing pixels and modifying it within math evaluator? Like i(#-1,xx,yy)++ for example. In the PDN forum, after multithreading was implemented onto Popcorn Fractal plugin, it comes close to the fastest theoretical time to finish. G’MIC is about 70% to that speed.

Strange… Anyway, to make things simpler, I’ll distribute the G’MIC-Qt plug-in with a single executable file where libgmic is statically included (just as before).
Thanks for your feedback.

I don’t see how.
Remember that the math evaluator in G’MIC is indeed an expression compiler, but it does not compile the expression directly in assembly code (which is probably the case for the JIT of C#), but as a sequence of bytecodes that is further evaluated. So you cannot expect performances as good as assembly code.

It is my observation that formulas without accessing pixels to return value from said pixel seem to be much, much faster. That’s why I thought that the speed of i(#-1…)++ could be improved.

gmic 10,1,1,1,x 10 f. i(#-2)++

The above command shows that i(#-2)++ access said pixel, and then return the value. Could there be a speedup without having it to return a value back i.e, it does nothing at all on the image that code is running on?

There’s also eval. It seem that it returns the last line of code, but does it do that for other lines?

Also, I know not to expect it to be better, but regardless, I am trying to think of ways to improve the speed on this part. There was a conversation where you pointed out that multi-threading can lead to unsafe behavior, I just figured out that faster internal calculation speed doesn’t always mean better experience.

I found something interesting here. Works well for even numbers.

Code:

rep_test_bug:
($*) (0) # First image still has the input value
eval.. da_push(#-1,int(abs(i)));resize(#-1,1,da_size(#-1),1,1);
echo {i}
rm..
eval [$*]
echo ${}

Output:

C:\Windows\System32>gmic rep_test_bug 25152163
[gmic]-0./ Start G'MIC interpreter.
[gmic]-2./rep_test_bug/ 25152164
[gmic]-1./rep_test_bug/ 25152163

Colormap appears to have broken. Not really colormap, but sample. See ADDENDA.

gosgood@bertha ~ $ gmic sp cat,512 colormap 4,1,2
[gmic]-0./ Start G'MIC interpreter.
[gmic] *** Error in ./+sp/_sample/*repeat/ *** Unknown command or filename '=>'; did you mean '='?

This is with:

gosgood@bertha ~/git_repositories/gmic/src $ gmic -version

  gmic: GREYC's Magic for Image Computing: command-line interface
        Version 3.1.0 (pre-release #220410)
        (https://gmic.eu)

        Copyright (c) Since 2008, David Tschumperlé / GREYC / CNRS.
        (https://www.greyc.fr)

This is a comparison of colormap code dumps. The top, b_301 is the production release. The bottom, b_310, compares with commit 77fe08b0b360 Wed Apr 6 05:03:00 2022 UT. The red-box around one diff region appears to coincide with the shell log error message given by G’MIC

Here is what git log -L 11842,11852:gmic_stdlib.gmic reports:

It appears that the :: notation is substituting to the new => name shortcut, but it is not being recognized as such by the command line parser. ADDENDA: Ary substitution happening in sampler

ADDENDA:
The misinterpretation of => is not just occurring in the confines of colormap; but sample instead.
I can make an Empty and name it as such using ‘::’ notation; so I can see what kind of substitution is supposed to happen:

gosgood@bertha ~/git_repositories/gmic/src $ gmic debug 0 '::'. Empty
[gmic]-0./ Start G'MIC interpreter (in debug mode).
<gmic>-0./ Initial command line: 'cli_start , debug 0 ::. Empty'.
<gmic>./ Decompose command line into 6 items: 
<gmic>./   item[0] = 'cli_start'
<gmic>./   item[1] = ','
<gmic>./   item[2] = 'debug'
<gmic>./   item[3] = '0'
<gmic>./   item[4] = '::.'
<gmic>./   item[5] = 'Empty'

<gmic>-0./ Enter scope './'.
<gmic>-0./ Item[0]: 'cli_start', selection [].
<gmic>-0./ Found custom command 'cli_start: ' (takes no arguments).
<gmic>-0./ Expand command line for command 'cli_start' to: ''.
<gmic>-0./cli_start/ Return from empty command 'cli_start/'.
<gmic>-0./ Item[2]: 'debug', selection [].
<gmic>-0./ Item[3]: '0', selection [].
<gmic>-0./ Command 'input': arguments = '0'.
[gmic]-0./ Input empty image at position 0 (1 image 0x0x0x0).
<gmic>-1./ Item[4]: '::.', selection [0].  **** Compare this with !!!! below ****
<gmic>-1./ Command 'name': arguments = 'Empty'.
[gmic]-1./ Set name of image [0] to 'Empty'.
[gmic]-1./ Display image [0] = 'Empty'.
[0] = 'Empty':
  size = (0,0,0,0) [0 b of floats].
  data = (nil) = () [float].

But at the end of sample a similar substitution goes ary:

gosgood@bertha ~/git_repositories/gmic/src $ gmic debug sp cat,512
[gmic]-0./ Start G'MIC interpreter (in debug mode).<gmic>-0./ Initial command line: 'cli_start , debug sp cat,512'.
<gmic>./ Decompose command line into 5 items: 
<gmic>./   item[0] = 'cli_start'
<gmic>./   item[1] = ','
<gmic>./   item[2] = 'debug'
<gmic>./   item[3] = 'sp'
<gmic>./   item[4] = 'cat,512'

<gmic>-0./ Enter scope './'.
<gmic>-0./ Item[0]: 'cli_start', selection [].
<gmic>-0./ Found custom command 'cli_start: ' (takes no arguments).
<gmic>-0./ Expand command line for command 'cli_start' to: ''.
<gmic>-0./cli_start/ Return from empty command 'cli_start/'.
<gmic>-0./ Item[2]: 'debug', selection [].
<gmic>-0./ Item[3]: 'sp', selection [].
<gmic>-0./ Found custom command '+sp: skip "${1=?}",${2=0} v + _sample[] "$1",${2--1} v - if !${} noarg fi' (takes arguments).
<gmic>-0./ Command 'sp': arguments = 'cat,512'.
<gmic>-0./ Found 2 given arguments for command '+sp':
<gmic>-0./   $1 = 'cat'
<gmic>-0./   $2 = '512'
<gmic>-0./ Expand command line for command '+sp' to: 'skip "cat",512 v + _sample[] "cat",512 v - if !${} noarg fi'.
<gmic>./ Decompose command line into 12 items: 
<gmic>./   item[0] = 'skip'
<gmic>./   item[1] = 'cat,512'
<gmic>./   item[2] = 'v'
<gmic>./   item[3] = '+'
<gmic>./   item[4] = '_sample[]'
<gmic>./   item[5] = 'cat,512'
<gmic>./   item[6] = 'v'
<gmic>./   item[7] = '-'
<gmic>./   item[8] = 'if'
<gmic>./   item[9] = '!${}'
<gmic>./   item[10] = 'noarg'
<gmic>./   item[11] = 'fi'

debug dump elided for brevity

<gmic>-1./+sp/_sample/*repeat/*if/ Item[80]: 'round.', selection [0].
<gmic>-1./+sp/_sample/*repeat/*if/ Command 'round': arguments = 'elif'.
[gmic]-1./+sp/_sample/*repeat/*if/ Round values of image [0] by 1 and nearest rounding.
<gmic>-1./+sp/_sample/*repeat/*if/ Item[81]: 'elif', selection [0].
[gmic]-1./+sp/_sample/*repeat/*if/ Reach 'else' block.
<gmic>-1./+sp/_sample/*repeat/*if/ Item[99]: 'fi', selection [0].
[gmic]-1./+sp/_sample/*repeat/*if/ End 'if...endif' block.
!!!!!<gmic>-1./+sp/_sample/*repeat/ Item[100]: '=>', selection []. !!!!!!!!!!!!!!!!!! '::' → '=>' already
<gmic>-1./+sp/_sample/*repeat/ Command 'input': arguments = '=>'.
[gmic]-1./+sp/_sample/*repeat/ Input file '=>' at position 1
[gmic]-1./+sp/_sample/*repeat/ *** Error *** Unknown command or filename '=>'; did you mean '='?
[gmic] *** Error in ./+sp/_sample/*repeat/ *** Unknown command or filename '=>'; did you mean '='?

:: has been repaced by => recently.
Maybe the Windows binaries have not been updated. I’ll check that today.

Where did you get pre-release #220410 ? Have you compiled it by yourself ?
The latest pre-release on the G’MIC website is #220406.
Also, did’nt you forget to $ gmic update ?

Linux here:

gosgood@bertha ~ $ uname -a
Linux bertha 5.15.26-gentoo-bertha #1 SMP Sun Apr 3 10:07:59 EDT 2022 x86_64 Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz GenuineIntel GNU/Linux

Built from sources at about 20:00 UTC yesterday
gmic/src: commit 77fe08b0b360aa433bb3e5295fb600bd0e5541d6 (HEAD → master, origin/master, origin/HEAD)
Author: David Tschumperle David.Tschumperle@unicaen.fr
Date: Wed Apr 6 07:03:00 2022 +0200

Build steps:

  1. remove old binaries gmic and the plugin gimp_gimic_qt
  2. Do make distcleans in gmic and gmic-qt projects
  3. Clean $HOME/.config/gmic and $HOME/.config/GIMP/2.10/plug-ins
  4. git pull origin master in both projects and CImg
  5. make cli && make make gimp in gmic/src
  6. distribute gmic to /home/gosgood/.local/bin/gmic (first on ${PATH})
  7. distribute gimp_gmic_qt to $HOME/.config/GIMP/2.10/plug-ins
  8. gmic -version for a smoke test in a shell.
  9. gmic -update to download update310.gmic
    9a. Current update310.gmic
-rw-r--r-- 1 gosgood gosgood 4922110 Apr 10 18:32 update310.gmic (22:32 UTC)
sha256sum: 1edce0d9ce100e33ffa90f44980771888fd0d3fce069f058298ba3be1bbb49fc  /home/gosgood/.config/gmic/update310.gmic

All this was done before seeing observed phenonmena.

Could please try again, I’ve just merged the ‘devel’ branch into ‘master’.
Thanks!

About an hour, yes. Time to walk the puppy dog.

Life is good. :slight_smile: Built with :

commit c1d98db6e775863d3fa10af0eb1c6dcc3b51ddb7 (HEAD -> master, origin/master, origin/HEAD)
Author: David Tschumperle <David.Tschumperle@unicaen.fr>
Date:   Thu Apr 7 16:21:47 2022 +0200
gosgood@bertha ~ $ which gmic
/home/gosgood/.local/bin/gmic
gosgood@bertha ~ $ gmic -version

  gmic: GREYC's Magic for Image Computing: command-line interface
        Version 3.1.0 (pre-release #220411)
        (https://gmic.eu)

        Copyright (c) Since 2008, David Tschumperlé / GREYC / CNRS.
        (https://www.greyc.fr)

gosgood@bertha ~ $ gmic -update
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Update command definition file '/home/gosgood/.config/gmic/update310.gmic' from the G'MIC server.
[gmic]-0./ End G'MIC interpreter.
gosgood@bertha ~ $ gmic sp cat,512 colormap 4,1,2
[gmic]-0./ Start G'MIC interpreter.
[gmic]-1./ Input sample image 'cat' (1 image 512x469x1x3).
[gmic]-1./ Estimate colormap with 4 entries for image [0], by k-means method.
[gmic]-1./ Display image [0] = '[colormap of cat]'.
[0] = '[colormap of cat]':
  size = (4,1,1,3) [48 b of floats].
  data = (187.919,160.086,203.631,76.1657 ^ 131.596,71.2735,178.374,29.4853 ^ 69.7817,21.1079,144.886,12.3982).
  min = 12.3982, max = 203.631, mean = 107.225, std = 68.6131, coords_min = (3,0,0,2), coords_max = (2,0,0,0).
[gmic]-1./ End G'MIC interpreter.

Gives me a pretty colormap:

Commits to gmic/src since report:

commit c1d98db6e775863d3fa10af0eb1c6dcc3b51ddb7 (HEAD -> master, origin/master, origin/HEAD)
Author: David Tschumperle <David.Tschumperle@unicaen.fr>
Date:   Thu Apr 7 16:21:47 2022 +0200

    .

commit e0203141f4d8b66c4e0bea46ddb44a7ae72bae99
Author: David Tschumperle <David.Tschumperle@unicaen.fr>
Date:   Thu Apr 7 15:56:04 2022 +0200

    .

commit d5ad465b1713547da97e5c61e3b2922b0ab38887
Author: David Tschumperle <David.Tschumperle@unicaen.fr>
Date:   Thu Apr 7 14:47:08 2022 +0200

    .

commit 30256fc64d75940ee6f32b87ae43cff4ce32f131
Author: David Tschumperle <David.Tschumperle@unicaen.fr>
Date:   Thu Apr 7 12:52:52 2022 +0200

    .

commit 635e656acb21c6d75f76949cf05f039952d707db
Author: David Tschumperlé <david.tschumperle@gmail.com>
Date:   Wed Apr 6 09:15:54 2022 +0200

    Auto-commit for release 3.1.0_pre

commit 77fe08b0b360aa433bb3e5295fb600bd0e5541d6
Author: David Tschumperle <David.Tschumperle@unicaen.fr>
Date:   Wed Apr 6 07:03:00 2022 +0200

    .

The gimp plug-in is building now, and haven’t done anything beyond what brought me onto the rocks yesterday evening, but in so far as basic smoke testing goes, I seem good now. Cheers!

ADDENDA:
gimp plug-in appears to be working as well. Off to the city…