Thanks for the answer, I think I got all of it. I also tried myself to change resize algorithm and there is little change in the final calculated variables.
However your algorithm doesn’t seem to produce correct results, while mine does.
I could use mine and be happy but I would like to understand what is going wrong.
I uploaded the source images:
red channel
IR channel
and you can try yourself if you want, just copy and paste:
mine:
-i Dia_1_red.tif -i Dia_1_IR.tif
--mul[-2] [-1] xy={-1,ia} -rm. x={-2,ia} y={-1,ia}
--sqr.. xx={-1,ia} -rm. x2={{-2,ia}*{-2,ia}}
_a={($xy-($x*$y))/($xx-$x2)} _b={$y-$_a*$x}
--*[0] $_a -+. $_b --display_histogram
yours:
-i Dia_1_red.tif -i Dia_1_IR.tif
--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
--*[0] $_a -+. $_b --display_histogram
I paste the summary of the input images (I cut some lines):
[0] = 'Dia_1_red.tif':
min = 3619, max = 42386, mean = 14729.3, std = 5100.47, coords_min = (1838,1763,0,0), coords_max = (3342,1866,0,0).
[1] = 'Dia_1_IR.tif':
min = 8565, max = 58354, mean = 48172.9, std = 3108.76, coords_min = (2911,984,0,0), coords_max = (3348,1968,0,0).
My result:
[gmic]-2./regression/ Set global variable _a='0.5623662604504396'.
[gmic]-2./regression/ Set global variable _b='39889.67002724859'.
[2] = 'Dia_1_red~.tif':
min = 41924.9, max = 63726.1, mean = 48172.9, std = 2868.33, coords_min = (1838,1763,0,0), coords_max = (3342,1866,0,0).
And it makes sense, the IR histogram is compressed and shifted to the right.
Your algorithm:
[gmic]-1./*local/ Set local variable a='2.981390953063965'.
[gmic]-1./*local/ Set local variable b='0.0001807634544093162'.
[2] = 'Dia_1_red~.tif':
min = 10789.7, max = 126369, mean = 43913.7, std = 15206.5, coords_min = (1838,1763,0,0), coords_max = (3342,1866,0,0).
The average is not correct and the std is larger, because somehow instead of compressing and shifting, your result expands and shifts only a little.
I can see with
--sub[-1] [-2] --display_histogram
that the the resulting difference is quite small:
[3] = 'Dia_1_red~.tif':
min = -4566.15, max = 35204.4, mean = 0.00165331, std = 1198.79, coords_min = (3362,2617,0,0), coords_max = (2911,984,0,0).
With yours:
[3] = 'Dia_1_red~.tif':
min = -29142, max = 70950.3, mean = -4259.21, std = 12396.3, coords_min = (4018,709,0,0), coords_max = (3338,1870,0,0).
Maybe this depends on the algorithms themselves and not on the implementation?
What do you think?