MinWidth 16
MinHeight 16
-PreQuantThresholds 9 9 25 25 100 100 400 400 1000 1000 10000 10000 10000 40000 40000
+PreQuantThresholds 9 100 1000 1000 2000 4000 8000 10000 10000 20000 20000 40000 40000 40000 40000
PostQuantMinSteps 2
PostQuantMaxSteps 10
PostQuantThreshold 2
-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 }
};
{
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:
#include <alloca.h>
int
-image_sig_init(struct image_thread *thread UNUSED, struct image_sig_data *data, struct image *image)
+image_sig_init(struct image_thread *thread, struct image_sig_data *data, struct image *image)
{
ASSERT((image->flags & IMAGE_PIXEL_FORMAT) == COLOR_SPACE_RGB);
data->image = image;
data->full_cols = image->cols >> 2;
data->full_rows = image->rows >> 2;
data->blocks_count = data->cols * data->rows;
+ if (data->blocks_count >= 0x10000)
+ {
+ image_thread_err(thread, IMAGE_ERR_INVALID_DIMENSIONS, "Image too large for implemented signature algorithm.");
+ return 0;
+ }
data->blocks = xmalloc(data->blocks_count * sizeof(struct image_sig_block));
data->area = image->cols * image->rows;
DBG("Computing signature for image of %ux%u pixels (%ux%u blocks)",
{
byte luv[3];
srgb_to_luv_pixel(luv, p2);
- l_sum += *tp++ = luv[0] / 2;
+ l_sum += *tp++ = luv[0] / 4;
u_sum += luv[1];
v_sum += luv[2];
}
{
byte luv[3];
srgb_to_luv_pixel(luv, p3);
- l_sum += *tp++ = luv[0] / 2;
+ l_sum += *tp++ = luv[0] / 4;
u_sum += luv[1];
v_sum += luv[2];
}
/* ... and to the columns... skip LL band */
for (i = 0; i < 2; i++)
{
- t[i + 8] = (DAUB_3 * s[i + 8] - DAUB_2 * s[i +12] + DAUB_1 * s[i + 0] - DAUB_0 * s[i + 4]) / 0x4000;
- t[i +12] = (DAUB_3 * s[i + 0] - DAUB_2 * s[i + 4] + DAUB_1 * s[i + 8] - DAUB_0 * s[i +12]) / 0x4000;
+ t[i + 8] = (DAUB_3 * s[i + 8] - DAUB_2 * s[i +12] + DAUB_1 * s[i + 0] - DAUB_0 * s[i + 4]) / 0x10000;
+ t[i +12] = (DAUB_3 * s[i + 0] - DAUB_2 * s[i + 4] + DAUB_1 * s[i + 8] - DAUB_0 * s[i +12]) / 0x10000;
}
for (; i < 4; i++)
{
- t[i + 0] = (DAUB_0 * s[i + 8] + DAUB_1 * s[i +12] + DAUB_2 * s[i + 0] + DAUB_3 * s[i + 4]) / 0x4000;
- t[i + 4] = (DAUB_0 * s[i + 0] + DAUB_1 * s[i + 4] + DAUB_2 * s[i + 8] + DAUB_3 * s[i +12]) / 0x4000;
- t[i + 8] = (DAUB_3 * s[i + 8] - DAUB_2 * s[i +12] + DAUB_1 * s[i + 0] - DAUB_0 * s[i + 4]) / 0x4000;
- t[i +12] = (DAUB_3 * s[i + 0] - DAUB_2 * s[i + 4] + DAUB_1 * s[i + 8] - DAUB_0 * s[i +12]) / 0x4000;
+ t[i + 0] = (DAUB_0 * s[i + 8] + DAUB_1 * s[i +12] + DAUB_2 * s[i + 0] + DAUB_3 * s[i + 4]) / 0x10000;
+ t[i + 4] = (DAUB_0 * s[i + 0] + DAUB_1 * s[i + 4] + DAUB_2 * s[i + 8] + DAUB_3 * s[i +12]) / 0x10000;
+ t[i + 8] = (DAUB_3 * s[i + 8] - DAUB_2 * s[i +12] + DAUB_1 * s[i + 0] - DAUB_0 * s[i + 4]) / 0x10000;
+ t[i +12] = (DAUB_3 * s[i + 0] - DAUB_2 * s[i + 4] + DAUB_1 * s[i + 8] - DAUB_0 * s[i +12]) / 0x10000;
}
/* Extract energies in LH, HL and HH bands */
byte *image_region_dump(byte *buf, struct image_region *reg);
struct image_sig_block {
- struct image_sig_block *next;
- u32 area; /* block area in pixels (usually 16) */
- u32 v[IMAGE_VEC_F];
- u32 x, y; /* block position */
+ struct image_sig_block *next; /* linked list */
+ u32 x, y; /* block position */
+ byte area; /* block area in pixels (usually 16) */
+ byte v[IMAGE_VEC_F]; /* feature vector */
};
struct image_sig_region {
uns image_signatures_dist(struct image_signature *sig1, struct image_signature *sig2);
-#if 0
-/* K-dimensional interval */
-struct image_bbox {
- struct image_vector vec[2];
-};
-
-/* Similarity search tree... will be changed */
-struct image_tree {
- uns count; /* Number of images in the tree */
- uns depth; /* Tree depth */
- struct image_bbox bbox; /* Bounding box containing all the */
- struct image_node *nodes; /* Internal nodes */
- struct image_leaf *leaves; /* Leaves */
-};
-
-/* Internal node in the search tree */
-#define IMAGE_NODE_LEAF 0x80000000 /* Node contains pointer to leaves array */
-#define IMAGE_NODE_DIM 0xff /* Split dimension */
-struct image_node {
- u32 val;
-};
-
-/* Leaves in the search tree */
-#define IMAGE_LEAF_LAST 0x80000000 /* Last entry in the list */
-#define IMAGE_LEAF_BITS(i) (31 / IMAGE_VEC_K) /* Number of bits for relative position in i-th dimension */
-struct image_leaf {
- u32 flags; /* Relative position in bbox and last node flag */
- oid_t oid;
-};
-
-#define stk_print_image_vector(v) ({ struct image_vector *_v = v; \
- byte *_s = (byte *) alloca(IMAGE_VEC_K * 6), *_p = _s + sprintf(_s, "%d", _v->f[0]); \
- for (uns _i = 1; _i < IMAGE_VEC_K; _i++) _p += sprintf(_p, " %d", _v->f[_i]); _s; })
-#endif
-
#endif