Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Rye
Posts: 158 Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789
Post
by Rye » 2013-03-09T04:16:28-07:00
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 ?
Last edited by
Rye on 2013-03-09T11:36:00-07:00, edited 1 time in total.
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2013-03-09T04:31:46-07:00
Code: Select all
set SRC="22 HP+200.png"
set REP="newImage.png"
"%IMG%convert" ^
%SRC% ^
( %REP% -geometry +39+37 ) ^
-composite ^
x.png
Rye
Posts: 158 Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789
Post
by Rye » 2013-03-09T04:40:35-07:00
Is there a way to automatically reuse the previous coordinate output instead of having to type it manually each time?
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2013-03-09T05:10:11-07:00
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".
Rye
Posts: 158 Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789
Post
by Rye » 2013-03-09T06:50:10-07:00
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%...
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2013-03-09T07:07:27-07:00
As I said in the other topic:
snibgo wrote: Then repeat until the number in brackets is no longer (0).
Rye
Posts: 158 Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789
Post
by Rye » 2013-03-09T09:21:33-07:00
Ok you are right.
Last question:
Is it possible to get ImageMagick to output this
instead of this:
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2013-03-09T09:51:25-07:00
Not as far as I know.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2013-03-09T10:45:02-07:00
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.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2013-03-09T10:50:28-07:00
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).
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2013-03-09T10:54:40-07:00
sed is available on Windows, eg in the Cygwin package.
For something this simple, the "for" command works fine.
Rye
Posts: 158 Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789
Post
by Rye » 2013-03-09T11:37:31-07:00
Thats funny...
Source image:
pattern to replace:
replacing pattern(new one):
RESULT:
^ What is this ?
Last edited by
Rye on 2013-03-09T12:59:49-07:00, edited 3 times in total.
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2013-03-09T12:42:46-07:00
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.
Rye
Posts: 158 Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789
Post
by Rye » 2013-03-09T12:54:35-07:00
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)
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2013-03-09T13:47:10-07:00
What are you saying? What do you think it should do after, say, 8 times?