Page 1 of 3
Paste image on coordinates outputted previously [SOLVED]
Posted: 2013-03-09T04:16:28-07:00
by Rye
Well in a previous thread of mine it was possible to get ImageMagic to output these coordinates (
viewtopic.php?f=1&t=22925).
The question now however is:
How do I have to proceed from here in order to paste a new image (say new_image.png for example) onto that coordinate ?
Re: Paste image on coordinates outputted previously
Posted: 2013-03-09T04:31:46-07:00
by snibgo
Code: Select all
set SRC="22 HP+200.png"
set REP="newImage.png"
"%IMG%convert" ^
%SRC% ^
( %REP% -geometry +39+37 ) ^
-composite ^
x.png
Re: Paste image on coordinates outputted previously
Posted: 2013-03-09T04:40:35-07:00
by Rye
Is there a way to automatically reuse the previous coordinate output instead of having to type it manually each time?
Re: Paste image on coordinates outputted previously
Posted: 2013-03-09T05:10:11-07:00
by snibgo
Yes. For example, redirect the compare output stderr to a file ...
Code: Select all
"%IMG%compare" -metric RMSE %SRC% %SUB% -dissimilarity-threshold 1 -subimage-search found.png 2>y.txt
... then read that file with "for".
Re: Paste image on coordinates outputted previously
Posted: 2013-03-09T06:50:10-07:00
by Rye
Alright...
That is good so far, except for one thing I don't understand... (refering to the other topic):
I have this image:
and replaced all
with those:
(3 were replaced).
Now however, Imagmagick just finds one that doesn't actually fit my search:
Is there a way to make the search more "pixel perfect" ?
It seems weird that it finds stuff that isn't even matching 100%...
Re: Paste image on coordinates outputted previously
Posted: 2013-03-09T07:07:27-07:00
by snibgo
As I said in the other topic:
snibgo wrote:Then repeat until the number in brackets is no longer (0).
Re: Paste image on coordinates outputted previously
Posted: 2013-03-09T09:21:33-07:00
by Rye
Ok you are right.
Last question:
Is it possible to get ImageMagick to output this
instead of this:
Re: Paste image on coordinates outputted previously
Posted: 2013-03-09T09:51:25-07:00
by snibgo
Not as far as I know.
Re: Paste image on coordinates outputted previously
Posted: 2013-03-09T10:45:02-07:00
by fmw42
You can pipe the output to sed (unix) and filter it to show only the part you want. I do not know the equivalent for Windows.
Re: Paste image on coordinates outputted previously
Posted: 2013-03-09T10:50:28-07:00
by fmw42
For reference, though not useful in Windows without Cygwin, see my bash shell script, maxima, at the link below.
You would only need one pass of compare, then get the coordinates from maxima, then use -flatten to composite your template at each coordinate in one command (or use multiple -compose over commands for each location).
Re: Paste image on coordinates outputted previously
Posted: 2013-03-09T10:54:40-07:00
by snibgo
sed is available on Windows, eg in the Cygwin package.
For something this simple, the "for" command works fine.
Re: Paste image on coordinates outputted previously [SOLVED]
Posted: 2013-03-09T11:37:31-07:00
by Rye
Thats funny...
Source image:
pattern to replace:
replacing pattern(new one):
RESULT:
^ What is this ?
Re: Paste image on coordinates outputted previously [SOLVED]
Posted: 2013-03-09T12:42:46-07:00
by snibgo
It works fine for me: compare finds the best location. The RMSE isn't zero, because the "pattern to replace" doesn't occur in the source.
Re: Paste image on coordinates outputted previously [SOLVED]
Posted: 2013-03-09T12:54:35-07:00
by Rye
Try it yourself with these two and see for yourself (I had posted the wrong ones):
(try it as often as possible... lets say 8 times)
Re: Paste image on coordinates outputted previously [SOLVED]
Posted: 2013-03-09T13:47:10-07:00
by snibgo
What are you saying? What do you think it should do after, say, 8 times?