下面的代码抛出一个错误,我不明白为什么。
错误:core:magick / compare.c:1003:GetImageChannelDistortion:断言`失真!=(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);
}
答案 0 :(得分:1)
您应该通过地址传递相似性:
double similarity;
aaaa = GetImageChannelDistortion(base_image, reference_image, channel, metric, &similarity, exception);