G'MIC exercises

I’m not sure what you mean. “null:” is part of the command that starts with “%IM%convert”. Forget the IM part. Each ^ shows where I had a line-break, but those get stripped out by some software. I’ll try again:

convert xc: -define morphology:showkernel=1 ^
  -morphology Convolve:0 Gaussian:0x2 null: 2>&1 | findstr Kernel

That’s a single command line.

“findstr” is a Windows command, like grep on unix. We don’t care about the image, just the text output from “showkernel”.

I misread the G’MIC output: the command with autocrop I showed doesn’t crop at all. If I start with 300x300 pixels, it crops to 56x56, and most of the values are very small (less than 1e-16). Oops, sorry.

To use autocrop, you could first adjust so values that are near zero become exactly zero. I don’t know the best way to do this in G’MIC. But one method that seems to work is:

%GMIC% 300,300,1,1 gaussian 2,2 normalize_sum ^
  +select_color 1e-8,0 oneminus. mul autocrop 0 print output x.tiff

Explanation: make a 300x300 image, gaussian with SD=2, normalized. Make a copy that has values near zero to white, and make the others black. Flip black and white. Multiply this by the gaussian image, so now we have a gaussian that has all values near zero, actually zero. Autocrop to trim off columns and rows with just zeros. Print info, and save to x.tiff.

I think that’s what it does, but I’m probably wrong. Adjust the limit (1e-8) to whatever you want.

EDIT: IM v7 needs “-define morphology:showkernel=1”, with that “morphology:” prefix. V6 doesn’t need that prefix, and works fine with or without it.