efros_freeman
0.1
|
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <fftw3.h>
#include <assert.h>
#include <float.h>
#include "patch_search.h"
#include "random_number.h"
Go to the source code of this file.
Macros | |
#define | MAX_DIST FLT_MAX |
#define | MIN_DIST 1.0 |
#define | MAX_INT 10000000 |
#define | SMOOTH 1 |
Functions | |
static void | cross_correlation_fft2_known (float *img1, fftwl_complex *fft2, long double *cross_corr, size_t nx, size_t ny) |
This function computes the cross-correlation between img1 and img2 using FFT, given the fft of img2 as input. The result is a long double image having the same size (already allocated). | |
void | compute_input_patch_norms (Image src_im, long double *patch_normsH, long double *patch_normsV, long double *patch_normsL, int patch_sz, int overlap_sz) |
Computes the squared norms of each RGB patches of the input according to the 3 possible overlap regions.The computation is done in applying the cross-correlation between the extended mask and the sum over the 3 channels of the squares of the pixel values. | |
static void | compute_distance_to_input_patches (Image src_im, Image out_im, Corner temp, int patch_sz, long double *src_patch_normsH, long double *src_patch_normsV, long double *src_patch_normsL, fftwl_complex *fft_srcR, fftwl_complex *fft_srcG, fftwl_complex *fft_srcB, Image_LD *distances) |
This function computes the squared distance between a given patch and all patches of another image. The squared distance is (implicitly) weighted by a binary mask on the patch domain.It does not appear because pixels that are not yet defined (outside the L-shape corner generally) are set to zero, so that multiplying by the binary mask does nàt change the patch. | |
static void | pick_patch (Image_LD *distances, int h, int w, Corner *patch, float tol) |
void | patch_search (Image src_im, Image out_im, Corner temp, int patch_sz, long double *src_patch_normsH, long double *src_patch_normsV, long double *src_patch_normsL, fftwl_complex *fft_srcR, fftwl_complex *fft_srcG, fftwl_complex *fft_srcB, int h, int w, Corner *patch, float tol) |
This function executes the two steps of the patch search procedure: |
#define MAX_DIST FLT_MAX |
Definition at line 29 of file patch_search.c.
#define MAX_INT 10000000 |
Definition at line 31 of file patch_search.c.
#define MIN_DIST 1.0 |
Definition at line 30 of file patch_search.c.
#define SMOOTH 1 |
Definition at line 32 of file patch_search.c.
|
static |
This function computes the squared distance between a given patch and all patches of another image. The squared distance is (implicitly) weighted by a binary mask on the patch domain.It does not appear because pixels that are not yet defined (outside the L-shape corner generally) are set to zero, so that multiplying by the binary mask does nàt change the patch.
src_im | The input texture sample |
out_im | The currently synthesized texture image (unknown pixels must be set to zero) |
temp | The patch from the output image to compare with those in the texture sample (patch to synthesize) |
patch_sz | The pathc size |
src_patch_normsH,src_patch_normsV,src_patch_normsL | long double arrays corresponding to the norm of input patches for the 3 possible overlap regions |
fft_srcR,fft_srcG,fft_srcB | long double Fourier transforms of the 3 input channels |
distances | Image of distances, WARNING: suppposed to be set to 0 at initialization (result) |
Definition at line 252 of file patch_search.c.
void compute_input_patch_norms | ( | Image | src_im, |
long double * | patch_normsH, | ||
long double * | patch_normsV, | ||
long double * | patch_normsL, | ||
int | patch_sz, | ||
int | overlap_sz | ||
) |
Computes the squared norms of each RGB patches of the input according to the 3 possible overlap regions.The computation is done in applying the cross-correlation between the extended mask and the sum over the 3 channels of the squares of the pixel values.
src_im | input RGB Image |
patch_normsH | long double image for the horizontal overlap (must be allocated) |
patch_normsV | long double image for the vertical overlap (must be allocated) |
patch_normsL | long double image for the L-shape overlap (must be allocated) |
patch_sz | patch size |
overlap_sz | size of the overlap at the edge of the patch |
Definition at line 136 of file patch_search.c.
|
static |
This function computes the cross-correlation between img1 and img2 using FFT, given the fft of img2 as input. The result is a long double image having the same size (already allocated).
Convention for image sizes w_img = nx = width of image : Indexes x or j h_img = ny = height of image : Indexes y or i
img1,img2,two | pointers to float images |
cross_corr | image of the cross-correlation |
nx,ny | image sizes |
Definition at line 56 of file patch_search.c.
void patch_search | ( | Image | src_im, |
Image | out_im, | ||
Corner | temp, | ||
int | patch_sz, | ||
long double * | src_patch_normsH, | ||
long double * | src_patch_normsV, | ||
long double * | src_patch_normsL, | ||
fftwl_complex * | fft_srcR, | ||
fftwl_complex * | fft_srcG, | ||
fftwl_complex * | fft_srcB, | ||
int | h, | ||
int | w, | ||
Corner * | patch, | ||
float | tol | ||
) |
This function executes the two steps of the patch search procedure:
src_im | The input texture sample |
out_im | The currently synthesized texture image (unknown pixels must be set to zero) |
temp | The patch from the output image to compare with those in the texture sample (patch to synthesize) |
patch_sz | The pathc size |
src_patch_normsH,src_patch_normsV,src_patch_normsL | long double arrays corresponding to the norm of input patches for the 3 possible overlap regions |
fft_srcR,fft_srcG,fft_srcB | long double Fourier transforms of the 3 input channels |
h,w | size of the domain of admissible patches |
patch | The position of the picked patch (Corner type) |
tol | The threshold used to select patches from the input image |
Definition at line 413 of file patch_search.c.
This function picks a random patch within all the patches of the source image that verify dist(p, current) < dist_min*(1+tolerance) with dist_min the minimum distance between the current patch and the all the patches from the input image
distances | Image containing the distance between the current patch and the patch of source image (distance has the same size as the input image, but the bottom-right border must be discarded) |
h,w | size of the domain of admissible patches |
patch | The position of the picked patch (Corner type) |
tol | The threshold used to select patches from the input |
Definition at line 338 of file patch_search.c.