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. | |
int | known_neighbours (ImageF w, unsigned char *mask, Pixel current, int i, int t, int larg, int haut, unsigned short *mask_neighb, float *curr_patch) |
Extract the neighbors' mask and values at a given pixel. | |
int | known_neighboursRL (unsigned char *mask, Pixel current, int i, int t, int larg, unsigned short *mask_neighb) |
Extract neighbors on the centered column of a patch. | |
int | known_neighboursUD (unsigned char *mask, Pixel current, int i, int t, int larg, unsigned short *mask_neighb) |
Extract neighbors on the centered row of a patch. | |
int | find_candidatesU (ImageF v, float *weights_pca, float *dictionary, Pixel current, int i, int totalPatches, unsigned short *mask_neighb, int total_neighb, int t, float *WU, float *mean, int m, int n, float tolerance, Cand_dist cand_list) |
Get the set of candidates for a given pixel to be filled. | |
int | find_candidatesD (ImageF v, float *weights_pca, float *dictionary, Pixel current, int i, int totalPatches, unsigned short *mask_neighb, int total_neighb, int t, float *WU, float *mean, int m, int n, float tolerance, Cand_dist cand_list) |
Get the set of candidates for a given pixel to be filled. | |
int | find_candidatesR (ImageF v, float *weights_pca, float *dictionary, Pixel current, int i, int totalPatches, unsigned short *mask_neighb, int total_neighb, int t, float *WU, float *mean, int m, int n, float tolerance, Cand_dist cand_list) |
Get the set of candidates for a given pixel to be filled. | |
int | find_candidatesL (ImageF v, float *weights_pca, float *dictionary, Pixel current, int i, int totalPatches, unsigned short *mask_neighb, int total_neighb, int t, float *WU, float *mean, int m, int n, float tolerance, Cand_dist cand_list) |
Get the set of candidates for a given pixel to be filled. | |
int | find_candidates (float *patch_list, float *patch_list_mask, float *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. | |
float * | load_patch_list (ImageF w, int t) |
Load the patch of an image into an array. | |
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. | |
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 larg, int tx, int ty, int *x, int *y) |
Retrieve the coordinates in the example image from a patch index. | |
int | compute_distances_pca (int totalPatches, int t, float tolerance, int total_neighb, unsigned short *mask_neighb, float *patch, float *patch_pca, float *dictionary, int n, Cand_dist cand_list, float *radius_out) |
Compute (using the PCA) the distances between a patch and all the others ones. | |
int | compute_distances (int totalPatchs, int t, int voisins_updated, unsigned short *mask_neighb, float *patch_list, float *patch_list_mask, float *curr_patch, float tolerance, Cand_dist cand_list, float *radius_out, float *weights) |
Compute (without PCA) the distances between a patch and all the others ones. | |
float * | gaussian_weights (int patchSize, int t) |
Pre-compute Gaussian weights. | |
float * | gaussian_weights_pca (int patchSize, int t) |
Pre-compute the root square of Gaussian weights. | |
float * | uniform_weights_pca (int patchSize) |
Pre-compute uniform weights. |
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, | ||
float * | patch_list, | ||
float * | patch_list_mask, | ||
float * | curr_patch, | ||
float | tolerance, | ||
Cand_dist | cand_list, | ||
float * | radius_out, | ||
float * | weights | ||
) |
Compute (without PCA) 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_pca | ( | int | totalPatches, |
int | t, | ||
float | tolerance, | ||
int | total_neighb, | ||
unsigned short * | mask_neighb, | ||
float * | patch, | ||
float * | patch_pca, | ||
float * | dictionary, | ||
int | n, | ||
Cand_dist | cand_list, | ||
float * | radius_out | ||
) |
Compute (using the PCA) the distances between a patch and all the others ones.
Each considered element has two parts: the first part corresponds to the central part of the patch (central column or central row) of size (2t + 1); the second part corresponds to the PCA projection of one of four patch subregions (up, down, right or left), it is of size equal to the PCA chosen dimensions n.
totalPatches | number of patches in the dictionary |
t | half-size of the patch |
tolerance | value of ![]() |
total_neighb | number of known neighbors |
mask_neighb | mask of known neighbors |
patch | |
patch_pca | the current patch coordinates in the PCA basis |
dictionary | dictionary of patches in the PCA basis |
n | number of dimension kept by PCA |
cand_list | output for the distances |
radius_out | threshold for distance (computation stops if reached) |
int find_candidates | ( | float * | patch_list, |
float * | patch_list_mask, | ||
float * | 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.
Don't use the PCA. The dictionary is simply the patch list.
int find_candidatesD | ( | ImageF | v, |
float * | weights_pca, | ||
float * | dictionary, | ||
Pixel | current, | ||
int | i, | ||
int | totalPatches, | ||
unsigned short * | mask_neighb, | ||
int | total_neighb, | ||
int | t, | ||
float * | WU, | ||
float * | mean, | ||
int | m, | ||
int | n, | ||
float | tolerance, | ||
Cand_dist | cand_list | ||
) |
Get the set of candidates for a given pixel to be filled.
Only for a patch with a known down part.
int find_candidatesL | ( | ImageF | v, |
float * | weights_pca, | ||
float * | dictionary, | ||
Pixel | current, | ||
int | i, | ||
int | totalPatches, | ||
unsigned short * | mask_neighb, | ||
int | total_neighb, | ||
int | t, | ||
float * | WU, | ||
float * | mean, | ||
int | m, | ||
int | n, | ||
float | tolerance, | ||
Cand_dist | cand_list | ||
) |
Get the set of candidates for a given pixel to be filled.
Only for a patch with a known left part.
int find_candidatesR | ( | ImageF | v, |
float * | weights_pca, | ||
float * | dictionary, | ||
Pixel | current, | ||
int | i, | ||
int | totalPatches, | ||
unsigned short * | mask_neighb, | ||
int | total_neighb, | ||
int | t, | ||
float * | WU, | ||
float * | mean, | ||
int | m, | ||
int | n, | ||
float | tolerance, | ||
Cand_dist | cand_list | ||
) |
Get the set of candidates for a given pixel to be filled.
Only for a patch with a known right part.
int find_candidatesU | ( | ImageF | v, |
float * | weights_pca, | ||
float * | dictionary, | ||
Pixel | current, | ||
int | i, | ||
int | totalPatches, | ||
unsigned short * | mask_neighb, | ||
int | total_neighb, | ||
int | t, | ||
float * | WU, | ||
float * | mean, | ||
int | m, | ||
int | n, | ||
float | tolerance, | ||
Cand_dist | cand_list | ||
) |
Get the set of candidates for a given pixel to be filled.
Only for a patch with a known upper-part.
The candidate pixels for a pixel
is the set:
where
and the distance
is computed on the known part of the patches centered at
and
.
v | the example image |
weights_pca | weights used for the distance between patches |
dictionary | dictionary of patches extracted from v |
current | list of pixels |
i | index of the current pixel ![]() |
totalPatches | number of patches in the dictionary |
mask_neighb | mask of the known pixels in the current patch |
total_neighb | number of known neighbors |
t | half-size of the patch |
mean | mean vector for patches dictionary |
WU | projection axis for the patches |
m | dimension of the patch |
n | number of dimension kept by PCA |
tolerance | value of ![]() |
cand_list | utput for the candidates (sorted from closest) |
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) |
float* gaussian_weights_pca | ( | int | patchSize, |
int | t | ||
) |
Pre-compute the root square of 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 | ( | ImageF | v, |
unsigned char * | mask, | ||
Pixel | current, | ||
int | i, | ||
int | t, | ||
int | ncols, | ||
int | nrows, | ||
unsigned short * | mask_neighb, | ||
float * | curr_patch | ||
) |
Extract the neighbors' mask and values at a given pixel.
v | the 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_neighboursRL | ( | unsigned char * | mask, |
Pixel | current, | ||
int | i, | ||
int | t, | ||
int | ncols, | ||
unsigned short * | mask_neighb | ||
) |
Extract neighbors on the centered column of a patch.
int known_neighboursUD | ( | unsigned char * | mask, |
Pixel | current, | ||
int | i, | ||
int | t, | ||
int | ncols, | ||
unsigned short * | mask_neighb | ||
) |
Extract neighbors on the centered row of a patch.
float* load_patch_list | ( | ImageF | w, |
int | t | ||
) |
Load the patch of an image into an array.
Facilitate posterior access.
w | image |
t | half-size of patches |
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 | tx, | ||
int | ty, | ||
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 |
t | half-size of the patch |
x | output for x position in the image |
y | output for y position in the image |
float* uniform_weights_pca | ( | int | patchSize | ) |
Pre-compute uniform weights.
patchSize | size of the patch |