Release of G'MIC 3.2

should fix thi.

1 Like

While trying to optimize command colormap (in “full palette extraction” mode), I’ve found a bug with the math parser command find() when an image index is passed as the first argument.

This is fixed, and the optimized version of colormap now works really faster (particularly for large images with lot of colors).

But there is a drawback : as the new version of colormap uses the version of find() that has just been fixed, it won’t work anymore with the older binary versions of gmic (only for version 3.2.0_pre of course). I need to rebuild binary packages with the fix included ASAP, but I can’t go to the lab this week, because it’s closed for x-mas holidays.

So maybe, avoid update your filters until next monday, otherwise any filter that requires colormap 0 won’t work as expected.

I’ll keep a backup in case.

Another possible optimisation: split_details using convolve in “a trous” mode?

Did something change to make that an efficient solution?

Well, I think the “a trous” convolve mode didn’t exist when split_details was first written. I could easily be wrong about that though.

In any case, I’ve written my own version using convolve (but only for 2D) and it’s significantly faster on my machine. The output was identical as well.

Edit: I should clarify - this is specifically for wavelets mode, not laplacian pyramid.

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!