**Setup and Compilation**

Un-tar the distribution in a local directory, `cd` to it, start MATLAB and call `init` to set up paths. Call `compileFF` and `compilePI` to compile the libSVM executables for the camera calibration code and the MEX functions for the probabilistic inverse code respectively. You only need to call the compile scripts once, but you must call `init` everytime you start up MATLAB.

$ tar xzvf derender.v1.0.tgz $ cd derender $ matlab >> init >> compileFF >> compilePI

**Calibrating Camera Tone-maps**

Use the function `CameraFit` to estimate a camera's tone-map using a training set of RAW/JPEG pairs. This function is called with three parameters:

>> CameraFit(x,y,'traindata/mycamera');Here,

>> ls traindata/mycamera* traindata/mycamera.c1 traindata/mycamera_T.mat traindata/mycamera.c2 traindata/mycamera_stats.mat traindata/mycamera.c3Here, the

Note that `CameraFit` assumes that JPEG values are integers in the `[0,255]` range and that RAW values lie between `[0,1]`, which is normally the case for values extracted from a RAW camera. However, when calibrating JPEG-only cameras with a RAW proxy, it is sometimes necessary to scale the proxy's original RAW values, and in these cases, the camera data files will contain a variable `nfact` which should be passed as an optional fourth parameter to `CameraFit`. We also provide a utility function `selSubset` (see `help selSubset`) to select subsets of illuminants and exposures, as described in the paper, from the captured data set for each camera.

Use the function `Render` to apply the learned camera tone-map to a novel set of RAW values and predict the camera's JPEG outputs:

>> ynew = Render(xnew,'traindata/mycamera');

**Computing Probabilistic Inverse**

Before computing the probabilistic inverse distributions for tone-mapped JPEG values from a given camera, you need to call the functions `InvertBase` and `InvertBaseQ`. These functions pre-compute and store data structures that will be used for the numerical integration required in the inverse computation step.

>> InvertBase('traindata/mycamera'); >> InvertBaseQ('traindata/mycamera');Here, the arguments to both functions is the

Now, given a set of JPEG values output from a given camera, call the function `invJ` to compute the inverse distributions for the corresponding RAW values as:

>> [mu,cv] = invJ(y,'traindata/mycamera');Here,