gpt4 book ai didi

c - Imagemagick Magickcore 抛出断言错误

转载 作者:行者123 更新时间:2023-11-30 15:43:23 26 4
gpt4 key购买 nike

下面的代码抛出一个错误,我不明白为什么。

错误:核心: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);
}

最佳答案

您应该通过地址传递相似度:

double similarity;
aaaa = GetImageChannelDistortion(base_image, reference_image, channel, metric, &similarity, exception);

关于c - Imagemagick Magickcore 抛出断言错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19871747/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com