I’m trying to fix the reverse spiral transform but I don’t know what to do at all. I know that Reptorian’s already sorted out the spiral transform and I can condense it into this:
+spiralbw
f[0] "I(i#1%w,floor(i#1/w))"
However, I really don’t know how this works. As far as I know, this reads like how I imagine the reverse spiral transform to be. Since the index values for where the pixels after the spiral transform should be after the reverse spiral transform are found in the values of the pixels in the spiral, it should be possible to map them back. I don’t know how to do this at all since everything I’ve tried just gives me the spiral transform. How can I swap the pixels in the spiral transform with other pixels so that I can get the original back without having to construct another map or through using dynamic arrays?
More generally, if there is an image specifying the order in which pixels go, how do I transform back to the original order? I can actually get part of the way there in the spiral case if I do this:
rm
50,50,1,1,">begin(index=-1);index+=1;index"
+spiralbw
f[0] "I(i#1%w,floor(i#1/w))"
f[0] ">begin(index=-1);index+=1;
valatspiral=i[#1,index,2];
I[valatspiral]=I[#1,index];"
n 0,255
Edit: I’ve found a way to use the warp
command to sort this whole mess out. G’MIC never fails to surprise, and this command is certainly extremely helpful! This script will return the original image (which I’ve assumed is already in the pipeline) through a spiral transform and a reverse spiral transform.
+spiralbw
f[0] "I(i#1%w,floor(i#1/w))"
# Here comes the magic!
100%,100%,1,2
f[2] "[i#1%w,floor(i#1/w)]"
warp[0] [2],2
k[0]