Release of G'MIC 3.2

So why not replacing the slowest one by your version directly in the stdlib ?

Hah, I did see this question on the horizon :slight_smile:
I generally assume my own code will not be perfect in some way, compared to what you would produce.

Anyway, I also assume you can tweak it, so here’s what I have right now. Firstly a convenience wrapper around convolve because the syntax is a headache for me:

#@cli gcd_convolve_atrous : [mask],_scale>=1
#@cli : Convolve selected images with specified mask and kernel scale.
#@cli : $ image.jpg (1,0,1) +gcd_convolve_atrous.. .,10
gcd_convolve_atrous : check ${"is_image_arg $1"}" && isnum(${2=1}) && $2>=1"
  pass$1 0
  repeat $!-1 l[$>,-1]
    c={ceil(([w,h,d]-1)/2)} whd={0,[w,h,d]-1}
    convolve.. .,1,0,1,$c,0,0,0,$whd,1,1,1,$2,$2,$2
  done done rm.

And then a partially implemented split details command:

# split using wavelets
gcd_split_details : skip ${1=2}
  foreach {
    repeat $1-1 {
      K:=2^$> (1,4,6,4,1) /. 16
      +gcd_convolve_atrous.. .,$K
      transpose.. gcd_convolve_atrous. ..,$K
      rm.. -.. .
    } rv
  }

Two comments: I know I can improve that code myself, so there’s no doubt you can do better. Second, I didn’t even attempt handling 3D.

Edit: perhaps your point is I could do it “properly” if I had to. Maybe next time!

1 Like

I also gave it a go at one point, but it was slower. :no_entry_sign: Good that you wrote a better solution.

1 Like

Regarding “color map 0”, I have always wanted option to have the frequency of each colors. I have some mode related commands myself. I know it can be improved.

What you want basically is the histogram of the color indices of the full image colormap :

foo : 
  sp lena
  +colormap. 0 index.. . rm. 
  histogram. {iM+1}

It could be done slightly faster by modifying directly colormap 0, but not significantly.

17 posts were split to a new topic: Switch statement

I’ve uploaded new binaries for 3.2.0_pre today, with various improvements, including the optimization of simple conditional expressions (as val1 == val2).
Now, I’m thinking about releasing it as the final 3.2.0 release, so please check and let me know if you find some bugs or unexpected behaviors. Thanks!

1 Like

I’d be really interested by all your feedback on this version, particularly from:

  • @KaRo , to check is G’MIC is working properly on Mac (compilation warnings?).
  • @garagecoder , @Reptorian to check if everything seems to work as expected when you’re a script developer :slight_smile: And also to suggest (simple) features that could be added before the release.
  • And all other users to check if all filters are working properly.

If everything goes well and I don’t get negative feedbacks, then I’ll release 3.2.0 this week.

3 Likes

I had no time to test a bit, still building works, one warning with g++, using git develop
Command:
(cd ~/work/src/gmic/src/; make -B OPENCV_CFLAGS="$(shell pkg-config opencv4 --cflags)" OPENCV_LIBS="$(shell pkg-config opencv4 --libs)" EXTRA_CFLAGS="-march=native -O3 -flto -Wno-c11-extensions -Wno-c++17-extensions -Dcimg_use_opencv $(OPENCV_CFLAGS) -Dcimg_use_heif" EXTRA_LIBS="$(OPENCV_LIBS) -lheif -Wno-c11-extensions -Wno-c++17-extensions " cli || exit; cp ~/work/src/gmic/src/gmic /usr/local/bin/)

In file included from ./gmic.cpp:2078:
In file included from ./gmic.h:253:
./CImg.h:26972:22: warning: variable ‘siz’ set but not used [-Wunused-but-set-variable]
unsigned int siz = 0;
^

By the way, command:

make CXX=clang+ + -mp-15 OPT_CLI_CFLAGS="-march=native -O3 -flto -fopenmp $(XSHM_CFLAGS)" OPENCV_CFLAGS="-Dcimg_use_opencv $(shell pkg-config opencv4 --cflags)" OPENCV_LIBS="$(shell pkg-config opencv4 --libs)" OPT_LIBS="-L/opt/local/lib/libomp -lgomp $(XSHM_LIBS)" cli

is building too

1 Like

Gamma function for math evaluator? I believe new things can be found with it. I know of fact(n), but it doesn’t have that gamma curve.

Thanks Karsten, I’ve fixed it.

Done as well: cimg_math_parser(): Add 'gamma()' function. · GreycLab/CImg@7ae52c2 · GitHub

Last git develop built: Buttons in demos window without text!

Terminating “Color Curves” throws an error and terminates “demos”

Should be fixed.

That is strange, it does not occur here.

The latter still, terminate by esc or what ever!

gmic demos
[gmic]-0./ Start G’MIC interpreter.

------ G’MIC demos ------------------

---- Mouse button to select a demo.
---- Keys ‘CTRL+D’ to increase window size.
---- Keys ‘CTRL+C’ to reset window size.
---- Keys ‘ESC’ or ‘Q’ to exit.


------ Color curves ----------------------------------------------------------------------------

---- Left mouse button on a curve creates a new control point (or moves an existing one).
---- Right mouse button on a control point deletes it.
---- Left mouse button on the main image window shows the initial image until button is released.
---- Right mouse button on the main image window adds a keypoint to all curves from picked color.
---- Key ‘R’ on a curve resets it.
---- Keys ‘CTRL+D’ increase window size.
---- Keys ‘CTRL+C’ decrease window size.
---- Keys ‘CTRL+R’ reset window size.
---- Keys ‘ESC’, ‘Q’ or ‘ENTER’ close the current window.


[gmic] G’MIC encountered a fatal error. Please submit a bug report, at: Issues · GreycLab/gmic · GitHub

/Users/karo $

Thanks @KaRo , here again, a valgrind or fsanitize output would be appreciated!

Still possible!

/Users/karo/sw/gmic/src $ lldb ./gmic demos
(lldb) target create “./gmic”
Current executable set to ‘/Users/karo/sw/gmic/src/gmic’ (x86_64).
(lldb) settings set – target.run-args “demos”
(lldb) run
Process 12306 launched: ‘/Users/karo/sw/gmic/src/gmic’ (x86_64)
gmic(12306,0x101ac0600) malloc: nano zone abandoned due to inability to preallocate reserved vm space.
[gmic]-0./ Start G’MIC interpreter.

------ G’MIC demos ------------------

---- Mouse button to select a demo.
---- Keys ‘CTRL+D’ to increase window size.
---- Keys ‘CTRL+C’ to reset window size.
---- Keys ‘ESC’ or ‘Q’ to exit.


------ Color curves ----------------------------------------------------------------------------

---- Left mouse button on a curve creates a new control point (or moves an existing one).
---- Right mouse button on a control point deletes it.
---- Left mouse button on the main image window shows the initial image until button is released.
---- Right mouse button on the main image window adds a keypoint to all curves from picked color.
---- Key ‘R’ on a curve resets it.
---- Keys ‘CTRL+D’ increase window size.
---- Keys ‘CTRL+C’ decrease window size.
---- Keys ‘CTRL+R’ reset window size.
---- Keys ‘ESC’, ‘Q’ or ‘ENTER’ close the current window.

------------------------------------------------------------------------------------------------=================================================================
==12306==ERROR: AddressSanitizer: heap-use-after-free on address 0x61e000127168 at pc 0x0001001e74ac bp 0x7ff7bfe79ff0 sp 0x7ff7bfe79fe8
READ of size 8 at 0x61e000127168 thread T0
#0 0x1001e74ab in gmic::current_is_abort() gmic.cpp:2393
#1 0x1005814b4 in gmic_library::gmic_image::_fill(char const*, bool, unsigned int, gmic_library::gmic_list, char const, gmic_library::gmic_image const*) CImg.h:32344
#2 0x1002443b5 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:14954
#3 0x10025afc2 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:9086
#4 0x10023b0f4 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:14431
#5 0x10020c0b9 in gmic& gmic::_run(gmic_library::gmic_list const&, gmic_library::gmic_list&, gmic_library::gmic_list&, float*, bool*) gmic.cpp:5406
#6 0x101622273 in gmic& gmic::run(char const*, gmic_library::gmic_list&, gmic_library::gmic_list&, float*, bool*) gmic.cpp:5370
#7 0x100007af3 in main gmic_cli.cpp:231
#8 0x101a4552d in start+0x1cd (dyld:x86_64+0x552d)

0x61e000127168 is located 1256 bytes inside of 2568-byte region [0x61e000126c80,0x61e000127688)
freed by thread T2 here:
#0 0x102d2c72d in wrap__ZdaPv+0x7d (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x5c72d)
#1 0x1002a0a8c in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:11013
#2 0x10026b996 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:8080
#3 0x10023b0f4 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:14431
#4 0x10023b0f4 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:14431
#5 0x10023b0f4 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:14431
#6 0x10025afc2 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:9086
#7 0x1008007b4 in void* gmic_parallel(void*) gmic.cpp:2706
#8 0x7ff8051004e0 in _pthread_start+0x7c (libsystem_pthread.dylib:x86_64+0x64e0)
#9 0x7ff8050fbf6a in thread_start+0xe (libsystem_pthread.dylib:x86_64+0x1f6a)

previously allocated by thread T2 here:
#0 0x102d2c31d in wrap__Znam+0x7d (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x5c31d)
#1 0x10029ed2e in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:10886
#2 0x10026b996 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:8080
#3 0x10023b0f4 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:14431
#4 0x10023b0f4 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:14431
#5 0x10023b0f4 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:14431
#6 0x10025afc2 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:9086
#7 0x1008007b4 in void* gmic_parallel(void*) gmic.cpp:2706
#8 0x7ff8051004e0 in _pthread_start+0x7c (libsystem_pthread.dylib:x86_64+0x64e0)
#9 0x7ff8050fbf6a in thread_start+0xe (libsystem_pthread.dylib:x86_64+0x1f6a)

Thread T2 created by T0 here:
#0 0x102d1499c in wrap_pthread_create+0x5c (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x4499c)
#1 0x1002a0380 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:10986
#2 0x10025afc2 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:9086
#3 0x10023b0f4 in gmic& gmic::_run(gmic_library::gmic_list const&, unsigned int&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, gmic_library::gmic_list&, unsigned int const*, bool*, char const*, gmic_library::gmic_image const*) gmic.cpp:14431
#4 0x10020c0b9 in gmic& gmic::_run(gmic_library::gmic_list const&, gmic_library::gmic_list&, gmic_library::gmic_list&, float*, bool*) gmic.cpp:5406
#5 0x101622273 in gmic& gmic::run(char const*, gmic_library::gmic_list&, gmic_library::gmic_list&, float*, bool*) gmic.cpp:5370
#6 0x100007af3 in main gmic_cli.cpp:231
#7 0x101a4552d in start+0x1cd (dyld:x86_64+0x552d)

SUMMARY: AddressSanitizer: heap-use-after-free gmic.cpp:2393 in gmic::current_is_abort()
Shadow bytes around the buggy address:
0x1c3c00024dd0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x1c3c00024de0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x1c3c00024df0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x1c3c00024e00: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x1c3c00024e10: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x1c3c00024e20: fd fd fd fd fd fd fd fd fd fd fd fd fd[fd]fd fd
0x1c3c00024e30: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x1c3c00024e40: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x1c3c00024e50: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x1c3c00024e60: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x1c3c00024e70: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==12306==ABORTING
(lldb) AddressSanitizer report breakpoint hit. Use ‘thread info -s’ to get extended information about the report.
Process 12306 stopped

  • thread #1, queue = ‘com.apple.main-thread’, stop reason = Use of deallocated memory
    frame #0: 0x0000000102d25fa0 libclang_rt.asan_osx_dynamic.dylib__asan::AsanDie() libclang_rt.asan_osx_dynamic.dylib__asan::AsanDie:
    → 0x102d25fa0 <+0>: pushq %rbp
    0x102d25fa1 <+1>: movq %rsp, %rbp
    0x102d25fa4 <+4>: pushq %rbx
    0x102d25fa5 <+5>: pushq %rax
    Target 0: (gmic) stopped.
    (lldb)
1 Like

@David_Tschumperle

The compilation of GMIC CLI and GMIC GIMP QT is without problem with an up-to-date version of MSYS2 64 bit.
Source : gmic_3.2.0_pre230111.tar.gz

The quick tests of the 2 programs are good.

I saw 1 error on CLI and Gimp:

1 Like

Thanks! It has been fixed.

Thanks @KaRo , that helps!
I’ve commited :

Could you tell me if that works for you ?

Ok, now!

1 Like