I have very recently discovered imagemagick and its amazing, and so is the community support.
I am looking for some help on comparing images.
Using windows 10 and the latest version of ImageMagick-7.0.8-68-Q16-x64
What I am trying to achieve:
I have approximately 40,000 images each in two folders, lets call them folder A and folder B, which I need to compare
-The file names in both folders is exactly the same. A -> 1, 2, 3, 4, 5..... B -> 1, 2, 3, 4, 5.....
-All images are in *.tiff format
-I need to compare image A->1 with B->
Data Prep:
I have currently taken a sample of 100 images from each folder to test the comparison, lets call them folder A# and folder B#.
The first step was to normalize the dimensions. Images in folder A# are 2400x2400, whereas the ones in folder B# are 2350x2350
I converted all images in folder A# to 2350x2350 using the following:
Code: Select all
mogrify -resize 2365x2365 *.tiff
Code: Select all
mogrify -background white -alpha remove -alpha off *.tiff
Code: Select all
compare -metric ncc Filepath1.tiff Filepath2.tiff -compose src difference.tiff 2>Output.txt
But for most comparisons, it gave me 0.9xxx, even when the images were matching.
Approach #2:
I tried using auto-level in hopes to normalize differences arising from brightness, contrast, etc. using the following code and then ran the comparison again, with a similar result
Code: Select all
mogrify –auto-level *.tiff
I then converted all images to grayscale, in order to see if the result improved using the following code, but with similar result
Code: Select all
mogrify -colorspace Gray *.tiff
Code: Select all
compare -fuzz 25% -metric ncc Filepath1.tiff Filepath2.tiff -compose src difference.tiff 2>Output.txt
Is there a method to normalize images, so that their differences in composition no longer trigger a difference, but only if the images are acutally different if that makes sense?
Here are sample images:
Image 1A: https://drive.google.com/file/d/1ULv9Vk ... sp=sharing
Image 1B: https://drive.google.com/file/d/1xW4L3k ... sp=sharing
Compare Result: https://drive.google.com/file/d/1Aw_LRk ... sp=sharing
Comparison value: 0.849224
Some side questions:
1. How can I insert an mage inline in the thread here. when I tried to add the above images as [img], it just displayed a broken image icon
2. What is the difference if I write -fuzz before or after metric -AE
3. Is there a way to write 2>output.txt for all comparisons into 1 txt file with the format "filename - result". Currently, I am concatenating different text docs into 1 in order to parse it in excel. I am pretty sure there is a better way
4. How can I run the compare command for all images in two folders in using * operator. Currently, I am building the script in excel for inidvidual files, and then copying them in command line to execute.
Thanks in advance for your help.