Page 1 of 1
Compare Images in VBA
Posted: 2012-10-01T05:17:14-07:00
by JasonT
Hi
I want to compare 2 images and display the difference in VBA.
How do i write the code?
Thank you.
Re: Compare Images in VBA
Posted: 2012-10-01T05:24:43-07:00
by magick
Use ImageMagickObject. It includes a Compare() method to compare two images.
Re: Compare Images in VBA
Posted: 2012-10-02T05:54:28-07:00
by JasonT
I tried to input the command line " $ compare -compose src StudPath RefPath difference.png" but received a syntax error.
I am trying to compare 2 images and the difference is saved as another image. Is this possible?
I tried another way of writing, (RefPath/StudPath is the path of my image)
Dim VarName As New MagickImage
Dim compare As Image
VarName.compare , RefPath, StudPath, compare.jpg
but received an error which says" Object variable not set"
Re: Compare Images in VBA
Posted: 2012-10-02T15:25:10-07:00
by fmw42
try just
compare -metric rmse image1 image2 null:
if the two images are the same size.
Re: Compare Images in VBA
Posted: 2012-10-03T04:18:46-07:00
by JasonT
fmw42 wrote:try just
compare -metric rmse image1 image2 null:
if the two images are the same size.
rmse is highlighted and an error shows up which reads "Complie Error, Expected: End of Statement"
Re: Compare Images in VBA
Posted: 2012-10-03T09:53:59-07:00
by fmw42
try
compare -metric rmse rose: rose: null:
change the rmse to any other metric. If these fail, then you have a problem with your IM install or you have some other compare function on your system and need to rename the IM compare.
see
http://www.imagemagick.org/Usage/compare/#statistics
Re: Compare Images in VBA
Posted: 2012-10-05T05:44:56-07:00
by JasonT
Failed again.
I am writing in VBA, do i have to change the way in writing the command line? (declare IM etc.)
Re: Compare Images in VBA
Posted: 2012-10-05T09:44:47-07:00
by fmw42
You may have to provide the full path to compare when using any scripting system such as VBA, Applescript, PHP exec(), etc