Paste image on coordinates outputted previously [SOLVED]
Re: Paste image on coordinates outputted previously [SOLVED]
I you use the two 22x22 pics I provided in my post then it should produce a garbled image (like the one above).
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Paste image on coordinates outputted previously [SOLVED]
So it should produce a garbled image, and is doing so. Do you have a question?
snibgo's IM pages: im.snibgo.com
Re: Paste image on coordinates outputted previously [SOLVED]
yes:
Why doesn't it stop after it found all possible (correct) matches and continues placing new ones on places they don't belong.
I wanted to know if there is a way to avoid this (beside only executing the code the exact number needed).
Why doesn't it stop after it found all possible (correct) matches and continues placing new ones on places they don't belong.
I wanted to know if there is a way to avoid this (beside only executing the code the exact number needed).
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Paste image on coordinates outputted previously [SOLVED]
My crystal ball is on the blink. I can't see your script, so I don't know why it doesn't stop.
snibgo's IM pages: im.snibgo.com
Re: Paste image on coordinates outputted previously [SOLVED]
Code: Select all
@echo off
DEL found-0.png
DEL found-1.png
DEL co.txt
SET /P SOURCE=Drag and drop the image to be altered (SOURCE):
SET /P toreplace=Drag and drop the image that will be replaced:
SET /P replacingpattern=Drag and drop the image that will pasted (new):
SET toreplace="02blnkCMD.gif"
set SRC="%SOURCE%"
set SUB="%toreplace%"
set REP="%replacingpattern%"
:start
"%IMG%compare" -metric RMSE %SRC% %SUB% -subimage-search found.png 2>co.txt
set /p xycos= <co.txt
set str=%xycos%
echo.%str%
set str=%str:,=+%
ECHO %str% > co.TXT
set /p xycos= <co.txt
set str=%xycos%
echo."%str%"
set str=%str: =%
ECHO %str% > co.TXT
set /p xycos= <co.txt
set str=%xycos%
echo.%str%
set str=%str:@= +%
ECHO %str% > co.TXT
set /p xycos= <co.txt
set str=%xycos%
echo.%str%
set str=%str:~-8%
ECHO %str% > co.TXT
set /p xcoyco= <co.txt
"%IMG%convert" ^
%SRC% ^
( %REP% -geometry %xcoyco% ) ^
-composite ^
%SOURCE%
DEL found-0.png
DEL found-1.png
set /p choice= Repeat script ? (1=Yes 2=No)
if %choice%==1 goto start
if %choice%==2 goto exit
:exit
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Paste image on coordinates outputted previously [SOLVED]
I can't figure out all those "set" and "echo" statements. You could parse co.txt in a single "for" statement, without intermediate files. But they put the correct offsets into xcoyco.
As far as I can see, for as long as the user presses "1", the script will loop. You seem to be ignoring the output from compare that gives the RMSE metric, which gives zero for exact matches; larger number otherwise.
As far as I can see, for as long as the user presses "1", the script will loop. You seem to be ignoring the output from compare that gives the RMSE metric, which gives zero for exact matches; larger number otherwise.
snibgo's IM pages: im.snibgo.com
Re: Paste image on coordinates outputted previously [SOLVED]
Code: Select all
"%IMG%compare" -metric RMSE %SRC% %SUB% -subimage-search found.png 2>co.txt
"%IMG%convert" ^
%SRC% ^
( %REP% -geometry %xcoyco% ) ^
-composite ^
%SOURCE%
It contains what you think "stops the script once no matches are found. The problem I see however is:
It won't stop because it still "finds" matches... That the matches that are found suck is another story.
What kind of script would you suggest to stop after it found any "right" matches ?
BTW: those set and echos are possible with for aswell, but I kinda don't want to use it anymore as it spits only weird error messages.
This gets the job done aswell. Its only for automatically entering the coordinates anyways.
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Paste image on coordinates outputted previously [SOLVED]
You need to decide what RMSE number you consider to be close enough. When "compare" returns a larger value, exit the loop.
snibgo's IM pages: im.snibgo.com
Re: Paste image on coordinates outputted previously [SOLVED]
is there an introduction to RSME ? I would prefer a 100% match. (if that can be achieved
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Paste image on coordinates outputted previously [SOLVED]
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Paste image on coordinates outputted previously [SOLVED]
Other metrics are available. See http://www.imagemagick.org/Usage/compare/#statistics
RMSE for a single pixel in two images is sqrt((diffR^2+diffG^2+diffB^2)/3)
Get the color channel differences or error between two images at a given pixel (E). Then sum or add them up (S). Then divide by 3 to get the mean or average (M). Then take the square root (R). Now reverse the letters from ESMR to get RMSE.
A perfect match would be when each difference is zero, so that the RMSE value is zero.
RMSE for a single pixel in two images is sqrt((diffR^2+diffG^2+diffB^2)/3)
Get the color channel differences or error between two images at a given pixel (E). Then sum or add them up (S). Then divide by 3 to get the mean or average (M). Then take the square root (R). Now reverse the letters from ESMR to get RMSE.
A perfect match would be when each difference is zero, so that the RMSE value is zero.
Re: Paste image on coordinates outputted previously [SOLVED]
Code: Select all
"%IMG%compare" -metric RMSE ((diffR^2+diffG^2+diffB^2)/3) %SRC% %SUB% -subimage-search found.png
However even if I use this one it seems the program still has its difficulty distinguishing this from this:
I can use either as source (to be replaced) and it will work with both (:weird:)..
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Paste image on coordinates outputted previously [SOLVED]
Sorry you misunderstand
"%IMG%compare" -metric RMSE %SRC% %SUB% -subimage-search found.png
You have to decide what value is a good threshold for the error value returned. Then substitute or do not substitute your new image based upon your threshold for the error value, i.e. how close a match is appropriate.
The named RMSE metric uses that formula. You do not include the formula in the command. RMSE means that it uses that formula already (though you forgot the sqrt). So remove the part in RED-metric RMSE ((diffR^2+diffG^2+diffB^2)/3)
"%IMG%compare" -metric RMSE %SRC% %SUB% -subimage-search found.png
You have to decide what value is a good threshold for the error value returned. Then substitute or do not substitute your new image based upon your threshold for the error value, i.e. how close a match is appropriate.
Last edited by fmw42 on 2013-03-10T11:53:38-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Paste image on coordinates outputted previously [SOLVED]
Neither of these images match any pattern but the background in your image. Perhaps you are using the wrong images.Rye wrote: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]
You are right ! I updated the two 22x22 images.
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC