Been a fun evening. Thank you, @Silvio_Grosso !
That was pretty slick.
OOPS! Coin too close to the apple. Can’t do anything about that. Also, had to tweak settings a bit to have success. In the real world, that means manual intervention.
Ah — this was actually a FAIL, because I had to use a lightened version of the “standard euro coin”. In the real world, that also means intervention.
Success. This, of course, was the sweet spot photograph where all the stars align.
This is my script, for the curiosity of it all
matchit : -check ${"is_image_arg\ $1"} -skip ${2=0.25},${3=5},${4=0.25}
cutoff,ed,ps=${2-4}
pass$1 1
=>. patch
foreach[^patch] {
ma=-1
ml=-1
bc=-1,-1
=>. unkwn
pass[-1] 1
=>. patch
+matchpatch[unkwn] [patch],{$ps*w#$patch},{$ps*h#$patch},1,20,0,-0.005,1 d ,
-channels. 2 d ,
-fill. ">begin(cv=$cutoff*(iM-im);print(cv));i(x,y)<cv?1:0" d ,
-erode. $ed
-dilate. $ed
-label_fg. 0,1 d ,
=>. areas
-repeat {iM#$areas}
[areas]
-eq. {$>+1}
+barycenter.
-area.. 0,1
-if i(#-2,{@0,1})>$ma
ma={i(#-2,{@0,1})}
ml={$>+1}
bc={@0,1}
-fi
-keep[areas,unkwn,patch]
-done
-fill[areas] i(x,y)==$ml
+autocrop[areas]
-circle.. $bc,{1.5*sqrt(w^2+h^2)/2},1,1
-remove.
-inpaint_morpho[unkwn] [areas]
-remove[patch]
}
-remove[patch,areas]
And these were the command lines that produced the images above.
gmic matchit.gmic -input coinplant.jpeg -input coin.png matchit[-2] [-1],0.01,5,0.16 OK
gmic matchit.gmic -input apple1.jpg -input coin.png matchit[-2] [-1],0.01,5,0.16 OK
gmic matchit.gmic -input apple2.jpg -input coin.png matchit[-2] [-1],0.03,5,0.20 ADJ Coin too close to botanical
gmic matchit.gmic -input blueberry.jpg -input coin_light.png matchit[-2] [-1],0.05,5,0.35 ADJ+ADJMSK
So — if I had to intervene to adjust arguments or change the matching patch, I marked it as a ‘FAIL’. So I’m batting about 50% — way too low for the Real World. I’d like to be able to load a hundred images and realize success in about 98% of them. I could tolerate fixing two out of a hundred. But not half. May as well use GIMP. As David could attest, matchpatch
plays a statistical game, but matchpatch
can’t tolerate modest levels of variance. Loosen restrictions, and bit and pieces of plants look too much like euros. Tighten restrictions, and the euro is never seen. I started looking at CHT at about 11 PM, then dozed off around midnight. I’ll be fine after about 20 ounces of strong coffee…
Onto CHT!!!