I wonder if it would be worthwhile to resize the images prior to computation and then save that data for alignment of the original images to save processing intensity, and otherwise reduce the complexity of the similarity and alignment processes.
I started by using rescale 50%
to test the original pipeline but ended up not using it.
Also I’m not sure if ssim doesn’t do that internally already.
Hi, i have once again a nooby question : is it possible to draw a circle using a single (thick)spline
?
All i could do was guitar picks and then ended up with this using 6 thicksplines:
OK ok, no circle there but i got lost on the way
Yes it is possible.
I’ve just added a new command thickcircle
in the stdlib, that uses thickspline
:
Here is the code of the thickcircle
command:
#@cli thickcircle : x[%],y[%],R[%],_thickness>=0,_opacity,_color1,...
#@cli : Draw specified colored thick outlined circle on selected images.
#@cli : Default values: 'thickness=3', 'opacity=1' and 'color1=0'.
#@cli : $ 400,400 repeat 15 { R:=lerp(10,190,$>/($>+$<)) thickcircle 200,200,$R,2,1,$R } n 0,255 map 7
thickcircle : check "${4=3}>=0" skip ${5=1},${6=0}
e[0--3] "Draw outlined thick circle at ($1,$2) with radius $3 on image$?, with thickness $4, opacity $5 "\
"and color (${6--1})."
if !$4 return fi
foreach {
4,1,1,4,"begin(
const xc = ispercentage($1)?w*$1:$1;
const yc = ispercentage($2)?h*$2:$2;
const R = ispercentage($3)?hypot(w#0,h#0)*$3:$3;
const R1667 = 1.667*R;
);
U = cexp([0,lerp(0,360,x/w)°]); [ xc + R*U[0], yc + R*U[1], -R1667*U[1], R1667*U[0] ]"
thickspline.. {[I[0],I[1]]},${4--1}
thickspline.. {[I[1],I[2]]},${4--1}
thickspline.. {[I[2],I[3]]},${4--1}
thickspline.. {[I[3],I[0]]},${4--1}
k[0]
}
And here is an example of use:
foo :
400,400
repeat 15 {
R:=lerp(10,190,$>/($>+$<))
thickcircle 200,200,$R,2,1,$R
}
n 0,255 map 7
So, with a simple $ gmic update
, you should be able to access this command.
Let me know.
Ah, you read my mind, thanks.
Any hope for thickpolygon
? Might be a tough one. Or maybe there’s
something else that could use some thickness.
But i see you are using 4 splines. I thought about trying with 1 only, but i guess it’s not possible.
I don’t think this will be tough. It’s just successive calls to command thickline
.
I may give a try.
EDIT: Ha no, using just thickline
won’t work for getting thick vertices that join nicely together.
Hi, the command still doesn’t appear after update (gmic 3.5.4).
My bad, it just wasn’t in autocompletion
$ gmic update
$ gmic h thickpolygon
thickpolygon:
N>=1,x1[%],y1[%],...,xN[%],yN[%],_thickness>=0,_opacity,_color1,... |
[coords],_thickness>=0,_opacity,_color1,...
Draw specified colored thick outlined N-vertices polygon on selected images.
If 'thickness<0', the command draws an open polygon rather than a closed polygon.
Default values: 'thickness=3', 'opacity=1', and 'color1=0'.
Example:
[#1] image.jpg thickpolygon 4,20%,20%,80%,30%,80%,70%,20%,80%,5,1,0,255,0
[#2] image.jpg 2,16,1,1,'u(x?h#0:w#0)' thickpolygon[-2] [-1],5,1,255,0,255 remove[-1]
Example of use:
foo :
shape_cupid 512 edgels -1 k[2] channels 0,1
512,512,1,3,"lerp([70,30,0],[0,0,255],y/h)"
repeat 5 {
f:=$>/($>+$<)
+r[0] 1,{lerp(10,1,$f)}%,1,2
f. "256 + lerp(0.2,1,$f)*(I - 256)" permute. cyzx
thickpolygon[1] .,{lerp(1,10,$f)},0.5,${-RGB} rm.
}
k.
Nice, thanks! I seriously thought i’d never see these thick
drawing commands.
Now i guess it means only thickellipse
is missing I thought you’d start there before
thickcircle
though. Isn’t circle
using ellipse
under the hood?
No, it uses thickspline
.
I mean, the standard circle
?
In that case, yes:
$ gmic e \$\$circle
[gmic]./ Start G'MIC interpreter (v.3.5.4).
skip ${4=1},${5=0},${6=0} if ${"is_pattern "$5""} e[0--3] "Draw outlined circle at ($1,$2) with radius $3 on image$?, with opacity $4, pattern $5 and color (${6--1})." else e[0--3] "Draw filled circle at ($1,$2) with radius $3 on image$?, with opacity $4 and color (${5--1})." fi ellipse $1,$2,$3,$3,0,${4--1}
~~~
Haha, i should remove that Rotation section… I’ve seen it before but completely forgot about it. Oups.
Hi there, been playing with strings for fun. Made a very simple command to create random hex patterns for line
, circle
and co. :
Now i want to make one that will generate a pattern and shift it N times. But… How can i convert my shifted string back to a string?
($char2 only there to check if shift works on a string).
Thanks.
char=abracadabra
e $char
char2:=shift(['$char'],0,0)
pat:=shift(['$char'],3,2)
pat2:=v2s('$pat',0,8)
e $char2
e $pat
u ""$pat""
[gmic]./ Start G'MIC interpreter (v.3.5.4).
abracadabra
97,98,114,97,99,97,100,97,98,114,97
98,114,97,97,98,114,97,99,97,100,97
[gmic]./ End G'MIC interpreter.
Bonus:
a unfinished stupidly stupid name generator:
Yeah, very random but not so much.
A pattern is a string like 0xFFCCFFCC
, which is actually a 32bits unsigned integer.
To shift a pattern and get the corresponding string, you can use this (not tested thoroughly):
# $1: input pattern
# $2: signed integer that tells about the shift (<0: left shift: 1: right shift).
shift_pattern :
u 0x${dec2hex\ {"$2<0?($1<<-$2)&~0 | $1>>(32 + $2):($1>>$2) | ($1<<(32-$2))&~0"}}
Thanks! It’s a lot different from what i imagined but i think it works :
gmic run '250,250,1,1 repeat 250 shift_pattern 0xFFA9FF00,{u(-8,8)} pat=${} e $pat line 0,$>,100%,$>,1,$pat,255 n 0,255 done'
Arrrg! my eyes =_=
with
$>
(it probably shifts to the max though since the pattern doesn’t change after a while?)(Not sure what happens towards the bottom too)
It actually stops shifting after a while and then starts again?
0xffa9ff00
0x7fd4ff80
0x3fea7fc0
0x1ff53fe0
0xffa9ff0
0x7fd4ff8
0x3fea7fc
0x1ff53fe
0xffa9ff
0x807fd4ff
0xc03fea7f
0xe01ff53f
0xf00ffa9f
0xf807fd4f
0xfc03fea7
0xfe01ff53
0xff00ffa9
0xff807fd4
0x7fc03fea
0x3fe01ff5
0x9ff00ffa
0x4ff807fd
0xa7fc03fe
0x53fe01ff
0xa9ff00ff
0xd4ff807f
0xea7fc03f
0xf53fe01f
0xfa9ff00f
0xfd4ff807
0xfea7fc03
0xff53fe01
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0xffa9ff00
0x-7fffffff00560000
0x-3fffffff00560000
0x-1fffffff00560100
0x-fffffff00560100
0x-7ffffff00560100
0x-3ffffff00560100
0x-1ffffff00560100
0x-ffffff00560100
0x-7fffff00560100
0x7fc00000ffaa0000
0x3fe00000ffaa0000
0x-600fffff00560000
0x4ff80000ffaa0000
0x-5803ffff00560000
0x53fe0000ffaa0000
0x-5600ffff00560000
0x-2b007fff00560000
0x-15803fff00560100
0x-ac01fff00560100
0x-5600fff00560100
0x-2b007ff00560100
0x-15803ff00560100
0x-ac01ff00560100
0x-5600ff00560100
0x7fd4ff80ffaa0000
0x3fea7fc0ffaa0000
0x1ff53fe0ffa9ff00
0xffa9ff0ffa9ff00
0x7fd4ff8ffa9ff00
0x3fea7fcffa9ff00
0x1ff53feffa9ff00
0xffa9ffffa9ff00
0x7fd4ffffa9ff00
0x3fea7fffa9ff00
0x1ff53fffa9ff00
0xffa9fffa9ff00
0x7fd4fffa9ff00
0x3fea7ffa9ff00
0x1ff53ffa9ff00
0xffa9ffa9ff00
0x7fd4ffa9ff00
0x3feaffe9ff00
0x1ff5ffe9ff00
0xffafff9ff00
0x7fdfff9ff00
0x3fefffdff00
0x1ffffffff00
0xffffffff00
There is a face somewhere in there (or mushroom cloud
). Would be neat to make a filter with an animation embedded in the randomness.
Here’s my bad code version:
pr_rndpat:
#~ pat=0x
pat=
hex=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
repeat 8 { char=${"arg0 v(15),"$hex} pat.=$char }
u ""$pat""
pr_offpat:
char2=$1
pat:=shift(['$char2'],$2,2)
pat2=0x${dec2str\ "$pat"}
u ""$pat2""
gmic run '250,250,1,1 pat1=${-pr_rndpat} repeat 250 pr_offpat $pat1,$> pat=${} line 0,$>,100%,$>,1,$pat,{u(255,255)} done d'`
gmic run '250,250,1,1 pat1=${-pr_rndpat} repeat 250 pr_offpat $pat1,{v(-1,1)} pat=${} line 0,$>,100%,$>,1,$pat,{u(255,255)} done d'
It actually works like i thought it would, so that’s ok for me (you?):
@afre Well, we all tend to see things in such patterns anyway. Remember your grand grandmother’s wallpaper in the living room? I always saw demonic faces in there.
Errr, yes, but i don’t think i can do that.
This looks like cellular automata. I made a script on that to expand on it later, whenever that happens.