/* Isocontour based density Demo (version 0.0.1):
 ----------------------------------------------------
 Copyright (C) 2008 Ajit Rajwade, Arunava Banerjee and Anand Rangarajan
 
 Authors: Ajit Rajwade, Arunava Banerjee and Anand Rangarajan
 Date:    1st April 2008
 
 Contact Information:

 Ajit Rajwade:	avr@cise.ufl.edu
 Arunava Banerjee: arunava@cise.ufl.edu
 Anand Rangarajan: anand@cise.ufl.edu

 Terms:	  
 
 The software is provided under the
 terms of the GNU General Public License (version 2)
*/

We are making part of our code for 2D joint density estimation using
isocontour based methods available publicly. We describe how to run the code
in this document. This code is released under the GNU General Public License
(version 2). The following are the instructions to run the code: 

1) ./make (to compile the code)

2) An executable called isocontour_pdf will be created.

3) Run isocontour_pdf on the command prompt. You will be prompted to enter the
size (height and width) of the two images whose joint density you want to
find. **You MUST specify the correct height and width, else the program may
crash.** For example, the sample images included here - ajit1.txt and
ajit2.txt are both 138x142. 

4) After this, you will be prompted to enter the filenames containing the two
images whose joint density you want to find. The files must be in text format
with one row of the file containing one row of the image with spaces as
delimiters. Enter the names ajit.txt and ajit2.txt. These files exist in the
code directory as well. **You MUST specify the correct names, else the program
may crash. Also the files MUST be in the correct format as described.** You
may also view the files in MATLAB (http://www.mathworks.com) as follows:
A = dlmread ('ajit1.txt');
imshow (A/255);

5) The program upon execution will produce four files iso_joint_pdf_Mbins.txt
(joint density with the isocontour method), simple_joint_pdf_Mbins.txt (joint
density using simple histograms), iso_marginal_pdf_Mbins.txt (marginal density
with isocontours), simple_marginal_pdf_Mbins.txt (marginal density with simple
histograms). Here M stands for the number of bins. The default number is
128. To change the number of bins, edit line number 128 of regim.h,
i.e. #define NL 128.  

6) We have already produced samples outputs for 64, 128, 256 and 512 bins for
you to check. The file names are as mentioned before. 

7) To view the joint density, do the following in MATLAB:
A = dlmread ('iso_joint_pdf_128bins.txt'); surf (A); shading interp; % this
will show the joint density with isocontours 
B = dlmread ('simple_joint_pdf_128bins.txt'); figure(2); surf (B); shading
interp; % this will show the joint density with histograms 

8) To view the marginal density, do:
A = dlmread ('iso_marginal_pdf_128bins.txt'); plot (A); % this will show the
marginal density with isocontours 
B = dlmread ('iso_marginal_pdf_128bins.txt'); figure(2); plot (B); % this will
show the marginal density with histograms 

9) You may repeat this for other images as well. But the images must be
written in text format, and you must specify the correct size of the image
when  you run the code. In our paper, we have shown results on a retinogram
image.  This image has been obtained from the following URL:
http://www.tina-vision.net/ilib.php. For our paper, the image was downsized to
128 x 128 and converted into text format. Then a rotated version of its
negative was created. The respective text files in this directory are ret1.txt
and ret2.txt. They are of size 128 x 128. 

10) Here is a listing of all files in this directory:

* README.txt (this very file, of course :-))
*  Sample image files: ajit1.txt, ajit2.txt, ret1.txt, ret2.txt
* Code: regim.h, entropies.c, im.c, isocontour_pdf.c, isbi.c, joint_density.c, poly.c
* Makefile
* LICENSE file
* Sample outputs:
simple_joint_pdf_64bins.txt
simple_joint_pdf_128bins.txt
simple_joint_pdf_256bins.txt
simple_joint_pdf_512bins.txt
iso_joint_pdf_64bins.txt
iso_joint_pdf_128bins.txt
iso_joint_pdf_256bins.txt
iso_joint_pdf_512bins.txt
simple_marginal_pdf_64bins.txt
simple_marginal_pdf_128bins.txt
simple_marginal_pdf_256bins.txt
simple_marginal_pdf_512bins.txt
iso_marginal_pdf_64bins.txt   
iso_marginal_pdf_128bins.txt  
iso_marginal_pdf_256bins.txt  
iso_marginal_pdf_512bins.txt  



