下面的代码抛出了一个我不明白为什么的错误。这
错误:核心:magick/compare.c:1003:GetImageChannelDistortion:断言 `distortion != (double *) ((void *)0)' 失败。
我正在尝试将此命令行语句转换为magickcore代码,
compare -dissimilarity-threshold 1 -metric MSE image1.jpg image2.jpg NULL
注意:我无法调试 imagemagick,它没有安装在环境中,我无权安装它。
版本:ImageMagick 6.5.4-7 2012-04-10
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <magick/MagickCore.h>
int main(int argc,char **argv)
{
ExceptionInfo *exception;
Image *base_image, *reference_image, *composed_image;
double * similarity = (double *) NULL;
ImageInfo *image_info, *image_info1;
MetricType metric = MeanSquaredErrorMetric;
ChannelType channel = AllChannels;
MagickBooleanType aaaa;
char base_image_src[] = "jpgs/100000.jpg";
char reference_image_src[] = "jpgs/101201.jpg";
MagickCoreGenesis(NULL, MagickTrue);
exception = AcquireExceptionInfo();
image_info = CloneImageInfo((ImageInfo *) NULL);
(void) strcpy(image_info->filename, base_image_src);
base_image = ReadImage(image_info, exception);
image_info1 = CloneImageInfo((ImageInfo *) NULL);
(void) strcpy(image_info1->filename, reference_image_src);
reference_image = ReadImage(image_info1, exception);
if (exception->severity != UndefinedException) {
CatchException(exception);
}
if (base_image == (Image *) NULL) {
exit(1);
}
if (reference_image == (Image *) NULL){
exit(1);
}
if (similarity != (double *) NULL) {
printf("whyyyyyyy\n");
}
aaaa = GetImageChannelDistortion(base_image, reference_image, channel, metric, similarity, exception);
// Throws same double not null error
//similarity = GetImageChannelDistortions(base_image, reference_image, metric, exception);
// Gives me an answer of 0.0 which is not what I'm looking for
//composed_image = CompareImageChannels(base_image, reference_image, channel, metric, similarity, exception);
printf("After: %f\n", similarity);
image_info=DestroyImageInfo(image_info);
image_info1=DestroyImageInfo(image_info1);
exception=DestroyExceptionInfo(exception);
MagickCoreTerminus();
return(0);
}