Release of G'MIC 3.0

Yes, that’s my point exactly - not surprising, because it’s mathematically not separable when the window sizes are arbitrary. With 2D summed area the problem goes away - so I’ll work on that approach later. It’s easy, but boundary handling is the main issue there (also an issue for separated, but my 1D filter handles it). An approximate separated method is still useful, but I’d like a correct reference version too!

Edit: thanks for the 2D version to use as a starting point. If the reference/guidance image (the gradient part) is replaced by +f 10 to simulate a normal box filter, the edges problem will be visible (it’s also apparent mathematically).

Edit2: after some scribbled drawings, it’s definitely possible to handle boundaries in 2D summed area (without a horrible extend-the-image hack). Mostly just finding edge sums and multiplying by distance and sign(x*y). It’s tricky but hopefully reducable. Not sure if I’ll complete it before next weekend though.

I think I’ve got a working reference which properly handles boundaries:

gcd_boxfilter_local : check ${"is_image_arg $1"}
  pass$1 0 max. 1
  repeat $!-1 l[$>,-1]
    cumulate.. xy
    f.. "
    begin(
      const boundary=1;
      const interpolation=1;
      const W=w-1; const H=h-1;
      T(X,Y)=Y>1?i(X,Y-1):Y*i(X,0);
      B(X,Y)=Y<H?i(X,Y):(1+Y-H)*i(X,H)-(Y-H)*i(X,H-1);
      C(X,Y)=X<W?B(X,Y):(1+X-W)*B(W,Y)-(X-W)*B(W-1,Y);
      D(X,Y)=X>1?T(X-1,Y):X*T(0,Y);
      E(X,Y)=X<W?T(X,Y):(1+X-W)*T(W,Y)-(X-W)*T(W-1,Y);
      F(X,Y)=X>1?B(X-1,Y):X*B(0,Y);
    );
    R=i#1; S=R*R; K=(R-1)/2;
    x0 = x - K;
    y0 = y - K;
    x1 = x + K;
    y1 = y + K;
    (C(x1,y1) + D(x0,y0) - E(x1,y0) - F(x0,y1))/S"
  endl done rm.

It’s already quite fast. Boundary check:
boundarycheck
Accuracy check:
accuracycheck

Edit: some extra info about how it works.

The starting point is to define two functions T(x,y) and B(x,y) which can extrapolate the summed area past the top and bottom boundaries respectively (but not left and right edges). Then we use knowledge of which boundaries each of the four areas can pass, to define and extrapolate each of those (to minimise number of comparisons per function). Those are C = bottom right, D = top left, E = top right, F = bottom left.

2 Likes

@David_Tschumperle any plans to add 64bit image support?

Each image pixel takes then 32bits/channel (except if double-precision buffers have been enabled during the compilation of the software, in which case 64bits/channel can be the default).


@David_Tschumperle The PDF version is 2.9.4, two versions behind. Another thing I noticed was that it is quite large. Could you make a low-fi version?

Request for making a knots paterns

Is it possible to create GMIC patterns similar to celtic knots ?

@hover

In theory, it is possible, but time-consuming. I think you are much better off learning gmic coding.

There is on my mac with gmic from git built a minor problem with “display”
Displaying some rel. large images and selecting e.g. the second, selecting a subregion, clicking left to leave it, and clicking left again to return to display of all images does not return to initial display, only <esc> helps, closing the window completely.

Aah, I just found that zooming out by mouse wheel and than clicking left helps. Seemingly there is a remaining zoom.

I think it is a problem of calculating/rounding coordinates!
Example: (it is a 24 MB file! with two images (1996,2698,1,3)) http://karo03.bplaced.net/Test/gmic_0000.cimgz

By the way, my screen #0:
dimensions: 2560x1416 pixels (677x375 millimeters)

Hello Karsten. Just tested here with your sample image, and it works for me :frowning:
My screen is 1920 x 1080.
I don’t know what I can do if I can’t reproduce the bug unfortunately. I’ll check how the test of the single click is done, maybe I can find something wrong there.

:thinking: I may have reported it before. It has been a while, so it may have been a different issue; but this sounds vaguely familiar.

Thank you for the quick response, David.

Left clicking shows instead of going back to initial display shortly a very small rectangle in the upper left of the cross hair!

I thought the problem was happening when left-clicking from the “image list” display modules, not the “image” display module ? In the “image list” module, there is no cross hair.
Could you tell me exactly where it occurs. It’s not the same code to inspect.

It is in the “image” module, with the cross hair cursor. The small white box, perhaps 1 px, appears in the cross upper left . from there I cannot return to “image list” module.

Clicking left does change slightly the display seemingly a zoom recalculation and sometimes a very small piece is zoomed and displayed as subregion!

With
gmic gmic_0000.cimgz luminance. gt. 40 dilate_oct. 3 r 50%,50%,50%
the problem does not occur! As well as with “r 200%,200%,200%” no problem!

Here are snapshots with my camera from the situation

unpressed

pressed

You see the different thickness of some lines?

Could you try to update with $ gmic up ?
I’ve tried something, but as everything works for me, I’m not sure it really fixes your issue.

No change, or even worse. zooming does not help anymore. By chance sometimes it returned to list mode.
Still the change in display by pressing! A very special “refreshing”!

Ha, closing the image window (via window decoration) let appear the image list window. I think earlier the display mode terminated completely by closing the window.

By the way

“fitscreen .” returns 891,1204 for my display.
Perhaps a problem with odd window sizes?

AND

gmic gmic_0000.cimgz r {w+1},100%,100%,100%

let’s disappear the problem!

Ok, I have found something:
the problem mentioned appears only on my external monitor, optimized for the external monitor. If I optimize the external monitor for the internal monitor (from my laptop) the problem does not appear.

Hence, although I have the latest OS and the latest XQuartz version, there is still the problem of X11 server with second monitors on Mac.

Thank you for your responses, David

One other thing:

On MacPorts the gmic cli is build with GraphicsMagic. For my local git build I don’t use this. Unluckily with GraphicsMagic linked I cannot input heic image files. I get an error of missing delegate. Without GraphicsMagic gmic cli opens this image format seemingly using convert from ImageMagick. Here is an example heic file: follic_test.heic.zip (52.6 KB) . It is zipped since heic is still not accepted by pixls.us!

Maybe it is possible to add another trial using the external program if an import error was thrown?

@KaRo, CImg just got a native support for reading .heic files, and I’ve just enabled this in G’MIC (not by default anyway).

To compile with the .heic support :

$ make EXTRA_CFLAGS="-Dcimg_use_heif" EXTRA_LIBS="-lheif" cli

(it require sthat libheif is installed on your system).

Then:

$ ./gmic follic_test.heic
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'follic_test.heic' at position 0 (1 image 256x256x1x3).
[gmic]-1./ Display image [0] = 'follic_test.heic'.
[0] = 'follic_test.heic':
  size = (256,256,1,3) [768 Kio of floats].
  data = (173,174,165,156,152,152,157,164,167,173,177,180,(...),99,100,98,104,102,102,102,107,113,115,110,101).
  min = 21, max = 227, mean = 97.8767, std = 46.0822, coords_min = (178,172,0,1), coords_max = (5,33,0,1).
~~~
1 Like

I’ve made a modification today to the display2d function, that may improve things. I’ve encountered a similar behavior today with one test image, and the change fixed the issue
(single click was not returning to the image list viewer).