GMCI CLI is not applying filters, but the QT Gui does...

I downloaded the QT GUI and the CLI. Both windows 64 bit. the filter I am trying to run is under Testing > Ian Fergusson > Moire Removal.

I launch the QT client, it updates filters, I load an image, and the preview shows the results. Great

I make a batch file and put the following in it:
gmic.exe -input test.png -iain_moire_removal_NP 4,5,1 -output test2.png

But when I run that, and then check test2.png, it’s the exact same as the original image

Why would the preview in the QT client work, but the CLI client not do anything?

Maybe because your .png file is encoded with 16bits ?
In that case, the value range of the image is [0,65535], which is different from what the G’MIC-Qt plug-in get (range [0,255]).
Maybe try :

gmic.exe div 257 -input test.png -iain_moire_removal_NP 4,5,1 mul 257 -output test2.png

Made no difference

Here’s one thing I found odd … I tried the exact same setup on another PC, and it seems to work there. Why would it work on one computer but not another?

That is very strange indeed. Does the G’MIC interpreter seems to run correctly until the end of the pipeline ? Don’t you have error messages ?

Yes, the output is as expected and matches on both machines. I am running two steps in my pipeline, they are:

-iain_moire_removal_NP 4,5,1
-afre_sharpenfft 5,2

When I run the CLI, I get this output

[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Input file ‘test.png’ at position 0 (1 image 1260x1714x1x3).
[afre]^_^) sharpenfft: Sharpen image [0] with Fourier transform using strength=5 and size=2.
[gmic]-1./ Output image [0] as png file ‘./fixed/test.png’ (1 image 1260x1714x1x3).
[gmic]-1./ End G’MIC interpreter.

It doesn’t specifically say it is running the moire removal, however the second line in that output does hang for about 15-20 seconds before moving on to the sharpen filter, so it is doing something.

I don’t think it’s anything specific to this PC since in the QT UI, the filter works fine.

Another thing I noticed: When I launch the QT client, and load the image, and pick the filter, it works correctly in the preview. When click OK, it applies the filter and I get the little pop up window showing the image and a “Close” and “Save As” button. When I click Save As, I get a Save dialog box, give it a filename, click save … and it doesn’t save. The file isn’t created

So i just checked on another laptop. I downloaded a fresh copy of GMIC, and same thing: Running the CLI produces an image with no filter applied. Running the QT interface properly shows the preview, but when you Click OK, and get the pop up with the resulting image, and click Save As, NO FILE IS SAVED. Is this a bug in the program?

Edit: I downloaded the 2.9.3 version of the QT program, and in that version the file DOES save, and it saves correctly (with the filter applied). So the current version of the Qt interface has a Save bug, apparently.

I tried the 2.9.3 CLI however and it did the same thing, it outputs the file with NO filter applied. I also tried 2.8.4, same thing, the CLI runs the filter, saves a file, the file size is different so it seems to be doing something, but the file itself is identical to the input

So to summarize

In the latest QT client, both stable and dev release, the Save As button doesn’t work
In every version of the CLI, the outputted file has no filters actually applied to it

But it should specifically say. There is something mysterious going on there. This suggests Iain’s filter isn’t running at all, though you seemingly included it in the pipeline.
Please:

  1. provide the complete pipeline, from gmic to carriage return, and not abridged.
  2. Consider reading Cheat #4 and if it not too alien to you, try putting -verbose 3 as the first pipeline command; it would be useful to find, in a more verbose reporting, what mechanism is causing the (possible) removal of Iain’s command.
  3. Further consider reading the Debuggery section and locating how G’MIC is itemizing the command line. I suspect that such itemization is not what we would expect it to be.

Thank you in advance for that!

If you are terminally bored, here are my tests. I cannot see any issues running these from the command line. Here are the gory details. First — don’t let the following massive commands frighten you. Their aim is to put the investigation of -iain_moire_removal_NP and afre_sharpenfft on a precise, numerical footing so that one could diagnose in a concrete way if these commands are doing their jobs or not (and — if the latter — whether they need to be fixed).

The numerical basis of choice is Variance, a measure of how image values vary from a mean. For an absolute solid gray image, the variance is zero because every pixel equals the image mean. In more typical circumstances, variance is some positive number, one that gets large quickly for modest variations of specific pixels from the general mean. The gist of the test is to introduce a moire-like pattern to an initially variance zero image, then see how the filters perform.

gmic v 0 m "mry: -input 2,1,1,5,u([{w#-1},{h#-1},1,1,1]) rbf. {w#-2},{h#-2} n. 0,700 cos. sqr. n. -5,5 add cut. 0,255" srand 1234 i 512,512,1,3,[127,127,127] eval "stats(#0)[3]" v + e "Variance @ Init: "'${}' v - mry. eval "stats(#0)[3]" v + e "Variance after Moire: "'${}' v - o. ~/mtest_00.png -iain_moire_removal_NP 4,5,1 -eval "stats(#0)[3]" v + e "Variance after Iain's MoireRemoval: "'${}' v - o. ~/mtest_01.png -afre_sharpenfft 5,2 eval "stats(#0)[3]" v + e "Variance after AfreSharp: "'${}' v - o. ~/mtest_02.png

You need not get lost in the detail with this. It:

  1. Defines a pseudo moire pattern generator, mry
  2. Introduces a flat gray image and prints its variance. Unsurprisingly it is zero.
  3. Injects a pseudo Moire-ish noise pattern into the image with mry and prints its variance. It is a large-ish positive number
  4. Runs iain_moire_removal_NP 4,5,1 on the image and prints its variance. Here, variance reduces considerably.
  5. Runs -afre_sharpenfft 5,2 on the image and prints its variance. No surprise: the variance goes up a bit, but not nearly as much as with the original noise injection.
  6. Along the way, it dumps intermediary images: after noise injection, mtest_00.png, after moire reduction, mtest_01.png and after afre-sharpening: mtest_02.png.

And so, in considerably less time than it takes to describe it, here is the test run:

[gmic]-1./ Variance @ Init: 0
[gmic]-1./ Variance after Moire: 12.501370084773514
[gmic]-1./ Variance after Iain's MoireRemoval: 1.4889610189454463
[gmic]-1./ Variance after AfreSharp: 4.2067888788877168

In light of this concrete variance measure, I can observe that — run from the CLI — Iain’s moire noise remover does remove (most) moire noise and have a quantitative sense of how well it is doing. I’m pretty confident that Iain;s script works, and Afre’s fft-based sharpener bumps the variance, also expected: it is an image sharpener. Sharpeners increase image variance. Here are the test images.

mtest_00
mtest_00.png
mtest_01
mtest_01.png
mtest_02
mtest_02.png

However, there is a pernicious class of images where these filters apparently do not do anything at all. I have modified the test script such that it produces a test image consisting of alternating black and white stripes. The image average is the same as the previous one, but every pixel now varies from the image mean by the biggest extreme possible, so the variance is astronomical.

 gmic v 0 m "mry: -input 2,1,1,5,u([{w#-1},{h#-1},1,1,1]) rbf. {w#-2},{h#-2} n. 0,700 cos. sqr. n. -5,5 add cut. 0,255" srand 1234 i 512,512,1,3 f. 0,255 eval "stats(#0)[3]" v + e "Variance @ Init: "'${}' v - mry. eval "stats(#0)[3]" v + e "Variance after Moire: "'${}' v - o. ~/mtest_03.png -iain_moire_removal_NP 4,5,1 -eval "stats(#0)[3]" v + e "Variance after Iain's MoireRemoval: "'${}' v - o. ~/mtest_04.png -afre_sharpenfft 5,2 eval "stats(#0)[3]" v + e "Variance after AfreSharp: "'${}' v - o. ~/mtest_05.png

Here is the test run:

[gmic]-1./ Variance @ Init: 16256.270670917093
[gmic]-1./ Variance after Moire: 15856.637440184575
[gmic]-1./ Variance after Iain's MoireRemoval: 15852.934917493372
[gmic]-1./ Variance after AfreSharp: 16056.331219528456

This tells us that there are images — exhibiting a great deal of variance from the outset — where Iain’s filter has negligible effect. Now, where do your test images fall in this spectrum? I don’t know. You haven’t provided test images. Ah me. The lack of apparent non-performance may lie in the nature of your test images. In this run, there is no apparent effect.
mtest_03
mtest_03.png
mtest_04
mtest_04.png
mtest_05
mtest_05.png

So there is a class of images where Iain’s filter cannot get much purchase. How much are your images like those? In the main, from my test bed, the filters seem to be working as expected. However, G’MIC’s operating log, presented in your early post, is strange. The direction of my inqueries would be toward that.

Bonjour,

As @sbal confirm that GMIC-QT does not export in PNG format but can export in other formats.

I just did some tests on the lines of commands offered on this thread.
I join the test images (test_images.7z) from Garry R. Osgood’s message :o)
There is also a screenshot of the 2 commands used by @sbal
Here’s what seems to work (the command lines of @David_Tschumperle and @grosgood are modified) :

gmic.exe input grosgood_16bits.png div 257 iain_moire_removal_NP 4,5,1 mul 257


gmic.exe input grosgood_0.png iain_moire_removal_NP 4,5,1 afre_sharpenfft 5,2


gmic.exe input grosgood_1.png iain_moire_removal_NP 4,5,1 afre_sharpenfft 5,2


gmic v 0 m "mry: -input 2,1,1,5,u([{w#-1},{h#-1},1,1,1]) rbf. {w#-2},{h#-2} n. 0,700 cos. sqr. n. -5,5 add cut. 0,255" srand 1234 i 512,512,1,3,[127,127,127] eval "stats(#0)[3]" v + e "Variance @ Init: "'${}' v - mry. eval "stats(#0)[3]" v + e "Variance after Moire: "'${}' v - o. mtest_00.png -iain_moire_removal_NP 4,5,1 -eval "stats(#0)[3]" v + e "Variance after Iain's MoireRemoval: "'${}' v - o. mtest_01.png -afre_sharpenfft 5,2 eval "stats(#0)[3]" v + e "Variance after AfreSharp: "'${}' v - o. mtest_02.png


gmic v 0 m "mry: -input 2,1,1,5,u([{w#-1},{h#-1},1,1,1]) rbf. {w#-2},{h#-2} n. 0,700 cos. sqr. n. -5,5 add cut. 0,255" srand 1234 i 512,512,1,3 f. 0,255 eval "stats(#0)[3]" v + e "Variance @ Init: "'${}' v - mry. eval "stats(#0)[3]" v + e "Variance after Moire: "'${}' v - o. mtest_03.png -iain_moire_removal_NP 4,5,1 -eval "stats(#0)[3]" v + e "Variance after Iain's MoireRemoval: "'${}' v - o. mtest_04.png -afre_sharpenfft 5,2 eval "stats(#0)[3]" v + e "Variance after AfreSharp: "'${}' v - o. mtest_05.png

test_images.7z (1.4 MB)

That’s not what I said. The current version of GMIC-QT does not save files at all. Period. The Save As button prompts for a filename, and then does literally nothing. I had to download an older verison of GMIC-QT to get svaing to work. There is a bug in the current version, someone should fix it.

As for Bonjour’s post, it doesn’t make sense, because in GMIC QT, the preview of the filter DOES WORK. The Filter IS APPLIED in the QT client (of course I can’t save it because the Save As button is broke). As far as I can tell the CLI and QT client use the same filter data files. Since the filter WORKS in QT, but not in CLI, it can’t be an issue with the image. It’s an issue with the CLI.

I added the verbose thing and it just spewed a bunch of garbage on the scren, that seem to indicate the filter is doing something. But when I check the saved file, it’s identical to the input. Load the file into the QT client, and the filter is applied in the preview (but you can’t save it)

Could you share that ‘garbage’? Thank you.

@David_Tschumperle
@sbal

Bonjour,

The latest version of ‘GMIC-3.0.0_pre-QT-WIN64’ save only in JPEG format :
https://gmic.eu/files/prerelease/gmic_qt_win64.zip

An error report is reported :

@sbal

Voici un exemple de ligne de commande qui fonctionne avec la dernière version de G’MIC CLI
Here is an example of a command line that works with the latest version of G’Mic CLI
https://gmic.eu/files/prerelease/gmic_cli_win64.zip

gmic.exe input my_image.png n 0,255 to_rgb iain_moire_removal_NP 4,5,1 afre_sharpenfft 5,2 o test.png rm[-1] input test.png