David,
here is a custom command (from you)
gmic help linear_reg,0
[gmic] Command ‘linear_reg’ has no description (did you mean ‘linear_x3’ ?). Try ‘gmic -h’ for global help.
#@cli linear_reg :
#@cli : The idea is to build the system [X,1].[a;b] = [Y], where X and Y are the column vectors
#@cli : composed of the values of images X and Y you want to match, and [a;b] the vector of the
#@cli : coefficients you are looking for.
#@cli : This small piece of code compute a and b for two input images [0] = X and [1] = Y such
#@cli : that ||Y - (a.X + b)||^2 is minimum:
linear_reg :
–l
-y 1,100%,1,1,1
-a[0,-1] x
-r 100%,{min(h,10000)}
-solve. [-2]
-k. a={[0]} b={[1]} -rm
-endl # Get vector [a,b]
–*[0] $a -+. $b # Compute [2] = aX+b (should match [1]).
I have put it into a file, say exa.gmic
And …
gmic m exa.gmic osteo follic r. … linear_reg
[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Import commands from file ‘exa.gmic’ (1 new, total: 4203).
[gmic]-0./ Load osteoblast nucleus example image
[gmic]-1./follic/ Load thyroid follicle nuclei example image from local storage
[gmic]-2./ Resize image [1] to 128x128x1x1, with nearest-neighbor interpolation, dirichlet boundary conditions and alignment (0,0,0,0).
[gmic]-3./ Display images [0,1,2] = ‘follic, follic, follic_c1’.
[0] = ‘follic’:
size = (128,128,1,1) [64 Kio of floats].
data = (213,219,217,214,213,213,213,210,214,211,217,212,(…),208,212,217,211,213,211,216,212,208,213,217,216).
min = 70, max = 249, mean = 197.159, std = 28.0122, coords_min = (64,85,0,0), coords_max = (112,97,0,0).
[1] = ‘follic’:
size = (128,128,1,1) [64 Kio of floats].
data = (193,176,167,176,182,192,201,209,203,193,175,161,(…),159,165,162,128,117,112,107,105,109,109,118,119).
min = 27, max = 224, mean = 106.09, std = 49.8296, coords_min = (81,28,0,0), coords_max = (4,14,0,0).
[2] = ‘follic_c1’:
size = (128,128,1,1) [64 Kio of floats].
data = (1,1,1,1,1,1,1,1,1,1,1,1,(…),1,1,1,1,1,1,1,1,1,1,1,1).
min = 1, max = 1, mean = 1, std = 0, coords_min = (0,0,0,0), coords_max = (0,0,0,0).
[gmic]-3./ End G’MIC interpreter.
gmic m exa.gmic h linear_reg,0
[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Import commands from file ‘exa.gmic’ (1 new, total: 4203).
[gmic] Command ‘linear_reg’ has no description (did you mean ‘linear_x3’ ?). Try ‘gmic -h’ for global help.
You see, no help. If I put it into $_path_user help text appears!
gmic h linear_reg
gmic: GREYC’s Magic for Image Computing: command-line interface
(https://gmic.eu)
Version 2.9.0 (pre-release #200225)
Copyright (c) 2008-2020, David Tschumperle / GREYC / CNRS.
(https://www.greyc.fr)
linear_reg:
The idea is to build the system [X,1].[a;b] = [Y], where X and Y are the column vectors
composed of the values of images X and Y you want to match, and [a;b] the vector of the
coefficients you are looking for.
This small piece of code compute a and b for two input images [0] = X and [1] = Y such
that ||Y - (a.X + b)||^2 is minimum: