|
NAMEpuzzle_init_cvec ,
puzzle_init_dvec ,
puzzle_fill_dvec_from_file ,
puzzle_fill_cvec_from_file ,
puzzle_fill_cvec_from_dvec ,
puzzle_free_cvec ,
puzzle_free_dvec ,
puzzle_init_compressed_cvec ,
puzzle_free_compressed_cvec ,
puzzle_compress_cvec ,
puzzle_uncompress_cvec ,
puzzle_vector_normalized_distance —
compute comparable signatures of bitmap images.
SYNOPSIS#include <puzzle.h>
int
int
int
int
void
void
void
void
void
void
void
int
int
double
DESCRIPTIONThe Puzzle library computes a signature out of a bitmap picture. Signatures are comparable and similar pictures have similar signatures.After a picture has been loaded and uncompressed, featureless parts of the image are skipped (autocrop), unless that step has been explicitely disabled, see puzzle_set(3) LIBPUZZLE CONTEXTEvery public function requires a PuzzleContext object, that stores every required tunables.Any application using libpuzzle should initialize a
PuzzleContext object with
puzzle_init_context(&context);
DVEC AND CVEC VECTORSThe next step is to divide the cropped image into a grid and to compute the average intensity of soft‐edged pixels in every block. The result is a PuzzleDvec object.PuzzleDvec objects should be initialized
before use, with The PuzzleDvec structure has two important fields: vec is the pointer to the first element of the array containing the average intensities, and sizeof_compressed_vec is the number of elements. PuzzleDvec objects are not comparable, so what you usually want is to transform these objects into PuzzleCvec objects. A PuzzleCvec object is a vector with relationships between adjacent blocks from a PuzzleDvec object. The But just like the other structure,
PuzzleCvec objects must be initialized and freed with
PuzzleCvec objects have a vector whoose first element is in the vec field, and the number of elements is in the sizeof_vec field LOADING PICTURESPuzzleDvec and PuzzleCvec objects can be computed from a bitmap picture file, withpuzzle_fill_dvec_from_file () and
puzzle_fill_cvec_from_file ()
GIF , PNG and JPEG files formats are currently supported and automatically recognized. Here's a simple example that creates a PuzzleCvec objects out of a file. PuzzleContext context; PuzzleCvec cvec; puzzle_init_context(&context); puzzle_init_cvec(&context,
&cvec); puzzle_fill_cvec_from_file(&context, &cvec,
"test-picture.jpg");
COMPARING VECTORSIn order to check whether two pictures are similar, you need to compare their PuzzleCvec signatures, usingpuzzle_vector_normalized_distance ()
That function returns a distance, between 0.0 and 1.0. The lesser, the nearer. Tests on common pictures show that a normalized distance of 0.6 (also defined as PUZZLE_CVEC_SIMILARITY_THRESHOLD ) means that both pictures are visually similar. If that threshold is not right for your set of pictures, you can experiment with PUZZLE_CVEC_SIMILARITY_HIGH_THRESHOLD , PUZZLE_CVEC_SIMILARITY_LOW_THRESHOLD and PUZZLE_CVEC_SIMILARITY_LOWER_THRESHOLD or with your own value. If the fix_for_texts of
If fix_for_texts is 0 , that special way of computing the normalized distance is disabled. PuzzleContext context; PuzzleCvec cvec1, cvec2; double d; puzzle_init_context(&context); puzzle_init_cvec(&context,
&cvec1); puzzle_init_cvec(&context, &cvec2);
puzzle_fill_cvec_from_file(&context, &cvec1,
"test-picture-1.jpg"); puzzle_fill_cvec_from_file(&context,
&cvec2, "test-picture-2.jpg"); d =
puzzle_vector_normalized_distance(&context, &cvec1, &cvec2, 1);
if (d < PUZZLE_CVEC_SIMILARITY_THRESHOLD) {
CVEC COMPRESSIONIn order to reduce storage needs, PuzzleCvec objects can be compressed to 1/3 of their original size.PuzzleCompressedCvec structures hold the
compressed data. Before and after use, these structures have to be passed to
And RETURN VALUEFunctions return 0 on success, and -1 if something went wrong.AUTHORSFrank DENIS libpuzzle at pureftpd dot orgACKNOWLEDGMENTSXerox Research Center H. CHI WONG Marschall BERN David GOLDBERG Sameh SCHAFIKSEE ALSOpuzzle_set(3) puzzle-diff(8)
Visit the GSP FreeBSD Man Page Interface. |