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?".
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:
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.
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?
"-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:
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.
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.