Efros-Leung
Exemplar-basedtexturesynthesis(Efros-Leung)
|
Sub-functions for texture synthesis. More...
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. |
Sub-functions for texture synthesis.
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.
a | pointer to a candidate |
b | pointer to another candidate |
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.
a | pointer to a pixel |
b | pointer to another pixel |
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.
totalPatchs | number of patches in the dictionary |
t | half-size of the patch |
neighbs_updated | number of known neighbors |
mask_neighb | mask of known neighbors |
patch_list | the list of patches |
curr_patch | the current patch |
tolerance | value of ![]() |
cand_list | output for the distances |
radius_out | threshold for distance (computation stops if reached) |
weights | weights 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.
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.
patch_list | list of patches extracted from the input image |
patch_list_mask | list of mask of patches extracted from the mask of the input image |
curr_patch | current patch |
totalPatchs | number of patches in the patch_list |
t | half-size of the patch |
mask_neighb | mask of the known pixels in the current patch |
neighbs_updated | number of known neighbors |
tolerance | value of ![]() |
cand_list | utput for the candidates (sorted from closest) |
weights | weights used for the distance between patches |
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.
float* gaussian_weights | ( | int | patchSize, |
int | t | ||
) |
Pre-compute Gaussian weights.
patchSize | size of the patch |
t | half-size of the patch (should have patchSize = 2t+1) |
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.
side | |
corner | |
current | output list of pixels |
mask | mask of already filled pixels |
t | half-size of patches |
ncols | number of columns (dx) for mask |
nrows | number of rows (dy) for mask |
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.
v | the image (color image) |
mask | the mask for the partially synthesized image v |
current | list of pixels |
i | index of the pixel in the current list |
t | size of the half-patch |
ncols | number of columns (dx) v |
nrows | number of rows (dy) in v |
mask_neighb | output array for the neighbors' mask |
curr_patch | output array for the neighbors' values |
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.
unsigned char* load_patch_list | ( | Cimage | w, |
int | t | ||
) |
Load the patch of an image into an array.
Facilitate posterior access.
w | image (color image) |
t | half-size of patches |
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.
long int random_choose | ( | Cand_dist | cand_list, |
long int | size_list | ||
) |
Randomly choose an element from a list.
The choice is uniform.
cand_list | a list of candidates |
size_list | the number of candidates |
void retrieve_coords | ( | int | p, |
int | ncols, | ||
int * | x, | ||
int * | y | ||
) |
Retrieve the coordinates in the example image from a patch index.
p | patch index |
ncols | number of columns (dx) in the image |
x | output for x position in the image |
y | output for y position in the image |
float* uniform_weights | ( | int | patchSize | ) |
Pre-compute uniform weights.
patchSize | size of the patch |