Hi all,
I would like to compare and find differences (expect white color) of 2 images by sectors, by 5 degrees for example, and if it possible than change white color to red of the secton with marginal differencdes. Currently I'am experimenting with IM in windows CMD. I know this is pretty complicated and difficult algoritm but any ideas are welcome.
Sample image:
Image to compare with sample and find anomalies:
Testing method:
Thank you forward for your help.
Special image comparison
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Special image comparison
For graphics images, don't use JPEG unless someone is holding a gun to your head.
"-compose Difference -composite" gives 7 small white blobs on a black background. "-morphology erode" can reduce each to a single white pixel. Many techniques can find the coordinates of those white pixels, eg make black transparent and output to "sparse-color:".
I don't understand what you want then. Perhaps the "+" represents a known coordinate, and you want the distance and angle from that coordinate to each of the white pixels. Simple trigonometry will calculate that.
"-compose Difference -composite" gives 7 small white blobs on a black background. "-morphology erode" can reduce each to a single white pixel. Many techniques can find the coordinates of those white pixels, eg make black transparent and output to "sparse-color:".
I don't understand what you want then. Perhaps the "+" represents a known coordinate, and you want the distance and angle from that coordinate to each of the white pixels. Simple trigonometry will calculate that.
snibgo's IM pages: im.snibgo.com
Re: Special image comparison
Hi snibgo,
the "+" represents the origo point. This is not on the image originally. From that point I want to compare sectors. Is there any function in IM for comparing just a specified areas of two same size images?
the "+" represents the origo point. This is not on the image originally. From that point I want to compare sectors. Is there any function in IM for comparing just a specified areas of two same size images?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Special image comparison
"-distort depolar" will convert the image to a polar representation, where the x-axis is the angle from north, and the y-axis is the distance from the centre. I've named your samples as blob1.jpg and blob2.jpg:
With appropriate resizing, each column would represent 5 degrees. Then:
... gives the locations.
Code: Select all
convert blob1.jpg -distort depolar -1 d1.png
convert blob2.jpg -distort depolar -1 d2.png
Code: Select all
convert d1.png d2.png -compose Difference -composite c.png
snibgo's IM pages: im.snibgo.com
Re: Special image comparison
Hi snibgo, thanks for your kind support.
It's working but extreamly slowly. I am comparing images by 10pixel width columns. Should I use different image format instead of png?
Here is my .bat file:
@echo off
setlocal enableextensions enabledelayedexpansion
set /a "x = 0"
set /a "error = 0"
:while1
if %x% leq 100 (
set /a "x = x + 10"
convert sample/sample.png -crop 10x1200+%x%+0 sample/cropped_sample.png
convert totest/totest.png -crop 10x1200+%x%+0 totest/crops/cropped%x%.png
compare -metric AE sample/cropped_sample.png totest/crops/cropped%x%.png null:
goto :while1
)
endlocal
Also I dont know how to return and save to error variable the compare functions value.
It's working but extreamly slowly. I am comparing images by 10pixel width columns. Should I use different image format instead of png?
Here is my .bat file:
@echo off
setlocal enableextensions enabledelayedexpansion
set /a "x = 0"
set /a "error = 0"
:while1
if %x% leq 100 (
set /a "x = x + 10"
convert sample/sample.png -crop 10x1200+%x%+0 sample/cropped_sample.png
convert totest/totest.png -crop 10x1200+%x%+0 totest/crops/cropped%x%.png
compare -metric AE sample/cropped_sample.png totest/crops/cropped%x%.png null:
goto :while1
)
endlocal
Also I dont know how to return and save to error variable the compare functions value.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Special image comparison
For speed, don't use png for temporary results. Use miff instead.
Better yet, don't save temporary results. Combine the two converts and compare into a single convert.
Even with that, you would still read both inputs multiple times. Converting both to miff and re-reading that would be quicker. Better, just create one large convert command that reads both inputs, and creates many pairs of crops, each with a "-compare".
"compare" writes the text output to stderr.
You might get some tips from "whatRot.bat" on my "What rotation?" page.
Better yet, don't save temporary results. Combine the two converts and compare into a single convert.
Even with that, you would still read both inputs multiple times. Converting both to miff and re-reading that would be quicker. Better, just create one large convert command that reads both inputs, and creates many pairs of crops, each with a "-compare".
"compare" writes the text output to stderr.
You might get some tips from "whatRot.bat" on my "What rotation?" page.
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: Special image comparison
If you are creating files once and reading them multiple times, then MPC format should be faster. See http://www.imagemagick.org/Usage/files/#mpc