-f --format-1 image1 format (jpeg, gif, png)\n\
-F --format-2 image2 format\n\
-g --background background color (hexadecimal RRGGBB)\n\
--s --segmentation-1 writes image1 segmentation to given file\n\
--S --segmentation-2 writes image2 segmentation to given file\n\
+-r --segmentation-1 writes image1 segmentation to given file\n\
+-R --segmentation-2 writes image2 segmentation to given file\n\
", stderr);
exit(1);
}
-static char *shortopts = "qf:F:g:t:s:S:" CF_SHORT_OPTS;
+static char *shortopts = "qf:F:g:t:r:R:" CF_SHORT_OPTS;
static struct option longopts[] =
{
CF_LONG_OPTS
{ "format-1", 0, 0, 'f' },
{ "format-2", 0, 0, 'F' },
{ "background", 0, 0, 'g' },
- { "segmentation-1", 0, 0, 's' },
- { "segmentation-2", 0, 0, 'S' },
+ { "segmentation-1", 0, 0, 'r' },
+ { "segmentation-2", 0, 0, 'R' },
{ NULL, 0, 0, 0 }
};
#define MSG(x...) do{ if (verbose) log(L_INFO, ##x); }while(0)
#define TRY(x) do{ if (!(x)) die("Error: %s", it.err_msg); }while(0)
+static void
+msg_str(byte *s, void *param UNUSED)
+{
+ MSG("%s", s);
+}
+
static void
dump_signature(struct image_signature *sig)
{
{
byte c[3];
double luv[3], xyz[3], srgb[3];
- luv[0] = data->regions[i].a[0] * (2 / 2.55);
+ luv[0] = data->regions[i].a[0] * (4 / 2.55);
luv[1] = ((int)data->regions[i].a[1] - 128) * (4 / 2.55);
luv[2] = ((int)data->regions[i].a[2] - 128) * (4 / 2.55);
luv_to_xyz_slow(xyz, luv);
color_make_rgb(&background_color, (v >> 16) & 255, (v >> 8) & 255, v & 255);
}
break;
- case 's':
+ case 'r':
segmentation_name_1 = optarg;
break;
- case 'S':
+ case 'R':
segmentation_name_2 = optarg;
break;
default:
TRY(image_sig_init(&it, &data, img1));
image_sig_preprocess(&data);
if (data.valid)
- image_sig_segmentation(&data);
+ {
+ image_sig_segmentation(&data);
+ image_sig_detect_textured(&data);
+ }
if (segmentation_name_1)
write_segmentation(&data, segmentation_name_1);
image_sig_finish(&data, &sig1);
TRY(image_sig_init(&it, &data, img2));
image_sig_preprocess(&data);
if (data.valid)
- image_sig_segmentation(&data);
+ {
+ image_sig_segmentation(&data);
+ image_sig_detect_textured(&data);
+ }
if (segmentation_name_2)
write_segmentation(&data, segmentation_name_2);
image_sig_finish(&data, &sig2);
if (img1 && img2)
{
- uns dist = image_signatures_dist(&sig1, &sig2);
- MSG("dist=%.6f", dist / (double)(1 << IMAGE_SIG_DIST_SCALE));
+ uns dist;
+ if (verbose)
+ {
+ struct fastbuf *fb = bfdopen(0, 4096);
+ dist = image_signatures_dist_explain(&sig1, &sig2, msg_str, NULL);
+ bclose(fb);
+ }
+ else
+ dist = image_signatures_dist(&sig1, &sig2);
+ MSG("dist=%u", dist);
}
if (img1)