
Texture synthesis with patch optimal transport
 B. Galerne, A. Leclaire, J. Rabin (c) 2018

Determinantal patch processes for texture synthesis.
 C. Launay, A. Leclaire (c) 2019

*** This archive contains Matlab code related to the papers

"A Texture Synthesis Model Based on Semi-discrete Optimal Transport in Patch Space"
(Bruno Galerne, Arthur Leclaire, Julien Rabin), 
SIAM Journal on Imaging Sciences, vol. 11, no. 4, pp. 2456-2493, 2018.
Hal preprint no 01726443 available at
https://hal.archives-ouvertes.fr/hal-01726443

"Determinantal Patch Processes for Texture Synthesis"
(Claire Launay, Arthur Leclaire),
Actes du GRETSI, 2019.
Hal preprint no 02088725 available at
https://hal.archives-ouvertes.fr/hal-02088725

*** The main files are:
- texto_estimate_dpp.m  : function to estimate the texture model
- texto_synthesize.m , texto_synthesize_cuda.m : functions to sample the texture model
- texto_test_dpp.m : script file (for batch processing)
- multiscale_texsynth_dpatchp.m : script file for detailed experiments

*** Example usage:

	>> im0 = im2double(imread('textures/ground103_small.png'));
  	>> model = texto_estimate_dpp(im0,4,3,4);  % 4 scales, patches 3x3, 4 Gaussian components at each scale
  	>> synth = texto_synthesize_dpp(model,512,512); % output of size 512x512

You can further test these functions by executing the scripts texto_test_dpp.m .

*** Pre-estimated textures

For certain textures, pre-estimated models are available in the folder models/ .
To skip the "estimation" part, you can set doestimation = 0 in the script texto_test_dpp.m .

*** Accelerated synthesis using CUDA

  This archive contains functions that can perform texture synthesis directly on the GPU.
  For that, you need to compile mex files using the CUDA compiler: in the Matlab console, you should run

	>> mexcuda patch_transport.cu
	>> mexcuda patch_transport_upsample.cu

  Prior to that, the mexcuda compiler should be correctly configured according to the version of the CUDA compiler installed on your system.

  Then, you may use the function texto_synthesize_cuda instead of texto_synthesize:

	>> synth = texto_synthesize_cuda(model,512,512);

  Alternately you can set use_cuda = 1 in the script texto_test_dpp.m .
