Thanks for the info! What you write makes sense, I’ll discard the second script I wrote.
Now I’m trying to understand yours. I think I got it but I still have some questions.
First of all, I wasn’t able to find any passage in the reference docs where you explain the meaning of the dot after a command. I understand it means [-1]. Is it there?
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]).
means
--local -unroll 1,100%,1,1,1 -append[0,-1] x -resize 100%,{min(h,10000)}
-solve. [-2] -keep. a={[0]} b={[1]} -rm -endlocal # Get vector [a,b]
--mul[0] $a -add. $b # Compute [2] = aX+b (should match [1]).
--local
takes I guess all the images (that should be only two, [0,1]) and puts them in a separate “list”, but in the docs -local appears with single dash, here double. What is its meaning in this context? especially since at the end you do -rm so the local list gets emptied, nothing would have to be added back to the outer one.
1,100%,1,1,1
creates a new image with same y size as the previous one, filled with 1s for the b.
-append[0,-1] x
from the first and the just generated image that are 1 by (number of pixels) I get only one. I guess the first one (that means [0]) gets modified in-place.
-resize 100%,{min(h,10000)}
here you want at most 10k pixels along y axis for speed reason, and it applies to all the three images. In my case the images I’m working on are about 32 Mpx… good idea. Why default nearest interpolation and not average?
-solve. [-2]
I guess this means [-1] is the only image which got the result of the “append” command, otherwise [-2] would not have been a simple 1D vector. Result is an image 2x1 using least squares because over-determined.
a={[0]} b={[1]}
I know that {…} means that you request a feature implicitly of the image [-1] (section substitution rules) but I cannot find the explanation of the use of [0] or [1] as feature (I guess it gives the first and second values of the content of the image)