This is the full code:
Code: Select all
#include <string.h>
#include "ImageMagick-6/magick/MagickCore.h"
int main()
{
ExceptionInfo *exception;
Image *base_image, *reference_image, *composed_image;
double similarity;
RectangleInfo offset;
ImageInfo *image_info_base, *image_info_reference, *image_info_composed;
char base_image_src[] = "in1.jpeg";
char reference_image_src[] = "in2.jpeg";
char composed_image_dst[] = "out.jpeg";
MagickCoreGenesis(NULL, MagickTrue);
exception = AcquireExceptionInfo();
image_info_base = CloneImageInfo((ImageInfo *) NULL);
(void) strcpy(image_info_base->filename, base_image_src);
base_image = ReadImage(image_info_base, exception);
CatchException(exception);
image_info_reference = CloneImageInfo((ImageInfo *) NULL);
(void) strcpy(image_info_reference->filename, reference_image_src);
reference_image = ReadImage(image_info_reference, exception);
CatchException(exception);
composed_image = SimilarityImage(base_image, reference_image, &offset, &similarity, exception);
CatchException(exception);
printf("%f\n", similarity);
printf("w %d h %d x %d y %d\n", (int) offset.width, (int) offset.height, (int) offset.x, (int) offset.y);
strcpy(composed_image->filename, composed_image_dst);
composed_image->x_resolution = 256;
composed_image->y_resolution = 256;
composed_image->rows = 256;
composed_image->columns = 256;
image_info_composed = CloneImageInfo((ImageInfo *) NULL);
if (WriteImage(image_info_composed, composed_image) == MagickTrue)
printf("image saved to disk\n");
CatchException(&composed_image->exception);
exception = DestroyExceptionInfo(exception);
MagickCoreTerminus();
return 0;
}


I keep getting a black image with only one grey pixel at the top left corner

What am I doing wrong?