Comparing images to know if they are visually identical using COM Interface in VBScript

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
GTAVLover
Posts: 2
Joined: 2017-08-23T05:51:24-07:00
Authentication code: 1151

Comparing images to know if they are visually identical using COM Interface in VBScript

Post by GTAVLover »

Hello, I want to compare visually similar images and get difference number in VBScript using COM Interface of ImageMagick.

I tried following command and it worked fine in Windows Command Processor:

Code: Select all

convert -metric PHASH C:\A.bmp C:\B.bmp NULL:
It gives the result 1.00 as it should.

But when I use following VBScript and execute it in WSH, COM interface throws the error unrecognized option "-metric PHASH".
I have ImageMagick 64-bit 7.0.2-9 Q16 installed in my 64-bit system.

This is the VBScript:

Code: Select all

Dim IM: Set IM = WScript.CreateObject("ImageMagickObject.MagickImage")

Dim Result: Result = IM.Compare("-metric PHASH", "C:\A.bmp", "C:\B.bmp", "NULL:")
WScript.Echo "PHASH Comparison returned " + CStr(Result)
Please help me to get this script work as it should.

Thanks in advance.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Comparing images to know if they are visually identical

Post by snibgo »

You are sending an output image to "x:", an X-terminal. Do you have an X-terminal? If not, that won't work.

What do you mean by "visually similar"? Samples would help us to advise.

The simplest comparison is when the two images are the same size, and you want a pixel-by-pixel comparison:

Code: Select all

compare -metric RMSE TCL.bmp TCCL.bmp NULL:
This returns a number in parentheses like "(0.03456)" which is 0.0 if they are identical, up to 1.0 if they are entirely different.
snibgo's IM pages: im.snibgo.com
GTAVLover
Posts: 2
Joined: 2017-08-23T05:51:24-07:00
Authentication code: 1151

Re: Comparing images to know if they are visually identical using COM Interface in VBScript

Post by GTAVLover »

Thanks for the reply. I also like to know difference between RMSE and PHASH. I can upload samples but they have watermarks.
As I edited my question, I now succeeded doing above in command processor, now I want to do the same in VBScript.
I updated my question some time ago.

Sincerely
Post Reply