---
name: "puzzle_set"
section: "3"
platform: "linux"
package: "libpuzzle-dev"
version: "0.11-3+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/puzzle_set"
---

# puzzle\_set(3)

set tunables for libpuzzle functions

## NAME

puzzle\_set\_max\_width, puzzle\_set\_max\_height, puzzle\_set\_lambdas, puzzle\_set\_p\_ratio, puzzle\_set\_noise\_cutoff, puzzle\_set\_contrast\_barrier\_for\_cropping, puzzle\_set\_max\_cropping\_ratio, puzzle\_set\_autocrop - set tunables for libpuzzle functions

## SYNOPSIS

\#include \<puzzle.h\>

int puzzle\_set\_max\_width(PuzzleContext \**context*, unsigned int *width*);

int puzzle\_set\_max\_height(PuzzleContext \**context*, unsigned int *height*);

int puzzle\_set\_lambdas(PuzzleContext \**context*, unsigned int *lambdas*);

int puzzle\_set\_p\_ratio(PuzzleContext \**context*, double *p\_ratio*);

int puzzle\_set\_noise\_cutoff(PuzzleContext \**context*, double *noise\_cutoff*);

int puzzle\_set\_contrast\_barrier\_for\_cropping(PuzzleContext \**context*, double *barrier*);

int puzzle\_set\_max\_cropping\_ratio(PuzzleContext \**context*, double *ratio*);

int puzzle\_set\_autocrop(PuzzleContext \**context*, int *enable*);

## DESCRIPTION

While default values have been chosen to be ok for most people, the **puzzle\_set\_\*()** functions are knobs to fit the algorithm to your set of data and to your applications.

## LAMBDAS

By default, pictures are divided in 9 x 9 blocks.

*9* is the *lambdas* value, and it can be changed with **puzzle\_set\_lambdas()**.

For large databases, for complex images, for images with a lot of text or for sets of near-similar images, it might be better to raise that value to *11* or even *13*.

However, raising that value obviously means that vectors will require more storage space.

The *lambdas* value should remain the same in order to get comparable vectors. So if you pick *11* (for instance), you should always use that value for all pictures you will compute a digest for **puzzle\_set\_p\_ratio()**.

The average intensity of each block is based upon a small centered zone.

The *"p ratio"* determines the size of that zone. The default is 2.0, and that ratio mimics the behavior that is described in the reference algorithm.

For very specific cases (complex images) or if you get too many false positives, as an alternative to increasing lambdas, you can try to lower that value, for instance to *1.5*.

The lowest acceptable value is *1.0*.

## MAXIMUM SIZES

In order to avoid CPU starvation, pictures won't be processed if their width or height is larger than 3000 pixels.

These limits are rather large, but if you ever need to change them, the **puzzle\_set\_max\_width()** and **puzzle\_set\_max\_height()** are available.

## NOISE CUTOFF

The noise cutoff defaults to 2. If you raise that value, more zones with little difference of intensity will be considered as similar.

Unless you have very specialized sets of pictures, you probably don't want to change this.

## AUTOCROP

By default, featureless borders of the original image are ignored. The size of each border depends on the sum of absolute values of differences between adjacent pixels, relative to the total sum.

That feature can be disabled with **puzzle\_set\_autocrop(0)**, any other value will enable it.

**puzzle\_set\_contrast\_barrier\_for\_cropping()** changes the tolerance. The default value is 5. Less shaves less, more shaves more.

**puzzle\_set\_max\_cropping\_ratio()** : this is a safe-guard against unwanted excessive auto-cropping.

The default (0.25) means that no more than 25% of the total width (or height) will ever be shaved.

## RETURN VALUE

Functions return *0* on success, and *-1* if something went wrong.

## AUTHORS

Frank DENIS libpuzzle at pureftpd dot org

## SEE ALSO

[**libpuzzle**(3)](/libpuzzle/3.md), **puzzle-diff**(8)
