This package contains a matlab implementation of the user assisted 
transparency separation described in the paper:
A. Levin and Y. Weiss. "User Assisted Separation of Reflections from a 
Single Image Using a Sparsity Prior". 
Proc. of the European Conference on Computer Vision (ECCV), Prague, 
May 2004. 

Usage of this code is free for research purposes only. 
Please refer to the above publication if you use the program.

Copyrights: The Hebrew University of Jerusalem, 2004.
All rights reserved.

Written by Anat Levin.
Please address comments/suggestions/bugs to: alevin@cs.huji.ac.il
------------------------------------------------------------------------



Optimization:
------------

2 optimization options are provided:
1) Calling the LOQO optimization package. To use this optimizer, you
   must buy, download and install LOQO from : http://www.princeton.edu/~rvdb/
   This solver is based on a global inertia-point method implementation.

2) Iterative reweighted least squares optimization- solving sequentially L2 
   optimization problems, such that in each step the equations are reweighted 
   according to the derivative of the L1 cost.
   This is a little slower then LOQO, but does not require buying and installing 
   a second package. 



Usage:
[I1,I2]=sepRefLOQO(I,xf,yf,xb,yb);
or
[I1,I2]=sepRefItrLS(I,xf,yf,xb,yb,iI);
Where:
    I - input (gray levels) superposition image.
    xf,yf- coordinates of labeled foreground gradients.
    xb,yb- coordinates of labeled background gradients.
    iI- (optional) initial guess. If no guess is provided, 
                   I is used as initial guess. 
    I1,I2- output layers.




GUI:
---
A GUI for labeling points is provided. To use it, addpath('gui'), and call 'sepRefGUI';
Superposition images used in our paper are provided in the subdirectory 
imgs. The resulting decomposition (optimized using LOQO) and the user 
labeled points (mat files) are provided as well. 


GUI Options:

Load/Save:

Load Image- a superposition image.
Load Data- load data saved using the save option. 
Save- save a mat file containing the input superposition image, current 
      decomposition and labeled points. This data can be loaded later 
      using "Load Data". The data is saved in a file 
      superposition_image_name.mat.
      The current decomposition layers are written as:
      superposition_image_name_L1.bmp and superposition_image_name_L2.bmp



Mark:

Points can be marked in red- classified as foreground gradients and in
blue- classified as background gradients.
Two labeling methods are available.
1) Labeling points (select "Mark blue points"/"Mark red points").
   Right click points sequentially. Click the left mouse button to stop.
   You can set the width of the marked point using "set the brush size".  
2) Labeling polygons (select "Mark blue polygons"/"Mark red polygons").
   In this option, the user marks only the frame of a polygon, while all 
   points inside it are considered marked.
   Click points on the polygon frame sequentially using the right mouse 
   button. Click the middle button to indicate that marking the current 
   polygon is done. Click the left button to stop marking polygons. 
Redisplaying- refresh the marked points display.
ReDisplay Marked- only polygon frames are drowned.
ReDisplay All- points "within" the polygons are displayed as well.


Evaluate Layers:

Solve for the layers, given the current labels. 
The user can choose between a LOQO optimization and an iterative 
reweighted least squares optimization.
 

