MagickCompareImages: NCC metric not availabe

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
Vojtek
Posts: 3
Joined: 2016-03-16T03:39:49-07:00
Authentication code: 1151

MagickCompareImages: NCC metric not availabe

Post by Vojtek »

Hi,
I need to compare selected parts of few images to check if they match.

In console version I use

Code: Select all

convert img1 img2 -metric NCC -compare -format "%[distortion]" info:
and if a distortion is close to 1 this means the images are similar.

I was trying to implement the same approach using MagickWand API with FreePascal and I failed because of the following:
the NCC (normalized cross correlation) metric is not implemented :(

Simply in console mode the list is the following:

Code: Select all

C:\>convert -list metric
AE
Fuzz
MAE
MEPP
MSE
NCC
PAE
PHASH
PSNR
RMSE
and if one checks the MetricType available using API the list is a bit shorter and NCC is missing :(:

Code: Select all

i=0 -> UndefinedMetric
i=1 -> MeanAbsoluteErrorMetric
i=2 -> MeanSquaredErrorMetric
i=3 -> PeakAbsoluteErrorMetric
i=4 -> PeakSignalToNoiseRatioMetric
i=5 -> RootMeanSquaredErrorMetric
Any idea how to overcome that issue?
Was it done on purpose or is it just a bug?

Regards
Wojtek
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: MagickCompareImages: NCC metric not availabe

Post by el_supremo »

I've had a quick look at the source code for the ImageMagick package in FPC 3.0.0. The list of metrics in compare.inc are precisely those that you obtained from the API list. The copyright at the top of that file is: Copyright 1999-2005 ImageMagick Studio LLC. It's likely that in 2005 those were the only metrics available.
My guess is that FPC and PascalMagick use a version of ImageMagick from 2005 and they haven't been updated since then. If that's the case, it will be a lot of work to bring it up to date so that you can add the missing metrics.

If you need this soon, you may have to resort to using C.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Vojtek
Posts: 3
Joined: 2016-03-16T03:39:49-07:00
Authentication code: 1151

Re: MagickCompareImages: NCC metric not availabe

Post by Vojtek »

Thanks Pete.
I think you've spotted a reason for my problems (quite old version of PascalMagick). As for metric though I have implemented a workaround by executing convert.exe in a cmd window.
I'll have to have a closer look at what can be done in terms of making the PascalMagick up-to-date...

Wojtek
Post Reply