Page 1 of 1

Replace pattern in image with other one

Posted: 2013-03-08T05:36:19-07:00
by Rye
Well, to make it simple,

I want to replace theyellow pattern that have a line over them in this image:
Image => Pattern to replace: Image

with this one:
Image

I'm not quite sure IF this is possible, however as no other tools exist to do this I'm betting my hope on ImageMagick so it will help me (once again).

Thanks in advance for awesome answers.

Re: Replace pattern in image with other one

Posted: 2013-03-08T06:28:30-07:00
by snibgo
A compare with subimage-search will find the two locations, expressed as a "match score" image with brightest points (probably pure white in this case). The location of these brightest points are the coordinates to put the replacement image.

Re: Replace pattern in image with other one

Posted: 2013-03-08T06:48:23-07:00
by Rye
since I don't actually get the usage of those "bright points".

Mind posting an example ?

Re: Replace pattern in image with other one

Posted: 2013-03-08T08:11:29-07:00
by snibgo
Windows script:

Code: Select all

set SRC="22 HP+200.png"
set SUB=test.png
set REP="03 (yellow) +-Part.png"

"%IMG%compare" -metric RMSE %SRC% %SUB% -subimage-search found.png
This outputs:

Code: Select all

0 (0) @ 39,37
It has found a match at coords (39,37). In your script, paste the replacement at that position. Then repeat until the number in brackets is no longer (0).

Re: Replace pattern in image with other one

Posted: 2013-03-08T08:31:21-07:00
by Rye
what would have to be added to this script so it will automatically repeat a paste till a match is no longer found ?

Re: Replace pattern in image with other one

Posted: 2013-03-08T14:42:06-07:00
by Rye
How can I modify the script to actually use these coordinates right now and paste the other images in ?