G'MIC Challenge: Create image from photographs with a single line

(Edit) Here is a version with which uses SVG Bézier curves to get curved lines.

I join the code for GIMP GMIC 3.1.0_pre (this code is not optimized).

I will wait for the GMIC ‘exec’ command to work properly to continue.

Liste_Points_TSP


## Supprimer les 2 lignes pour obtenir un SVG sur une autre image ##
rm
fx_gmicky 0
####################################################################
Param1Masque1=1.25
Param2Masque1=42
Param1Masque2=0
Param2Masque2=32.5
Echelle=1
CRLF="\\r\\n"
Liste="<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>"$CRLF
Liste.="<svg xmlns=\\"http://www.w3.org/2000/svg\\" version=\\"1.1\\" width=\\"1024\\" height=\\"1024\\">"$CRLF
Liste.="<title>Test GMIC SVG</title>"$CRLF
Liste.="<desc>Points et Splines</desc>"$CRLF
if w>h
resize 1000,{h/w*1000}
else
resize {w/h*1000},1000
fi
+samj_Masques_Noir_Et_Blanc_Preview $Param1Masque1,$Param2Masque1
to_gray.
negate.
dilate. 10
pointcloud. 3
channels. 0,1
WWe={round(w/100*$Echelle)}
if {$WWe%2}==0 resize. $WWe,1 else resize. {$WWe-1},1 fi
add. 12
tsp. 200
+crop. 0,0,1,0
Xo={i0}
Yo={i1}
rm[-1]
+crop. 1,0,2,0
Xs={i0}
Ys={i1}
rm[-1]
+crop. 2,0,3,0
Xt={i0}
Yt={i1}
rm[-1]
+crop. 3,0,4,0
Xq={i0}
Yq={i1}
rm[-1]
Liste.="<path d=\\"M"
Liste.=$Xo" "
Liste.=$Yo" C"
Liste.=$Xs" "
Liste.=$Ys" "
Liste.=$Xt" "
Liste.=$Yt" "
Liste.=$Xq" "
Liste.=$Yq" "
Liste.="\\" stroke=\\"blue\\" fill=\\"transparent\\" stroke-width=\\"2\\" mask=\\"none\\"  style=\\"fill:#000000;fill-opacity:0\\"/>"$CRLF
Index=2
repeat {{w/2}-1}
 Xu=$Xq
 Yu=$Yq
 Xd=$Xt
 Yd=$Yt
 +crop {$Index},0,{$Index+1},0
 Xt={i0}
 Yt={i1}
 rm[-1]
 rm[-1]
 +crop {$Index+1},0,{$Index+2},0
 Xq={i0}
 Yq={i1}
 rm[-1]
 rm[-1]
 Xs={$Xu+$Xu-$Xd}
 if $Xs<0 Xs=0 fi
 if $Xs>1023 Xs=1023 fi
 Ys={$Yu+$Yu-$Yd}
 if $Ys<0 Ys=0 fi
 if $Ys>1023 Ys=1023 fi
 Liste.="<path d=\\"M"
 Liste.=$Xu" "
 Liste.=$Yu" C"
 Liste.=$Xs" "
 Liste.=$Ys" "
 Liste.=$Xt" "
 Liste.=$Yt" "
 Liste.=$Xq" "
 Liste.=$Yq" "
 Liste.="\\" stroke=\\"blue\\" fill=\\"transparent\\" stroke-width=\\"2\\" mask=\\"none\\"  style=\\"fill:#000000;fill-opacity:0\\"/>"$CRLF
 Index={$Index+2}
done
rm.
########## ligne 2
samj_Masques_Noir_Et_Blanc_Preview $Param1Masque2,$Param2Masque2
to_gray.
negate.
dilate. 10
pointcloud. 3
channels. 0,1
WWe={round(w/100*$Echelle)}
if {$WWe%2}==0 resize. $WWe,1 else resize. {$WWe-1},1 fi
add. 12
tsp. 200
+crop. 1,0,2,0
Xs={i0}
Ys={i1}
rm[-1]
+crop. 2,0,3,0
Xt={i0}
Yt={i1}
rm[-1]
+crop. 3,0,4,0
Xq={i0}
Yq={i1}
rm[-1]
Liste.="<path d=\\"M"
Liste.=$Xo" "
Liste.=$Yo" C"
Liste.=$Xs" "
Liste.=$Ys" "
Liste.=$Xt" "
Liste.=$Yt" "
Liste.=$Xq" "
Liste.=$Yq" "
Liste.="\\" stroke=\\"blue\\" fill=\\"transparent\\" stroke-width=\\"2\\" mask=\\"none\\"  style=\\"fill:#000000;fill-opacity:0\\"/>"$CRLF
Index=2
repeat {{w/2}-1}
 Xu=$Xq
 Yu=$Yq
 Xd=$Xt
 Yd=$Yt
 +crop {$Index},0,{$Index+1},0
 Xt={i0}
 Yt={i1}
 rm[-1]
 +crop {$Index+1},0,{$Index+2},0
 Xq={i0}
 Yq={i1}
 rm[-1]
 Xs={$Xu+$Xu-$Xd}
 if $Xs<0 Xs=0 fi
 if $Xs>1023 Xs=1023 fi
 Ys={$Yu+$Yu-$Yd}
 if $Ys<0 Ys=0 fi
 if $Ys>1023 Ys=1023 fi
 Liste.="<path d=\\"M"
 Liste.=$Xu" "
 Liste.=$Yu" C"
 Liste.=$Xs" "
 Liste.=$Ys" "
 Liste.=$Xt" "
 Liste.=$Yt" "
 Liste.=$Xq" "
 Liste.=$Yq" "
 Liste.="\\" stroke=\\"blue\\" fill=\\"transparent\\" stroke-width=\\"2\\" mask=\\"none\\"  style=\\"fill:#000000;fill-opacity:0\\"/>"$CRLF
 Index={$Index+2}
done
Liste.="</svg>"$CRLF
('$Liste')
output_text.  $_path_rc/Liste_Points_TSP.svg
# SVG validé sur https://validator.w3.org/
rm
1500,100,1,3
fill_color. 255,255,255
text. "SVG disponible sur :",20,20,20,1,255,0,0
if '$_os'=='windows'
 text. $_path_rc"\\Liste_Points_TSP.svg",20,50,20,1,255,0,0
else
 text. $_path_rc"/Liste_Points_TSP.svg",20,50,20,1,255,0,0
fi
autocrop
3 Likes