Efros-Leung
Exemplar-basedtexturesynthesis(Efros-Leung)
Functions
inc/synthesis.h File Reference

Sub-functions for texture synthesis. More...

#include <stdlib.h>
#include "auxiliary.h"
#include "mt.h"

Go to the source code of this file.

Functions

int compare_pixel (const void *a, const void *b)
 Comparison between pixel's number of neighbors.
int compare_cand_dist (const void *a, const void *b)
 Comparison between candidates' distances.
unsigned char * load_patch_list (Cimage w, int t)
 Load the patch of an image into an array.
unsigned char * load_patch_list_gray (Gimage w, int t)
 Load the patch of an image into an array.
float * gaussian_weights (int patchSize, int t)
 Pre-compute Gaussian weights.
float * uniform_weights (int patchSize)
 Pre-compute uniform weights.
long int generate_current_list (int cote, int coin, Pixel current, unsigned char *mask, int t, int larg, int haut)
 Generate the current list of pixels to be filled.
int known_neighbours (Cimage v, unsigned char *mask, Pixel current, int i, int t, int larg, int haut, unsigned short *mask_neighb, unsigned char *curr_patch)
 Extract the neighbors' mask and values at a given pixel.
int known_neighbours_gray (Gimage v, unsigned char *mask, Pixel current, int i, int t, int ncols_v, int nrows_v, unsigned short *mask_neighb, unsigned char *curr_patch)
 Extract the neighbors' mask and values at a given pixel.
int find_candidates (unsigned char *patch_list, unsigned char *patch_list_mask, unsigned char *curr_patch, int totalPatchs, int t, unsigned short *mask_neighb, int voisins_updated, float tolerance, Cand_dist cand_list, float *weights)
 Get the set of candidates for a given pixel to be filled.
int find_candidates_gray (unsigned char *patch_list, unsigned char *patch_list_mask, unsigned char *curr_patch, int totalPatchs, int t, unsigned short *mask_neighb, int voisins_updated, float tolerance, Cand_dist cand_list, float *weights)
 Get the set of candidates for a given pixel to be filled.
int compute_distances (int totalPatchs, int t, int voisins_updated, unsigned short *mask_neighb, unsigned char *patch_list, unsigned char *patch_list_mask, unsigned char *curr_patch, float tolerance, Cand_dist cand_list, float *radius_out, float *weights)
 Compute the distances between a patch and all the others ones.
int compute_distances_gray (int totalPatchs, int t, int neighbs_updated, unsigned short *mask_neighb, unsigned char *patch_list, unsigned char *patch_list_mask, unsigned char *curr_patch, float tolerance, Cand_dist cand_list, float *radius_out, float *weights)
 Compute the distances between a patch and all the others ones.
long int random_choose (Cand_dist cand_list, long int size_list)
 Randomly choose an element from a list.
void retrieve_coords (int p, int ncols, int *x, int *y)
 Retrieve the coordinates in the example image from a patch index.

Detailed Description

Sub-functions for texture synthesis.

Author:
Cecilia Aguerrebere

Function Documentation

int compare_cand_dist ( const void *  a,
const void *  b 
)

Comparison between candidates' distances.

This function is used by qsort to sort a list of candidates.

Parameters:
apointer to a candidate
bpointer to another candidate
Returns:
a negative, zero, or positive value respectively if the distance of a is smaller than, equal to, or greater than the distance of b.
int compare_pixel ( const void *  a,
const void *  b 
)

Comparison between pixel's number of neighbors.

This function is used by qsort to sort a list of pixel in decreasing order of known neighbors.

Parameters:
apointer to a pixel
bpointer to another pixel
Returns:
a negative, zero, or positive value respectively if the number of known neighbors is more, the same, or less for a than for b.
int compute_distances ( int  totalPatchs,
int  t,
int  neighbs_updated,
unsigned short *  mask_neighb,
unsigned char *  patch_list,
unsigned char *  patch_list_mask,
unsigned char *  curr_patch,
float  tolerance,
Cand_dist  cand_list,
float *  radius_out,
float *  weights 
)

Compute the distances between a patch and all the others ones.

Parameters:
totalPatchsnumber of patches in the dictionary
thalf-size of the patch
neighbs_updatednumber of known neighbors
mask_neighbmask of known neighbors
patch_listthe list of patches
curr_patchthe current patch
tolerancevalue of $(1+\varepsilon)^2$
cand_listoutput for the distances
radius_outthreshold for distance (computation stops if reached)
weightsweights used for the distance between patches
int compute_distances_gray ( int  totalPatchs,
int  t,
int  neighbs_updated,
unsigned short *  mask_neighb,
unsigned char *  patch_list,
unsigned char *  patch_list_mask,
unsigned char *  curr_patch,
float  tolerance,
Cand_dist  cand_list,
float *  radius_out,
float *  weights 
)

Compute the distances between a patch and all the others ones.

Idem compute_distances for gray images.

See also:
compute_distances
int find_candidates ( unsigned char *  patch_list,
unsigned char *  patch_list_mask,
unsigned char *  curr_patch,
int  totalPatchs,
int  t,
unsigned short *  mask_neighb,
int  neighbs_updated,
float  tolerance,
Cand_dist  cand_list,
float *  weights 
)

Get the set of candidates for a given pixel to be filled.

Given the dictionary and the current pixel to be filled, find all the possible candidates, i.e. all the patches p verifying:

dist( p, current ) <= dist_min * (1 + tolerance)

with dist_min = minimum distance between the current patch and the dictionary elements.

The list is given in cand_list, and the number of elements on the list is given by size_cand_list. The cand_list is sorted in increasing order of distance value.

Parameters:
patch_listlist of patches extracted from the input image
patch_list_masklist of mask of patches extracted from the mask of the input image
curr_patchcurrent patch
totalPatchsnumber of patches in the patch_list
thalf-size of the patch
mask_neighbmask of the known pixels in the current patch
neighbs_updatednumber of known neighbors
tolerancevalue of $(1+\varepsilon)^2$
cand_listutput for the candidates (sorted from closest)
weightsweights used for the distance between patches
Returns:
the number of candidates
int find_candidates_gray ( unsigned char *  patch_list,
unsigned char *  patch_list_mask,
unsigned char *  curr_patch,
int  totalPatchs,
int  t,
unsigned short *  mask_neighb,
int  neighbs_updated,
float  tolerance,
Cand_dist  cand_list,
float *  weights 
)

Get the set of candidates for a given pixel to be filled.

Idem find_candidates for gray level images.

See also:
find_candidates
float* gaussian_weights ( int  patchSize,
int  t 
)

Pre-compute Gaussian weights.

Parameters:
patchSizesize of the patch
thalf-size of the patch (should have patchSize = 2t+1)
Returns:
array of Gaussian weights, length = patchSize x patchSize
long int generate_current_list ( int  side,
int  corner,
Pixel  current,
unsigned char *  mask,
int  t,
int  ncols,
int  nrows 
)

Generate the current list of pixels to be filled.

Parameters:
side
corner
currentoutput list of pixels
maskmask of already filled pixels
thalf-size of patches
ncolsnumber of columns (dx) for mask
nrowsnumber of rows (dy) for mask
Todo:
argument side and corner: still undocumented
Returns:
size of the list
int known_neighbours ( Cimage  v,
unsigned char *  mask,
Pixel  current,
int  i,
int  t,
int  ncols_v,
int  nrows_v,
unsigned short *  mask_neighb,
unsigned char *  curr_patch 
)

Extract the neighbors' mask and values at a given pixel.

Parameters:
vthe image (color image)
maskthe mask for the partially synthesized image v
currentlist of pixels
iindex of the pixel in the current list
tsize of the half-patch
ncolsnumber of columns (dx) v
nrowsnumber of rows (dy) in v
mask_neighboutput array for the neighbors' mask
curr_patchoutput array for the neighbors' values
Returns:
number of known neighbors
int known_neighbours_gray ( Gimage  v,
unsigned char *  mask,
Pixel  current,
int  i,
int  t,
int  ncols_v,
int  nrows_v,
unsigned short *  mask_neighb,
unsigned char *  curr_patch 
)

Extract the neighbors' mask and values at a given pixel.

Idem known_neighbours for gray level images.

See also:
known_neighbours
unsigned char* load_patch_list ( Cimage  w,
int  t 
)

Load the patch of an image into an array.

Facilitate posterior access.

Parameters:
wimage (color image)
thalf-size of patches
Returns:
the patches array extracted from the image
unsigned char* load_patch_list_gray ( Gimage  w,
int  t 
)

Load the patch of an image into an array.

Idem load_patch_list for gray level images.

See also:
load_patch_list
long int random_choose ( Cand_dist  cand_list,
long int  size_list 
)

Randomly choose an element from a list.

The choice is uniform.

Parameters:
cand_lista list of candidates
size_listthe number of candidates
Returns:
the index of a random candidate
void retrieve_coords ( int  p,
int  ncols,
int *  x,
int *  y 
)

Retrieve the coordinates in the example image from a patch index.

Parameters:
ppatch index
ncolsnumber of columns (dx) in the image
xoutput for x position in the image
youtput for y position in the image
float* uniform_weights ( int  patchSize)

Pre-compute uniform weights.

Parameters:
patchSizesize of the patch
Returns:
array of uniform weights, length = patchSize x patchSize
 All Classes Files Functions