diff --git a/build/1.png b/build/1.png
new file mode 100644
index 00000000..e674b8b2
Binary files /dev/null and b/build/1.png differ
diff --git a/build/2.png b/build/2.png
new file mode 100644
index 00000000..5e0d7684
Binary files /dev/null and b/build/2.png differ
diff --git a/build/Courses Aligned.html b/build/Courses Aligned.html
new file mode 100644
index 00000000..fd560c00
--- /dev/null
+++ b/build/Courses Aligned.html
@@ -0,0 +1,227 @@
+
+
+
+
+
+
+
+
+
+
+ Welcome to Virtual Labs - A MHRD Govt of india Initiative
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Image Processing Lab
+
+This virtual lab is aligned with an introductory course on Image processing, which is usually offered as a first level elective in many curricula.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/Feedback.html b/build/Feedback.html
new file mode 100644
index 00000000..071752e6
--- /dev/null
+++ b/build/Feedback.html
@@ -0,0 +1,222 @@
+
+
+
+
+
+
+
+
+
+
+ Welcome to Virtual Labs - A MHRD Govt of india Initiative
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/Introduction.html b/build/Introduction.html
new file mode 100644
index 00000000..12b0e2ff
--- /dev/null
+++ b/build/Introduction.html
@@ -0,0 +1,236 @@
+
+
+
+
+
+
+
+
+
+
+ Welcome to Virtual Labs - A MHRD Govt of india Initiative
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Image Processing Lab
+
+Welcome to the digital image processing virtual lab. The primary objective of this virtual lab is to supplement an undergraduate level course on image processing and enable students to understand the subject better. The lab consists of a diverse set of experiments with objective, theory, assessment, references and interactive examples which are designed to improve the clarity in understanding of the basic concepts. It is important that the student goes through the objectives and the underlying theory before carrying out the experiments to get maximum benefit. The lab is intended to help in clarifying concepts. It is not intented for learning how to write code to do image processing
+
+
+The primary references (textbook) for the topics covered by the experiments are:
+1. Digital Image Processing (3rd Edition), by Rafael C. Gonzalez and Richard E. Woods.
+2. Fundamentals of digital image processing, by Anil K. Jain.
+
+
Before you start any of the experiments, make sure you read the notes below.
+1. Each link on the right takes you to a set of experiments that is related to a specific topic. The experiments are designed to expose you to certain concepts. You are encouraged to carry out variants of the suggested experiments and learn from them.
+2. Please make sure that you read the background material and experiment procedure before carrying out the experiments. Trying out the experiments before reading does not hurt, but having the background will help you understand the results better.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/List of experiments.html b/build/List of experiments.html
new file mode 100644
index 00000000..91024dd3
--- /dev/null
+++ b/build/List of experiments.html
@@ -0,0 +1,269 @@
+
+
+
+
+
+
+
+
+
+
+ Welcome to Virtual Labs - A MHRD Govt of india Initiative
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Image Processing Lab
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/Prerequisites.html b/build/Prerequisites.html
new file mode 100644
index 00000000..b9812ff8
--- /dev/null
+++ b/build/Prerequisites.html
@@ -0,0 +1,230 @@
+
+
+
+
+
+
+
+
+
+
+ Welcome to Virtual Labs - A MHRD Govt of india Initiative
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Image Processing Lab
+
+
+Linear Algebra.
+Signals and Systems
+ Computer Programming
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/Target Audience.html b/build/Target Audience.html
new file mode 100644
index 00000000..b23e6c34
--- /dev/null
+++ b/build/Target Audience.html
@@ -0,0 +1,228 @@
+
+
+
+
+
+
+
+
+
+
+ Welcome to Virtual Labs - A MHRD Govt of india Initiative
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Image Processing Lab
+
+The experiments provides an introduction to image processing to students at third year undergraduate or first year postgradute level.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/affine.php b/build/affine.php
new file mode 100644
index 00000000..f4d3603a
--- /dev/null
+++ b/build/affine.php
@@ -0,0 +1,850 @@
+
+
+
+
+
+
+
+
+
+
+Virtual Lab in Image Processing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
" alt="picture" width="140px" height="140px"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Expected Output Image Input Image
+
+ Output size
+
+
+ 300 x 300
+
+ __ x __
+
+
+
+
+
+ View Full Size Image
+
+
+
+
+
+
+
+
Affine Transformation
+
+
+ Select Image";} ?>
+
Reset
+
Run
+
Return to Piping
+
+
+ Single Choice
+ Multiple Choice
+
+
+
+
+
+
+
+
+ Translation
+
X-Translation (Pixels)
+
+
+
+
+
+
Y-Translation (Pixels)
+
+
+
+
+
+
Change Order of Operations
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/affine/assessment.html b/build/affine/assessment.html
new file mode 100644
index 00000000..8cc4de83
--- /dev/null
+++ b/build/affine/assessment.html
@@ -0,0 +1,14 @@
+
+
+ 1. Will the output of a image remain same if apply rotation followed by translation or translation followed by rotation?
+
+
+
+ 2. Can rotation be reversed to recover original image?
+
+
+
+ 3. How to apply shear in one direction ? For instance, in x direction
+
+
+
diff --git a/build/affine/eqn.jpg b/build/affine/eqn.jpg
new file mode 100644
index 00000000..0e5ee722
Binary files /dev/null and b/build/affine/eqn.jpg differ
diff --git a/build/affine/images/image012.jpg b/build/affine/images/image012.jpg
new file mode 100644
index 00000000..7aeb4ffc
Binary files /dev/null and b/build/affine/images/image012.jpg differ
diff --git a/build/affine/images/image012.png b/build/affine/images/image012.png
new file mode 100644
index 00000000..08163f41
Binary files /dev/null and b/build/affine/images/image012.png differ
diff --git a/build/affine/images/image013.jpg b/build/affine/images/image013.jpg
new file mode 100644
index 00000000..838da31e
Binary files /dev/null and b/build/affine/images/image013.jpg differ
diff --git a/build/affine/images/image013.png b/build/affine/images/image013.png
new file mode 100644
index 00000000..b4a3f34d
Binary files /dev/null and b/build/affine/images/image013.png differ
diff --git a/build/affine/images/image014.jpg b/build/affine/images/image014.jpg
new file mode 100644
index 00000000..2085b245
Binary files /dev/null and b/build/affine/images/image014.jpg differ
diff --git a/build/affine/images/image014.png b/build/affine/images/image014.png
new file mode 100644
index 00000000..47f8a940
Binary files /dev/null and b/build/affine/images/image014.png differ
diff --git a/build/affine/images/image015.jpg b/build/affine/images/image015.jpg
new file mode 100644
index 00000000..385e1917
Binary files /dev/null and b/build/affine/images/image015.jpg differ
diff --git a/build/affine/images/image015.png b/build/affine/images/image015.png
new file mode 100644
index 00000000..0e9f3bab
Binary files /dev/null and b/build/affine/images/image015.png differ
diff --git a/build/affine/images/image016.jpg b/build/affine/images/image016.jpg
new file mode 100644
index 00000000..66a0dad3
Binary files /dev/null and b/build/affine/images/image016.jpg differ
diff --git a/build/affine/images/image016.png b/build/affine/images/image016.png
new file mode 100644
index 00000000..810ed8da
Binary files /dev/null and b/build/affine/images/image016.png differ
diff --git a/build/affine/images/image017.jpg b/build/affine/images/image017.jpg
new file mode 100644
index 00000000..f7e69f72
Binary files /dev/null and b/build/affine/images/image017.jpg differ
diff --git a/build/affine/images/image017.png b/build/affine/images/image017.png
new file mode 100644
index 00000000..c3af5df0
Binary files /dev/null and b/build/affine/images/image017.png differ
diff --git a/build/affine/images/image018.jpg b/build/affine/images/image018.jpg
new file mode 100644
index 00000000..d7e25ecc
Binary files /dev/null and b/build/affine/images/image018.jpg differ
diff --git a/build/affine/images/image018.png b/build/affine/images/image018.png
new file mode 100644
index 00000000..4f57633c
Binary files /dev/null and b/build/affine/images/image018.png differ
diff --git a/build/affine/images/image019.jpg b/build/affine/images/image019.jpg
new file mode 100644
index 00000000..e785405d
Binary files /dev/null and b/build/affine/images/image019.jpg differ
diff --git a/build/affine/images/image019.png b/build/affine/images/image019.png
new file mode 100644
index 00000000..8867095c
Binary files /dev/null and b/build/affine/images/image019.png differ
diff --git a/build/affine/images/image020.jpg b/build/affine/images/image020.jpg
new file mode 100644
index 00000000..ee5b88dd
Binary files /dev/null and b/build/affine/images/image020.jpg differ
diff --git a/build/affine/images/image020.png b/build/affine/images/image020.png
new file mode 100644
index 00000000..c1d58286
Binary files /dev/null and b/build/affine/images/image020.png differ
diff --git a/build/affine/images/image021.jpg b/build/affine/images/image021.jpg
new file mode 100644
index 00000000..edc7d8fa
Binary files /dev/null and b/build/affine/images/image021.jpg differ
diff --git a/build/affine/images/image021.png b/build/affine/images/image021.png
new file mode 100644
index 00000000..528ef81b
Binary files /dev/null and b/build/affine/images/image021.png differ
diff --git a/build/affine/images/image022.jpg b/build/affine/images/image022.jpg
new file mode 100644
index 00000000..844819cd
Binary files /dev/null and b/build/affine/images/image022.jpg differ
diff --git a/build/affine/images/image022.png b/build/affine/images/image022.png
new file mode 100644
index 00000000..f49da8b0
Binary files /dev/null and b/build/affine/images/image022.png differ
diff --git a/build/affine/images/image023.jpg b/build/affine/images/image023.jpg
new file mode 100644
index 00000000..9da3c0f6
Binary files /dev/null and b/build/affine/images/image023.jpg differ
diff --git a/build/affine/images/image023.png b/build/affine/images/image023.png
new file mode 100644
index 00000000..bfc144a4
Binary files /dev/null and b/build/affine/images/image023.png differ
diff --git a/build/affine/images/image024.jpg b/build/affine/images/image024.jpg
new file mode 100644
index 00000000..34f4c0ec
Binary files /dev/null and b/build/affine/images/image024.jpg differ
diff --git a/build/affine/images/image025.jpg b/build/affine/images/image025.jpg
new file mode 100644
index 00000000..0e5ee722
Binary files /dev/null and b/build/affine/images/image025.jpg differ
diff --git a/build/affine/images/image025.png b/build/affine/images/image025.png
new file mode 100644
index 00000000..6aac130b
Binary files /dev/null and b/build/affine/images/image025.png differ
diff --git a/build/affine/intro.html b/build/affine/intro.html
new file mode 100644
index 00000000..28a30c53
--- /dev/null
+++ b/build/affine/intro.html
@@ -0,0 +1,14 @@
+Affine Transformation - Introduction
+
+
+ In cricket, to decide if a batsman has been run out, the standard practice is to select the part of the image around the stumps and zoom on it so that the third umpire can take a decision. The region of interest is the crease. If one were to automate this process, several steps are required. This will include identifying the stump region and rotating the image so that the crease is at the right orientation and scale to enable an accurate judgement.
+
+
+
+ The set of transformations that will possibly be required are translation (to place the crease within the view window), rotation (to orient the crease such that the bat is seen to the left or right of it) and finally scaling so the bat position relative to the crease can be determined accurately.
+
+
+ The set of transformations namely, translation, rotation, scale and shear (stretching in one direction) forms the affine class of transformations. In this experiment, we will study how the first three types of transformations are effected on a given image.
+
+
+
diff --git a/build/affine/objective.html b/build/affine/objective.html
new file mode 100644
index 00000000..bd9e062b
--- /dev/null
+++ b/build/affine/objective.html
@@ -0,0 +1,23 @@
+Affine Transformation - Objectives
+
+To learn basic image transformation
+
+Translation
+Rotation
+Scaling
+
+
+To learn the role of interpolation operation
+
+Bi-linear
+Bi-cubic
+Nearest neighbor
+
+
+To learn the effect of multiple transformations
+
+Significance of order in which one carried out
+
+
+
+
diff --git a/build/affine/procedure.html b/build/affine/procedure.html
new file mode 100644
index 00000000..1156b54a
--- /dev/null
+++ b/build/affine/procedure.html
@@ -0,0 +1,45 @@
+Affine Transformation - Procedure
+
+The experiments are designed in two parts:
+
+Single transformation among three is allowed
+Multiple transformations are allowed
+Single Transformation
+
+Select image from the mosaic using .select
+ image. option
+Selected region of the image to load it in the
+ input image panel
+Select appropriate parameters to see the effect
+Select .single choice. option
+Only one transformation is available at a time
+Select one choice among three choices: scaling, rotation and
+ translation
+For rotation and scaling, select interpolation function to see the
+ difference in the output. The default choice for interpolation function is
+ nearest neighbor.
+Select .run. option to see the output under the selected
+ parameters
+To view the full sized output image, select .view full size
+ image.
+Panel below input and output image panel shows the intermediate results
+ obtained during operation. Click on the thumbnails to view images in full
+ size.
+Multiple Transformations
+
+Select .multiple choice. option
+Order selection panel will be pop out. Select the
+ order in which you want to perform the operation. The order sequence is
+ displayed in front of each transformation choice. During operation, edit
+ option is provided below in the left panel to change the selected order of
+ operation.
+All three transformations are allowed under this choice
+ The interpolation function is kept fixed i.e. nearest neighbor for this
+ operation
+Select appropriate parameters
+In case you do not want any particular
+ transformation. Do not change parameter of the respective choice
+Select the .run. option to perform operations
+Output panel and intermediate results panel will display the obtained
+ output.
+
diff --git a/build/affine/quiz.php b/build/affine/quiz.php
new file mode 100644
index 00000000..d547859c
--- /dev/null
+++ b/build/affine/quiz.php
@@ -0,0 +1,33 @@
+i) scaling->rotation-> translation ii) scaling ->translation->rotation iii) translation-> rotation-> scaling iv) rotation ->scaling ->translation ";
+$option[1][4]="i and ii";
+$option[2][4]="iii and iv";
+$option[3][4]="i and iv";
+$option[4][4]="None of the above";
+
+$exp_name="AFFINE TRANSFORMATION";
+
+$correct="2 2 1 1";
+
+$no_ques=4;
+
+?>
+
+
+
diff --git a/build/affine/references.html b/build/affine/references.html
new file mode 100644
index 00000000..b3e0004b
--- /dev/null
+++ b/build/affine/references.html
@@ -0,0 +1,42 @@
+Affine Transformation - References
+Specific web references:
+
+Affine
+ Transformation http://homepages.inf.ed.ac.uk/rbf/HIPR2/affine.htm
+ Affine
+ Transformations http://www.geom.uiuc.edu/docs/reference/CRC-formulas/node15.html
+Affine
+ Transformations http://xahlee.org/complex/affine/affine.html
+Affine Transformation (and
+ cousins) http://www.leptonica.com/affine.html
+Affine
+ Transformation http://c2.com/cgi/wiki?AffineTransformation
+Affine http://www.roborealm.com/help/Affine.php
+Image Affine
+ Trasnformation http://cvlab.epfl.ch/~jpilet/image_science/serie2/
+ Basic web references
+
+Lecture Notes in Digital Image
+ Processing http://eeweb.poly.edu/~onur/lectures/lectures.html
+Advanced Image Processing
+ Lab http://www.eng.tau.ac.il/~yaro/lectnotes/
+Digital Image
+ Processing http://www.cs.nmt.edu/~ip/lectures.html
+Books:
+
+A.K.Jain, Fundamentals of Digital Image Processing,
+ Prentice-Hall, 1989.
+A.M.Tekalp, Digital Video Processing, Prentice-Hall, 1995.
+A.Bovik, Handbook of Image Video Processing, Academic Press, 2000.
+H.Stark and J.W.Woods, Probability, Random Processes, and Estimation
+ Theory for Engineers, Prentice-Hall, 1994.
+ A.M.Yaglom, Correlation Theory of Stationary and Related Random Functions
+ I: Basic Results, Springer-Verlag, 1987.
+L.Breiman, Probability, SIAM, 1992.
+H.V.Poor, An Introduction to Signal Detection and Estimation, 2nd Ed.,
+ Springer-Verlag, 1994.
+A.Gersho and R.M.Gray, Vector Quantization and Signal Compression, Kluwer,
+ 1992
+ M.Vetterli and J.Kovacevic, Wavelets and Subband Coding, Prentice-Hall,
+ 1995.
+
diff --git a/build/affine/theory.html b/build/affine/theory.html
new file mode 100644
index 00000000..dc23970a
--- /dev/null
+++ b/build/affine/theory.html
@@ -0,0 +1,135 @@
+Affine Transformation - Theory
+
+An affine transformation is a geometrical transformation which moves points
+ in space such that points which were lying on a line remain so after the
+ transformation.
+
+Given a point which is a point location [x, y]T , transformed
+ location after translation, rotation and scaling can be as follows.
+
+
+
+
+
+
+ Translation
+
+
+
+
+
+
+
+
+
+
+
+
+ Rotation (θ)
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Scaling
+
+
+
+
+
+
+
+
+
+
+
+
+ To geometrically transform an image, the result we seek is an image with
+ transformed coordinates. The result of applying the transformation function
+ is generally not an integer particularly in case of rotation and
+ scaling. This poses a problem since the image is defined on a grid
+ (coordnates have to be integer valued). The solution is interpolation.
n
+ implementation, image rotation is done as follows. Given I[m,n] to find a
+ transformed image X[m., n.] where [m., n.]= A x [m, n] + B according to the
+ above given equation:
+
+Create a dummy array X[m., n.].
+ Find the locations [m, n] in I that correspond to locations [., n.] in
+ the image X by applying the inverse transformation. I.e. A-1
+ ([m., n.]-B) = [m, n]. This can result in non-integer locations.
+ Find the pixel value at these source locations. If it is non-integer
+ valued locations, use an interpolation function.
+ Example: Consider A to be rotation by 30 degrees. Let us take the
+ location [12, 13] in X and find its corresponding location in I. This will
+ be [3.89 17.26]. To determine the value of I at this location, we can use
+ the known values closest to this location
+
+
+
+
+
+
+Option 1: Round off the [m, n] and take the pixel value at that
+ location. This is known as the nearest neighbour interpolation method.
+
+Option 2: Take the weighted average of the 4 neighbouring
+ pixels. The weights are the distance between the desired location and that
+ of the neighbours. The common form is the bilinear form which is a second
+ order approximation and equivalent to fitting a straight line pairs of
+ neighbouring pixels.
+
+Option 3: Take a nonlinear combination of the 16 neighbouring
+ pixels. The standard is to use a third order approximation and fit two
+ piecewise cubic polynomials on to the neighbouring pixels. Hence the
+ interpolation function is called the bicubic interpolation method.
diff --git a/build/allexec.sh b/build/allexec.sh
new file mode 100644
index 00000000..5bac0a7f
--- /dev/null
+++ b/build/allexec.sh
@@ -0,0 +1,21 @@
+export OPENCV_INC=/usr/include/opencv
+export OPENCV_LIB=/usr/lib/
+export OPENCV_LIB_OPTS="-lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann"
+
+sudo apt-get update
+sudo apt-get install -y gcc
+sudo apt-get update
+gcc -I$OPENCV_INC codes/latest_affine.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/affine.out
+gcc -I$OPENCV_INC codes/im_arith.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/arith.out
+gcc -I$OPENCV_INC codes/im_dist.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/dist.out
+gcc -I$OPENCV_INC codes/im_fourier.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/fourier.out
+gcc -I$OPENCV_INC codes/im_hist.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/hist.out
+gcc -I$OPENCV_INC codes/im_morphology.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/morpho.out
+gcc -I$OPENCV_INC codes/im_nbrhood.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/neigh.out
+gcc -I$OPENCV_INC codes/im_path.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/path.out
+gcc -I$OPENCV_INC codes/im_point.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/point.out
+gcc -I$OPENCV_INC codes/im_segment.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/segment.out
+gcc -I$OPENCV_INC codes/im_colour.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/colour.out
+gcc -I$OPENCV_INC codes/im_colourLin.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/colour2.out
+gcc -I$OPENCV_INC codes/im_colhist.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/colour3.out
+gcc -I$OPENCV_INC codes/im_colhist.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/colhist.out
diff --git a/build/analyticstracking.php b/build/analyticstracking.php
new file mode 100644
index 00000000..b804dc57
--- /dev/null
+++ b/build/analyticstracking.php
@@ -0,0 +1,12 @@
+
+
+
\ No newline at end of file
diff --git a/build/arith.php b/build/arith.php
new file mode 100644
index 00000000..b31e2d13
--- /dev/null
+++ b/build/arith.php
@@ -0,0 +1,467 @@
+
+
+
+
+
+
+
+
+
+
+Virtual Lab in Image Processing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
" alt="picture" width="140px" height="140px"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Input size
+
+ Output size
+
+
+ 300 x 300
+
+ ____ x ____
+
+
+
+
+
+
+
+
+
Image Arithmetic
+
+
+
+ Select Image";} ?>
+
Reset
+
Run
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/arith/add1.png b/build/arith/add1.png
new file mode 100644
index 00000000..09dc3fe2
Binary files /dev/null and b/build/arith/add1.png differ
diff --git a/build/arith/add2.png b/build/arith/add2.png
new file mode 100644
index 00000000..92c2a7e2
Binary files /dev/null and b/build/arith/add2.png differ
diff --git a/build/arith/add3.png b/build/arith/add3.png
new file mode 100644
index 00000000..542944c5
Binary files /dev/null and b/build/arith/add3.png differ
diff --git a/build/arith/intro.html b/build/arith/intro.html
new file mode 100644
index 00000000..44b16dc7
--- /dev/null
+++ b/build/arith/intro.html
@@ -0,0 +1,14 @@
+
+ Image Arithmetic - Introduction
+
+
+
+ In image arithmetic, we consider operations such as I(x,y) = A (x,y) o B(x,y) where o is an arithmetic operation such as addition, subtraction,
+ multiplication or division. Here, A and B could be derived from different sources. Such operations are particularly used in modelling image acquisition
+ as a result of a perfect image corrupted with (additive or multiplicative) noise. The noise is often introduced either by a transmission medium or the
+ camera.
+
+
+
+
+
diff --git a/build/arith/objective.html b/build/arith/objective.html
new file mode 100644
index 00000000..9fcb5d11
--- /dev/null
+++ b/build/arith/objective.html
@@ -0,0 +1,23 @@
+
+
Image Arithmetic - Objectives
+
+
+
+To learn to use arithmetic operations to combine images.
+
+
+
+
+To study the effect of these operations on the dynamic range of the output image.
+
+
+
+
+To study methods to enforce closure - force the output image to also be an 8 bit image.
+
+
+
+
+
+
+
diff --git a/build/arith/procedure.html b/build/arith/procedure.html
new file mode 100644
index 00000000..78b05eb9
--- /dev/null
+++ b/build/arith/procedure.html
@@ -0,0 +1,99 @@
+
+
+
Image Arithmetic: Procedure
+ The experiment is design to understand and learn the image arithmetic concepts. This experiment consists five parts:
+
+
+
+
+ Image addition
+
+
+
+
+ Image Subtraction
+
+
+
+
+ Image Difference
+
+
+
+
+ Image Multiplication
+
+
+
+
+ Image Division
+
+
+
+
+ Steps to run the experiments
+
+
+
+
+ Select image from the mosaic using 'select imag' option
+
+
+
+
+ Select region of the image to load it in the input image panel
+
+
+
+
+ Select secondary image by choosing either of the 'dull ' , 'bright ' or 'gradient ' images
+
+
+
+
+
+
+ Select one option from 'addition', 'subtraction', 'difference', 'multiplication' and 'division'
+
+
+
+
+ Select the one option from 'clipping ' and 'auto-scaling '
+
+
+
+
+
+
+ Select run option to perform the operations
+
+
+
+
+ Output result will be displayed in the output panel
+
+
+
+
+ Along with intermediate results
+
+
+
+
+
+
+ Interesting Observations
+
+
+
+
+ Do the Subtraction and Difference operations, and compare the results.
+
+
+
+
+ Do the Multiplication operation first with clipping and then with auto-scaling , and compare the results.
+
+
+
+
diff --git a/build/arith/quiz.php b/build/arith/quiz.php
new file mode 100644
index 00000000..05f78e7a
--- /dev/null
+++ b/build/arith/quiz.php
@@ -0,0 +1,49 @@
+
+
+
+
diff --git a/build/arith/references.html b/build/arith/references.html
new file mode 100644
index 00000000..1ef65e26
--- /dev/null
+++ b/build/arith/references.html
@@ -0,0 +1,32 @@
+
diff --git a/build/arith/theory.html b/build/arith/theory.html
new file mode 100644
index 00000000..a989a62b
--- /dev/null
+++ b/build/arith/theory.html
@@ -0,0 +1,140 @@
+ Image Arithmetic - Theory
+
+
+
+ A (x,y) o B(x,y) = I(x,y)
+
+
+
+
+ The important requirement in image arithmetic is that all (input and output) the images are of the same size MxM.
+
+
+
+
+ Arithmetic operations are done pixelwise. Let p = A(x,y) and q = B(x,y) be the pixel values to be operated on and r =I(x,y) be the result of the
+ operation.
+
+
+
+
+ Addition
+ :
+
+
+
+
+ I(x,y) = A(x,y) + B(x,y) → r = p + q
+
+
+
+
+ Subtraction
+ :
+
+
+
+
+ I(x,y) = A(x,y) - B(x,y) → r = p - q
+
+
+
+
+ Difference :
+
+
+
+
+ I(x,y) = |A(x,y) - B(x,y)| → r = |p - q|
+
+
+
+
+ Multiplication
+ :
+
+
+
+
+ I(x,y) = A(x,y) X B(x,y) → r = p x q
+
+
+
+
+ Division
+ :
+
+
+
+
+ I(x,y) = A(x,y) / B(x,y) → r = p / q
+
+
+
+
+ Implementation issues:
+
+
+
+
+ Digital images are stored as b - bit images. Hence, the range of values a pixel can take is restricted to the range [ 0, 1,... (2b -1)]. With
+ b= 8 this range is [0,1,...255]. The closed interval poses a problem when performing arithmetic operations in practice, as the results are not
+ guaranteed to be within this interval. For an 8-bit image the intervals for the output pixel for each operation are:
+
+
+
+
+ Addition: r ∈ [0, (2x255=510)]
+
+
+
+
+ Subtraction: r ∈ [-255, 255]
+
+
+
+
+ Difference: r ∈ [0, 255]
+
+
+
+
+ Multiplication: r ∈ [0, (2552 = 65025)]
+
+
+
+
+ Division: r ∈ [0,∞]
+
+
+
+
+ Since we need r to be in [0,255], we will have an underflow or overflow. A final processing step is generally required to handle this problem.
+
+
+
+
+ There are two options:
+
+
+
+
+ Clipping- Map all negative pixel values ( r < 0) to zero and all values above 255 to 255.
+
+
+
+
+ Auto scaling - This operation remaps the range of r to fit to be in [0, 255] as follows. Let ra be the autoscaled value.
+
+
+
+
+ ra = 255 x (r - rmin )/(rmax -rmin )
+
+
+
+
+ Where, rmax and rmin are the maximum and minimum values of an arithmetic operation.
+
+
+
diff --git a/build/assign.php b/build/assign.php
new file mode 100644
index 00000000..04294bbf
--- /dev/null
+++ b/build/assign.php
@@ -0,0 +1,85 @@
+
+
+
+ Assignment - Virtual Lab in Image Processing
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Obtain the figure of the right from the figure on the left.
+
+
"/>
"/>
+
+
+Click
here to try it out.
+
+
+
+
+
diff --git a/build/codes/HIST_backup.cpp b/build/codes/HIST_backup.cpp
new file mode 100755
index 00000000..e87d7416
--- /dev/null
+++ b/build/codes/HIST_backup.cpp
@@ -0,0 +1,194 @@
+#include
+#include
+#include
+#include
+using namespace std;
+
+void create_histogram_image(IplImage* bin_img, IplImage* hist_img,int bins) {
+ CvHistogram *hist;
+
+ int fc = 256/bins;
+ int hist_size = 256/fc;
+ float range[]={0,256/fc};
+ float* ranges[] = { range };
+ float max_value = 0.0;
+ float w_scale = 0.0;
+
+ // create array to hold histogram values
+ hist = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1);
+
+ // calculate histogram values
+ cvCalcHist( &bin_img, hist, 0, NULL );
+
+ // Get the minimum and maximum values of the histogram
+ cvGetMinMaxHistValue( hist, 0, &max_value, 0, 0 );
+
+ // set height by using maximim value
+ cvScale( hist->bins, hist->bins, ((float)hist_img->height)/max_value, 0 );
+
+ // calculate width
+ w_scale = ((float)hist_img->width)/hist_size;
+
+ // plot the histogram
+ for( int i = 0; i < hist_size; i++ ) {
+
+ cvRectangle( hist_img, cvPoint((int)i*w_scale , hist_img->height),
+ cvPoint((int)(i+1)*w_scale, hist_img->height - cvRound(cvGetReal1D(hist->bins,i))),
+ cvScalar(0), -1, 8, 0 );
+
+ }
+}
+IplImage* Pre_Process(IplImage* src,int bins)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+ for(int i=0;iwidth, source->height ), IPL_DEPTH_8U, 1 );
+ if(nbins!=256)
+ bin_img = Pre_Process(source,nbins);
+ else
+ bin_img = cvCloneImage(source);
+
+ int c = cvGetSize(bin_img).width;
+ int r = cvGetSize(bin_img).height;
+
+ IplImage *bin_img1 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
+ int mn4=300,mx4=-1,avg4=0;
+ for(int i=0;i mx4)
+ mx4 = s.val[0];
+ avg4+=s.val[0];
+ cvSet2D(bin_img1,i,j,s);
+ }
+ }
+ avg4 = 4*avg4/(r*c);
+
+ IplImage *hist_img = cvCreateImage(cvSize(300,300), 8, 1);
+ cvSet( hist_img, cvScalarAll(255), 0 );
+ create_histogram_image(bin_img1, hist_img,nbins);
+ char nam[30];
+ int n = sprintf(nam,"%s_1.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+ IplImage *bin_img2 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
+ int mn1=300,mx1=-1,avg1=0;
+ for(int i=0;i mx1)
+ mx1 = s.val[0];
+ avg1+=s.val[0];
+ cvSet2D(bin_img2,i,j-c/2,s);
+ }
+ }
+ avg1 = 4*avg1/(r*c);
+
+ hist_img = cvCreateImage(cvSize(300,300), 8, 1);
+ cvSet( hist_img, cvScalarAll(255), 0 );
+ create_histogram_image(bin_img2, hist_img,nbins);
+ n = sprintf(nam,"%s_2.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+ IplImage *bin_img3 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
+ int mn2=300,mx2=-1,avg2=0;
+ for(int i=r/2;i mx2)
+ mx2 = s.val[0];
+ avg2+=s.val[0];
+ cvSet2D(bin_img3,i-r/2,j,s);
+ }
+ }
+ avg2 = 4*avg2/(r*c);
+
+ hist_img = cvCreateImage(cvSize(300,300), 8, 1);
+ cvSet( hist_img, cvScalarAll(255), 0 );
+ create_histogram_image(bin_img3, hist_img,nbins);
+ n = sprintf(nam,"%s_3.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+
+ IplImage *bin_img4 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
+ int mn3=300,mx3=-1,avg3=0;
+ for(int i=r/2;i mx3)
+ mx3 = s.val[0];
+ avg3+=s.val[0];
+ cvSet2D(bin_img4,i-r/2,j-c/2,s);
+ }
+ }
+ avg3 = 4*avg3/(r*c);
+
+ hist_img = cvCreateImage(cvSize(300,300), 8, 1);
+ cvSet( hist_img, cvScalarAll(255), 0 );
+ create_histogram_image(bin_img4, hist_img,nbins);
+ n = sprintf(nam,"%s_4.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+ cvReleaseImage( &source );
+ cvReleaseImage( &hist_img );
+ cvReleaseImage( &bin_img );
+ cvReleaseImage( &bin_img1 );
+ cvReleaseImage( &bin_img2 );
+ cvReleaseImage( &bin_img3 );
+ cvReleaseImage( &bin_img4 );
+
+ cout<
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+IplImage* imPATH(IplImage *img,int xs,int ys,int xd,int yd,int con)
+{
+ int c = cvGetSize(img).width;
+ int r = cvGetSize(img).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,3);
+ cvMerge(img,img,img,NULL,final_img);
+
+ int dst[r][c];
+ int srcx[r][c];
+ int srcy[r][c];
+ for(int i=0;i X;
+ queue Y;
+ srcx[xs][ys]=xs;
+ srcy[xs][ys]=ys;
+ X.push(xs);
+ Y.push(ys);
+ dst[xs][ys]=0;
+ int pth_found=0;
+
+ int xp,yp;
+ while(!X.empty())
+ {
+ xp = X.front();
+ yp = Y.front();
+/* cout<<"last "<=0)
+ s1 = cvGet2D(img,xp-1,yp);
+ if(con==8 and (xp -1 >= 0) and (yp+1 =0))
+ s7 = cvGet2D(img,xp+1,yp-1);
+
+ if(yp-1 >=0)
+ s4 = cvGet2D(img,xp,yp-1);
+ if(con==8 and (xp-1 >=0) and (yp-1 >=0))
+ s8 = cvGet2D(img,xp-1,yp-1);
+
+ if(s1.val[0] > 0)
+ {
+ if(dst[xp-1][yp] > dst[xp][yp] + 1)
+ {
+ dst[xp-1][yp]=dst[xp][yp]+1;
+ srcx[xp-1][yp]=xp;
+ srcy[xp-1][yp]=yp;
+ X.push(xp-1);
+ Y.push(yp);
+ }
+ }
+
+ if(s5.val[0] > 0)
+ {
+ if(dst[xp-1][yp+1] > dst[xp][yp] + 1)
+ {
+ dst[xp-1][yp+1]=dst[xp][yp]+1;
+ srcx[xp-1][yp+1]=xp;
+ srcy[xp-1][yp+1]=yp;
+ X.push(xp-1);
+ Y.push(yp+1);
+ }
+ }
+
+ if(s2.val[0] > 0)
+ {
+ if(dst[xp][yp+1] > dst[xp][yp] + 1)
+ {
+ dst[xp][yp+1]=dst[xp][yp]+1;
+ srcx[xp][yp+1]=xp;
+ srcy[xp][yp+1]=yp;
+ X.push(xp);
+ Y.push(yp+1);
+ }
+ }
+
+ if(s6.val[0] > 0)
+ {
+ if(dst[xp+1][yp+1] > dst[xp][yp] + 1)
+ {
+ dst[xp+1][yp+1]=dst[xp][yp]+1;
+ srcx[xp+1][yp+1]=xp;
+ srcy[xp+1][yp+1]=yp;
+ X.push(xp+1);
+ Y.push(yp+1);
+ }
+ }
+
+ if(s3.val[0] > 0)
+ {
+ if(dst[xp+1][yp] > dst[xp][yp] + 1)
+ {
+ dst[xp+1][yp]=dst[xp][yp]+1;
+ srcx[xp+1][yp]=xp;
+ srcy[xp+1][yp]=yp;
+ X.push(xp+1);
+ Y.push(yp);
+ }
+ }
+
+ if(s7.val[0] > 0)
+ {
+ if(dst[xp+1][yp-1] > dst[xp][yp] + 1)
+ {
+ dst[xp+1][yp-1]=dst[xp][yp]+1;
+ srcx[xp+1][yp-1]=xp;
+ srcy[xp+1][yp-1]=yp;
+ X.push(xp+1);
+ Y.push(yp-1);
+ }
+ }
+
+ if(s4.val[0] > 0)
+ {
+ if(dst[xp][yp-1] > dst[xp][yp] + 1)
+ {
+ dst[xp][yp-1]=dst[xp][yp]+1;
+ srcx[xp][yp-1]=xp;
+ srcy[xp][yp-1]=yp;
+ X.push(xp);
+ Y.push(yp-1);
+ }
+ }
+
+ if(s8.val[0] > 0)
+ {
+ if(dst[xp-1][yp-1] > dst[xp][yp] + 1)
+ {
+ dst[xp-1][yp-1]=dst[xp][yp]+1;
+ srcx[xp-1][yp-1]=xp;
+ srcy[xp-1][yp-1]=yp;
+ X.push(xp-1);
+ Y.push(yp-1);
+ }
+ }
+ }
+
+ int tx=xd,ty=yd;
+ if(!pth_found)
+ {
+// cout<<"path not found\n";
+ tx = xp;
+ ty = yp;
+// cout<<"point "<0 and sd.val[0]>0)
+ {
+ // cout<<"here :S \n";
+ IplImage* path_img=cvCreateImage(cvSize(c1,r1),IPL_DEPTH_8U,3);
+ path_img=imPATH(img1,xs,ys,xd,yd,con);
+ cvSaveImage(argv[2],path_img);
+ cvReleaseImage( &path_img );
+ }
+ cvReleaseImage( &img1 );
+ return 0;
+}
diff --git a/build/codes/coladaptivehist.sh b/build/codes/coladaptivehist.sh
new file mode 100755
index 00000000..5d4956cc
--- /dev/null
+++ b/build/codes/coladaptivehist.sh
@@ -0,0 +1,4 @@
+ gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o coladaptivehist.out im_coladaptivehist.cpp
+./coladaptivehist.out colimg.jpg cimg.jpg 7 7 2 2
+#display cimg.jpg &
+#display colimg.jpg &
diff --git a/build/codes/colcon.out b/build/codes/colcon.out
new file mode 100755
index 00000000..05ce43ca
Binary files /dev/null and b/build/codes/colcon.out differ
diff --git a/build/codes/colhist.out b/build/codes/colhist.out
new file mode 100755
index 00000000..1fb1b1d6
Binary files /dev/null and b/build/codes/colhist.out differ
diff --git a/build/codes/colhist.sh b/build/codes/colhist.sh
new file mode 100755
index 00000000..ec7e27d1
--- /dev/null
+++ b/build/codes/colhist.sh
@@ -0,0 +1,7 @@
+ gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o colhist.out im_colhist.cpp
+#./colhist.out colimg.jpg cimg.jpg 2 2
+#display cimg.jpg &
+#display colimg.jpg &
+#display p1.jpg &
+#display p2.jpg &
+#display p3.jpg &
diff --git a/build/codes/color.out b/build/codes/color.out
new file mode 100755
index 00000000..df1b988e
Binary files /dev/null and b/build/codes/color.out differ
diff --git a/build/codes/color.sh b/build/codes/color.sh
new file mode 100755
index 00000000..35439bd2
--- /dev/null
+++ b/build/codes/color.sh
@@ -0,0 +1,11 @@
+# gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o color.out im_color.cpp
+#./color.out colimg.jpg cimg.jpg 2
+gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o colcon.out im_colcon.cpp
+
+
+
+#display cimg.jpg &
+#display colimg.jpg &
+#display p1.jpg &
+#display p2.jpg &
+#display p3.jpg &
diff --git a/build/codes/colour.sh b/build/codes/colour.sh
new file mode 100755
index 00000000..329deeab
--- /dev/null
+++ b/build/codes/colour.sh
@@ -0,0 +1,3 @@
+ gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o colour.out im_colour.cpp
+# gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o colour2.out im_colourLin.cpp
+# gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o colour3.out im_colhist.cpp
\ No newline at end of file
diff --git a/build/codes/colour2.out b/build/codes/colour2.out
new file mode 100755
index 00000000..de84a025
Binary files /dev/null and b/build/codes/colour2.out differ
diff --git a/build/codes/colpoint.out b/build/codes/colpoint.out
new file mode 100755
index 00000000..48dad590
Binary files /dev/null and b/build/codes/colpoint.out differ
diff --git a/build/codes/colpoint.sh b/build/codes/colpoint.sh
new file mode 100755
index 00000000..7875019f
--- /dev/null
+++ b/build/codes/colpoint.sh
@@ -0,0 +1,4 @@
+ gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o colpoint.out im_colourLin.cpp
+./colpoint.out colimg.jpg cimg.jpg 1 100 150 1
+#display colimg.jpg
+#display cimg.jpg
diff --git a/build/codes/colunsharp.sh b/build/codes/colunsharp.sh
new file mode 100755
index 00000000..71125e96
--- /dev/null
+++ b/build/codes/colunsharp.sh
@@ -0,0 +1,6 @@
+ gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o unsharp.out im_unsharpmasking.cpp
+ ./unsharp.out desert.jpg UnsharpMasking.jpg
+display desert.jpg &
+#display smoothened.jpg &
+#display subtracted.jpg &
+display UnsharpMasking.jpg &
diff --git a/build/codes/dist.sh b/build/codes/dist.sh
new file mode 100755
index 00000000..b84d3fb8
--- /dev/null
+++ b/build/codes/dist.sh
@@ -0,0 +1,2 @@
+ gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o dist.out im_dist.cpp
+mv dist.out ../execs/
diff --git a/build/codes/fourier.sh b/build/codes/fourier.sh
new file mode 100755
index 00000000..847463d8
--- /dev/null
+++ b/build/codes/fourier.sh
@@ -0,0 +1,2 @@
+ gcc -I/usr/local/include/opencv -L/usr/local/lib -lcv -lhighgui -lstdc++ -o fourier.out im_fourier.cpp
+mv fourier.out ../execs/
\ No newline at end of file
diff --git a/build/codes/fourier_backup.cpp b/build/codes/fourier_backup.cpp
new file mode 100755
index 00000000..1034cf2f
--- /dev/null
+++ b/build/codes/fourier_backup.cpp
@@ -0,0 +1,42 @@
+#include
+#include
+#include
+#include
+using namespace std;
+
+int main( int argc, char** argv )
+
+{
+ IplImage *source = cvLoadImage(argv[1],0);
+
+ cout<<"done this";
+
+ IplImage *bin_img = cvCreateImage(cvSize( source->width, source->height ), CV_64FC1, 1 );
+ bin_img = cvCloneImage(source);
+
+ int c = cvGetSize(bin_img).width;
+ int r = cvGetSize(bin_img).height;
+
+
+
+ if(1)
+ {
+ IplImage *four_img = cvCreateImage(cvSize( source->width, source->height ),CV_64FC1,2);
+ cvDFT( bin_img, four_img, CV_DXT_FORWARD, 0);
+ IplImage *ioutRe = cvCreateImage(cvSize( source->width, source->height ),CV_64FC1, 1);
+ IplImage *ioutIm = cvCreateImage(cvSize( source->width, source->height ),CV_64FC1, 1);
+ cvSplit(four_img, ioutRe, ioutIm, NULL, NULL);
+ cvSaveImage(argv[2],ioutRe);
+ cvSaveImage(argv[3],ioutIm);
+ cvReleaseImage( &ioutIm );
+ cvReleaseImage( &ioutRe );
+ cvReleaseImage( &source );
+ cvReleaseImage( &four_img );
+ cvReleaseImage( &bin_img );
+
+
+
+ }
+
+ return 0;
+}
diff --git a/build/codes/hist.sh b/build/codes/hist.sh
new file mode 100755
index 00000000..713fc90f
--- /dev/null
+++ b/build/codes/hist.sh
@@ -0,0 +1,4 @@
+ gcc -I/usr/local/include/opencv -L/usr/local/lib -lcv -lhighgui -lstdc++ -o hist.out im_hist.cpp
+# display stock1.jpg
+#./hist.out
+#display hist_1.jpg
diff --git a/build/codes/im_advfourier.cpp b/build/codes/im_advfourier.cpp
new file mode 100644
index 00000000..2874a0dd
--- /dev/null
+++ b/build/codes/im_advfourier.cpp
@@ -0,0 +1,128 @@
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+#define PI 3.1428571
+#define MAXI 999999999
+
+int main(int argc, char ** argv)
+{
+ IplImage * im = cvLoadImage(argv[1],0);
+ IplImage * realInput = cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 1);
+ IplImage * imaginaryInput = cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 1);
+ IplImage * complexInput = cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 2);
+ CvMat* dft_A, tmp;
+ int theta = atoi(argv[2]);
+ int rad = atoi(argv[3]);
+ int deltheta = atoi(argv[4]);
+ int delrad = atoi(argv[5]);
+ double angle1 = theta-(deltheta/2);
+ double angle2 = theta+(deltheta/2);
+ double angle3 = 180+theta-(deltheta/2);
+ double angle4 = 180+theta+(deltheta/2);
+ double val1 = atan((angle1==90||angle1==270||angle1==-90||angle1==-270)?MAXI:tan(PI/180*angle1));
+ double val2 = atan((angle1==90||angle1==270||angle1==-90||angle1==-270)?MAXI:tan(PI/180*angle2));
+ double val3 = atan((angle1==90||angle1==270||angle1==-90||angle1==-270)?MAXI:tan(PI/180*angle3));
+ double val4 = atan((angle1==90||angle1==270||angle1==-90||angle1==-270)?MAXI:tan(PI/180*angle4));
+
+ int dft_M, dft_N;
+ cvScale(im, realInput, 1.0, 0.0);
+ cvZero(imaginaryInput);
+ cvMerge(realInput, imaginaryInput, NULL, NULL, complexInput);
+ dft_M = cvGetOptimalDFTSize( im->height - 1 );
+ dft_N = cvGetOptimalDFTSize( im->width - 1 );
+ dft_A = cvCreateMat( dft_M, dft_N, CV_64FC2 );
+ cvGetSubRect( dft_A, &tmp, cvRect(0,0, im->width, im->height));
+ cvCopy( complexInput, &tmp, NULL );
+ if( dft_A->cols > im->width )
+ {
+ cvGetSubRect( dft_A, &tmp, cvRect(im->width,0, dft_A->cols -
+ im->width, im->height));
+ cvZero( &tmp );
+ }
+ cvDFT( dft_A, dft_A, CV_DXT_FORWARD, complexInput->height );
+ IplImage * re = cvCreateImage(cvSize(dft_N,dft_M),IPL_DEPTH_64F,1);
+ IplImage * imag = cvCreateImage(cvSize(dft_N,dft_M),IPL_DEPTH_64F,1);
+ cvSplit(dft_A,re,imag,0,0);
+
+ int r = cvGetSize(imag).height;
+ int c = cvGetSize(imag).width;
+ double dist,row,col,val;
+ CvScalar s;
+ for (int i=0;i=val2 && (val>=val1||val<=val2)) || (val3>=val4 && (val>=val3||val<=val4)))
+ {
+ s.val[0]=0.0;
+ cvSet2D(imag,i,j,s);
+ }
+ else if ((val>=val1 && val<=val2) || (val>=val3 && val<=val4))
+ {
+ s.val[0]=0.0;
+ cvSet2D(imag,i,j,s);
+ }
+ }
+ }
+ }
+ }
+
+ cvNamedWindow("imaginary",0);
+ cvShowImage("imaginary",imag);
+
+ cvMerge(re,imag,NULL,NULL,dft_A);
+ cvDFT( dft_A, dft_A, CV_DXT_INVERSE_SCALE, dft_N);
+ cvScale(dft_A,dft_A,0.001);
+ cvSplit(dft_A,re,imag,0,0);
+ cvPow(re,re,2);
+ cvPow(imag,imag,2);
+ cvAdd(re,imag,re,NULL);
+ cvPow(re,re,0.5);
+ cvAddS( re, cvScalarAll(1.0), re, NULL ); // 1 + Mag
+ cvLog( re, re); // log(1 + Mag)
+ double m,M;
+ cvMinMaxLoc(re, &m, &M, NULL, NULL, NULL);
+ cvScale(re, re, 1.0/(M-m), 1.0*(-m)/(M-m));
+ IplImage * Output = cvCreateImage(cvGetSize(re),IPL_DEPTH_8U,1);
+ CvPoint minLoc, maxLoc;
+ double minVal = 0; double maxVal = 0;
+ cvMinMaxLoc(re, &minVal, &maxVal, &minLoc, &maxLoc, 0);
+ cvCvtScaleAbs(re,Output,255.0*(maxVal-minVal),0);
+ cvSaveImage("advfourier.jpg",Output);
+
+ cvNamedWindow("advfourier",0);
+ cvShowImage("advfourier",Output);
+
+ cvWaitKey(-1);
+
+ cvReleaseImage(&im);
+ cvReleaseImage(&realInput);
+ cvReleaseImage(&imaginaryInput);
+ cvReleaseImage(&complexInput);
+ cvReleaseImage(&re);
+ cvReleaseImage(&imag);
+ cvReleaseMat(&dft_A);
+ cvReleaseImage(&Output);
+ return 0;
+}
diff --git a/build/codes/im_affine.cpp b/build/codes/im_affine.cpp
new file mode 100755
index 00000000..e8f47320
--- /dev/null
+++ b/build/codes/im_affine.cpp
@@ -0,0 +1,128 @@
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+IplImage *imtranslate(IplImage *src,int tx,int ty)
+{
+ IplImage *tmp=cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,1);
+/* if(tx==0 and ty==0)
+ {
+ tmp= cvCloneImage(src);
+ return tmp;
+ }
+*/
+ for(int i=0;i< src->height-1-ty;i++)
+ {
+ for(int j=0;jwidth-1-tx;j++)
+ {
+ CvScalar s1;
+ s1= cvGet2D(src,i,j);
+ cvSet2D(tmp,i+ty,j+tx,s1);
+ }
+
+ }
+ return tmp;
+
+}
+
+IplImage *imscale_rotate(IplImage *src,float angl,float scale,int flag)
+{
+ CvPoint2D32f srcTri[3], dstTri[3];
+ CvMat* rot_mat = cvCreateMat(2,3,CV_32FC1);
+ CvMat* warp_mat = cvCreateMat(2,3,CV_32FC1);
+ IplImage *dst;
+ dst = cvCloneImage( src );
+
+ srcTri[0].x = 0;
+ srcTri[0].y = 0;
+ srcTri[1].x = src->width - 1;
+ srcTri[1].y = 0;
+ srcTri[2].x = 0;
+ srcTri[2].y = src->height - 1;
+
+ dstTri[0].x = 0;
+ dstTri[0].y = 0;
+ dstTri[1].x = src->width - 1;
+ dstTri[1].y = 0;
+ dstTri[2].x = 0;
+ dstTri[2].y = src->height - 1;
+
+ cvGetAffineTransform( srcTri, dstTri, warp_mat );
+ cvWarpAffine( src, dst, warp_mat,flag);
+ cvCopy ( dst, src );
+
+
+ // Compute rotation matrix
+ CvPoint2D32f center = cvPoint2D32f( src->width/2, src->height/2 );
+ cv2DRotationMatrix( center, angl, scale, rot_mat );
+
+ // Do the transformation
+ cvWarpAffine( src, dst, rot_mat );
+ return dst;
+}
+
+int main(int argc,char* argv[])
+{
+ // Set up variables
+
+ IplImage *src, *dst;
+
+ // Load image
+ src=cvLoadImage(argv[1]);
+
+
+
+ char *img_nm,*img_typ;
+ img_nm = strtok (argv[2],".");
+ img_typ = strtok (NULL, ".");
+
+ // get angle of rotation, translation(%) and scale value for the transformation
+
+ float angl;
+ int tx,ty;
+ float scale;
+
+ angl = atof(argv[3]);
+ tx = atoi(argv[4]);
+ ty = atoi(argv[5]);
+ scale = atof(argv[6]);
+ scale = pow(2,scale);
+/*
+ cvNamedWindow( name, 1 );
+ cvShowImage( name,src);
+ cvWaitKey(0);
+ return 0;
+*/
+ int flag[3];
+ flag[0] = CV_INTER_NN+CV_WARP_FILL_OUTLIERS;
+ flag[1] = CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS;
+ flag[2] = CV_INTER_CUBIC+CV_WARP_FILL_OUTLIERS;
+
+
+ for(int i = 0;i<3;i++)
+ {
+ dst = cvCloneImage( src );
+// tmp=cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,1);
+ dst->origin = src->origin;
+ cvZero( dst );
+ if(tx==0 and ty==0)
+ dst = imscale_rotate(src,angl,scale,flag[i]);
+ else
+ dst = imtranslate(src,tx,ty);
+// src = cvCloneImage(tmp);
+
+ char nm[50];
+ int n = sprintf(nm,"%s%d.%s",img_nm,i+1,img_typ);
+ cvSaveImage(nm,dst);
+ }
+
+ cvReleaseImage( &src );
+// cvReleaseImage( &tmp );
+ cvReleaseImage( &dst );
+
+ return 0;
+}
+
diff --git a/build/codes/im_arith.cpp b/build/codes/im_arith.cpp
new file mode 100755
index 00000000..2b8cdc22
--- /dev/null
+++ b/build/codes/im_arith.cpp
@@ -0,0 +1,425 @@
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+IplImage* imADD(IplImage *img1,IplImage *img2,int map_fn)
+{
+ int c = cvGetSize(img1).width;
+ int r = cvGetSize(img1).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ if(map_fn==1)
+ {
+ for(int i=0;i 255)
+ grval=255;
+ s.val[0] = grval;
+ cvSet2D(final_img,i,j,s);
+ }
+ }
+
+ }
+ else if(map_fn==2)
+ {
+ int min_val=100000;
+ int max_val=-300;
+
+ for(int i=0;i max_val)
+ max_val = grval;
+ if(grval < min_val)
+ min_val = grval;
+ }
+ }
+ for(int i=0;i max_val)
+ max_val = grval;
+ if(grval < min_val)
+ min_val = grval;
+ }
+ }
+ for(int i=0;i max_val)
+ max_val = grval;
+ if(grval < min_val)
+ min_val = grval;
+ }
+ }
+ for(int i=0;i 255)
+ grval=255;
+ s.val[0] = grval;
+ cvSet2D(final_img,i,j,s);
+ }
+ }
+
+ }
+ else if(map_fn==2)
+ {
+ int min_val=100000;
+ int max_val=-300;
+
+ for(int i=0;i max_val)
+ max_val = grval;
+ if(grval < min_val)
+ min_val = grval;
+ }
+ }
+ for(int i=0;i 255.0)
+ grval=255;
+ s.val[0] = (int)(grval);
+ cvSet2D(final_img,i,j,s);
+ }
+ }
+
+ }
+ else if(map_fn==2)
+ {
+ double min_val=1000000;
+ double max_val=-300;
+
+ for(int i=0;i max_val)
+ max_val = grval;
+ if(grval < min_val)
+ min_val = grval;
+ }
+ }
+// cout<
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+IplImage* adapthist(IplImage* pln, int arg3, int arg4)
+{
+ int c=cvGetSize(pln).width;
+ int r=cvGetSize(pln).height;
+
+ IplImage *p4=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+
+ CvScalar s,s1;
+ int cdf[256]={0};
+ int hst[256]={0};
+ int count;
+ for (int i=0;i "< input should be 1 or 2 or 3
+// and argv[6] tells which color model to select --> input should be "1" for RGB, "2" for HSV, and "3" for CMY
+
+int main(int argc, char* argv[])
+{
+ IplImage *source=cvLoadImage(argv[1],1);
+
+ int c=cvGetSize(source).width;
+ int r=cvGetSize(source).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,3);
+ IplImage* out_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,3);
+ IplImage *p1=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p2=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p3=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p4=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p5=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p6=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+
+ if (atoi(argv[6])==1)
+ {
+ CvScalar s,t;
+ t.val[0]=0;
+ t.val[1]=0;
+ t.val[2]=0;
+ for (int i=0;i
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+
+
+int main(int argc, char* argv[])
+{
+ IplImage *source=cvLoadImage(argv[1],1);
+
+
+ int c=cvGetSize(source).width;
+ int r=cvGetSize(source).height;
+ IplImage *p1=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p2=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p3=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage* out_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,3);
+
+ CvScalar s,t;
+ t.val[0]=0;
+ t.val[1]=0;
+ t.val[2]=0;
+ for (int i=0;i
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+IplImage* adapthist(IplImage* pln, int arg3, int arg4)
+{
+ int c=cvGetSize(pln).width;
+ int r=cvGetSize(pln).height;
+
+ IplImage *p4=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+
+
+ IplImage *temp=cvCreateImage(cvSize(arg3,arg4),IPL_DEPTH_8U,1);
+
+ CvScalar s;
+ for (int ii=0;ii=x)?0:x); ii=y)?0:y); jj input should be 1 or 2 or 3
+// and argv[4] tells which color model to select --> input should be "1" for RGB, "2" for HSV, and "3" for CMY
+// argv[6] and argv[7] tell the kernel size -> LXB
+
+int main(int argc, char* argv[])
+{
+ IplImage *source=cvLoadImage(argv[1],1);
+
+ int c=cvGetSize(source).width;
+ int r=cvGetSize(source).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,3);
+ IplImage* out_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,3);
+ IplImage *p1=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p2=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p3=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p4=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p5=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p6=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+
+ if (atoi(argv[4])==1)
+ {
+ CvScalar s,t;
+ t.val[0]=0;
+ t.val[1]=0;
+ t.val[2]=0;
+ for (int i=0;i
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+
+
+int main(int argc, char* argv[])
+{
+ IplImage *source=cvLoadImage(argv[1],1);
+
+ int c=cvGetSize(source).width;
+ int r=cvGetSize(source).height;
+
+ IplImage* out_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,3);
+ IplImage *p1=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p2=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p3=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+
+ if(atoi(argv[3])==1)
+ {
+ cout<<"splitting the original image to RGB planes"<
+#include
+#include
+#include
+#include
+#include
+using namespace std;
+int main(int argc, char* argv[])
+{
+ IplImage *source=cvLoadImage(argv[1],1);
+ int c=cvGetSize(source).width;
+ int r=cvGetSize(source).height;
+ IplImage* out_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,3);
+ IplImage *p1=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p2=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage *p3=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ char *img_nm,*img_typ;
+ img_nm = strtok (argv[2],".");
+ img_typ = strtok (NULL, ".");
+ if(atoi(argv[3])==1 || atoi(argv[3])==5)
+ {
+ // converting the RGB image to HSV
+ // cout<<"converting the RGB image to HSV"<
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+IplImage* Contrast_Stretch(IplImage *src,float a,float b, int arg)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+
+ for(int i=0;i 255)
+ grval1 = 255;
+ else if(grval1 < 0)
+ grval1 = 0;
+ s.val[0] = grval1;
+ }
+
+ if (arg==2 || arg==3 || arg==6 || arg==7)
+ {
+ int grval2 = (int)(tan(a*3.14/180)*s1.val[1] + b);
+ if(grval2 > 255)
+ grval2 = 255;
+ else if(grval2 < 0)
+ grval2 = 0;
+ s.val[1] = grval2;
+ }
+
+ if (arg==4 || arg==5 || arg==6 || arg==7)
+ {
+ int grval3 = (int)(tan(a*3.14/180)*s1.val[2] + b);
+ if(grval3 > 255)
+ grval3 = 255;
+ else if(grval3 < 0)
+ grval3 = 0;
+ s.val[2] = grval3;
+ }
+
+ cvSet2D(final_img,i,j,s);
+
+ }
+ }
+ return final_img;
+}
+
+// argv[7] will tells on which plane the proc. needs to be done --> input should be 1 or 2 or 3
+// and argv[8] tells which color model to select --> input should be "1" for RGB, "2" for HSV, and "3" for CMY
+
+int main(int argc,char *argv[])
+{
+ int p[3];
+ p[0] = CV_IMWRITE_JPEG_QUALITY;
+ p[1] = 90;
+ p[2] = 0;
+
+ char *img_nm,*img_typ;
+ IplImage* source = cvLoadImage(argv[1],1);
+ IplImage* dst;
+ IplImage* dst1;
+
+ char *pch,*rem,*f_img;
+ pch = strtok (argv[1],"/");
+ while (pch != NULL)
+ {
+ f_img = pch;
+ pch = strtok (NULL, "/");
+
+ }
+
+ img_nm = strtok (f_img,".");
+ img_typ = strtok (NULL, ".");
+ cout<<"hello worldhhhh"<width,src->height),src->depth,src->nChannels);
+ dst1=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ dst1=Contrast_Stretch(src,a,b,atoi(argv[3]));
+
+
+ cvSplit(dst1,p1,p2,p3,0);
+
+ if (atoi(argv[6])==1)
+ {
+ // processing the image in RGB
+ CvScalar s,t;
+ t.val[0]=0;
+ t.val[1]=0;
+ t.val[2]=0;
+ for (int i=0;i
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+
+IplImage* Log_Image(IplImage *src,int cn, int arg)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+ for(int i=0;i 255)
+ grval1= 255;
+ if(grval1 < 0)
+ grval1 = 0;
+ s.val[0] = grval1;
+ }
+
+ if (arg==2 || arg==3 || arg==6 || arg==7)
+ {
+ int grval2 = s1.val[1];
+ grval2 = cn*log10(1 + grval2);
+ if(grval2 > 255)
+ grval2= 255;
+ if(grval2 < 0)
+ grval2 = 0;
+ s.val[1] = grval2;
+ }
+
+ if (arg==4 || arg==5 || arg==6 || arg==7)
+ {
+ int grval3 = s1.val[2];
+ grval3 = cn*log10(1 + grval3);
+ if(grval3 > 255)
+ grval3= 255;
+ if(grval3 < 0)
+ grval3 = 0;
+ s.val[2] = grval3;
+ }
+
+ cvSet2D(final_img,i,j,s);
+ }
+ }
+ return final_img;
+}
+
+IplImage* Contrast_Stretch(IplImage *src,float a,float b, int arg)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+ for(int i=0;i 255)
+ grval1 = 255;
+ else if(grval1 < 0)
+ grval1 = 0;
+ s.val[0] = grval1;
+ }
+
+ if (arg==2 || arg==3 || arg==6 || arg==7)
+ {
+ int grval2 = (int)(tan(a*3.14/180)*s1.val[1] + b);
+ if(grval2 > 255)
+ grval2 = 255;
+ else if(grval2 < 0)
+ grval2 = 0;
+ s.val[1] = grval2;
+ }
+
+ if (arg==4 || arg==5 || arg==6 || arg==7)
+ {
+ int grval3 = (int)(tan(a*3.14/180)*s1.val[2] + b);
+ if(grval3 > 255)
+ grval3 = 255;
+ else if(grval3 < 0)
+ grval3 = 0;
+ s.val[2] = grval3;
+ }
+
+ cvSet2D(final_img,i,j,s);
+
+ }
+ }
+ return final_img;
+}
+
+IplImage* Clipped_Image(IplImage *src,float a,float b,float beta, int arg)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+ for(int i=0;i (int)(b))
+ grval1 = 255;
+ else
+ grval1 = (int)(beta * grval1);
+ if(grval1 > 255)
+ grval1 = 255;
+ s.val[0] = grval1;
+ }
+
+ if (arg==2 || arg==4 || arg==5 || arg==7)
+ {
+ int grval2 = (int)(s1.val[1]);
+ if(grval2 < (int)(a))
+ grval2 = 0;
+ else if(grval2 > (int)(b))
+ grval2 = 255;
+ else
+ grval2 = (int)(beta * grval2);
+ if(grval2 > 255)
+ grval2 = 255;
+ s.val[1] = grval2;
+ }
+
+ if (arg==3 || arg==5 || arg==6 || arg==7)
+ {
+ int grval3 = (int)(s1.val[2]);
+ if(grval3 < (int)(a))
+ grval3 = 0;
+ else if(grval3 > (int)(b))
+ grval3 = 255;
+ else
+ grval3 = (int)(beta * grval3);
+ if(grval3 > 255)
+ grval3 = 255;
+ s.val[2] = grval3;
+ }
+
+ cvSet2D(final_img,i,j,s);
+ }
+ }
+ return final_img;
+}
+
+IplImage* Windowed_Image(IplImage *src,float a,float b,float beta, int arg)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+ for(int i=0;i (int)(b)))
+ grval1 = 0;
+ else
+ grval1 = (int)(beta * grval1);
+ if(grval1 > 255)
+ grval1 = 255;
+ s.val[0] = grval1;
+ }
+
+ if (arg==2 || arg==4 || arg==5 || arg==7)
+ {
+ int grval2 = (int)(s1.val[1]);
+ if((grval2 < (int)(a)) or (grval2 > (int)(b)))
+ grval2 = 0;
+ else
+ grval2 = (int)(beta * grval2);
+ if(grval2 > 255)
+ grval2 = 255;
+ s.val[1] = grval2;
+ }
+
+ if (arg==3 || arg==5 || arg==6 || arg==7)
+ {
+ int grval3 = (int)(s1.val[2]);
+ if((grval3 < (int)(a)) or (grval3 > (int)(b)))
+ grval3 = 0;
+ else
+ grval3 = (int)(beta * grval3);
+ if(grval3 > 255)
+ grval3 = 255;
+ s.val[2] = grval3;
+ }
+
+ cvSet2D(final_img,i,j,s);
+ }
+ }
+ return final_img;
+}
+
+ // argv[7] will tells on which plane the proc. needs to be done --> input should be 1 or 2 or 3
+ // and argv[8] tells which color model to select --> input should be "1" for RGB, "2" for HSV, and "3" for CMY
+
+
+int main(int argc,char *argv[])
+{
+ int p[3];
+ p[0] = CV_IMWRITE_JPEG_QUALITY;
+ p[1] = 90;
+ p[2] = 0;
+
+ char *img_nm,*img_typ;
+ IplImage* src = cvLoadImage(argv[1],1);
+ IplImage* dst;
+
+ char *pch,*rem,*f_img;
+ pch = strtok (argv[1],"/");
+ while (pch != NULL)
+ {
+ f_img = pch;
+ pch = strtok (NULL, "/");
+
+ }
+
+ img_nm = strtok (f_img,".");
+ img_typ = strtok (NULL, ".");
+
+
+// cout<<"2\n";
+ float a,b;
+ a = atof(argv[3]);
+ b = atof(argv[4]);
+ dst=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ dst=Contrast_Stretch(src,a,b,atoi(argv[5]));
+
+ cvSaveImage(argv[2],dst);
+
+ int c=cvGetSize(src).width;
+ int r=cvGetSize(src).height;
+ IplImage* p1=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage* p2=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ IplImage* p3=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ cvSplit(src,p1,p2,p3,0);
+ cvSaveImage("p1.jpg",p1);
+ cvSaveImage("p2.jpg",p2);
+ cvSaveImage("p3.jpg",p3);
+ cvSplit(dst,p1,p2,p3,0);
+ cvSaveImage("newp1.jpg",p1);
+ cvSaveImage("newp2.jpg",p2);
+ cvSaveImage("newp3.jpg",p3);
+ cvReleaseImage( &p1 );
+ cvReleaseImage( &p2 );
+ cvReleaseImage( &p3 );
+
+ cvReleaseImage( &src );
+ cvReleaseImage( &dst);
+ return 0;
+}
diff --git a/build/codes/im_colunsharpmasking.cpp b/build/codes/im_colunsharpmasking.cpp
new file mode 100755
index 00000000..2b39eed4
--- /dev/null
+++ b/build/codes/im_colunsharpmasking.cpp
@@ -0,0 +1,52 @@
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+void UnsharpMasking(IplImage *src, char* out_img)
+{
+ IplImage *UnsharpMaskingImage = cvCreateImage(cvGetSize(src), src->depth, src-> nChannels);
+ IplImage *temp1 = cvCreateImage(cvGetSize(src), src->depth, src-> nChannels);
+ IplImage *temp2 = cvCreateImage(cvGetSize(src), src->depth, src-> nChannels);
+
+ cvSmooth( src, temp1, CV_GAUSSIAN, 27, 27);
+ cvSub( src,temp1, temp2, NULL );
+
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ CvScalar s1;
+
+ for (int i=0;inChannels<
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+int maxi(int a, int b)
+{
+ return a>b?a:b;
+}
+
+IplImage *imCityBlock2(IplImage *img,int x1,int y1)
+{
+ int c = cvGetSize(img).width;
+ int r = cvGetSize(img).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+
+ float scale;
+ int maxd;
+ maxd = maxi( maxi(x1+y1, x1+abs(y1-c) ), maxi(abs(x1-r)+y1, abs(x1-r)+abs(y1-c)) );
+ scale=255.0/maxd;
+
+ CvScalar s;
+ for (int i=0;i=0 && y2=0)
+ cvSet2D(final_img,x2,y2,s);
+
+ y2=y1-d;
+ // cout<=0 && y2=0)
+ cvSet2D(final_img,x2,y2,s);
+ }
+
+ return final_img;
+}
+
+IplImage *imChessBoard(IplImage *img,int x1,int y1,int dist)
+{
+ int c = cvGetSize(img).width;
+ int r = cvGetSize(img).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,3);
+ cvMerge(img,img,img,NULL,final_img);
+
+ int x2,y2;
+ CvScalar s;
+
+ s.val[0]=255;
+ cvSet2D(final_img,x1,y1,s);
+ s.val[0]=0;
+
+ s.val[1]=255;
+ for (y2=y1-dist; y2<=y1+dist; y2++)
+ {
+ x2=x1+dist;
+ if (x2=0 && y2=0)
+ cvSet2D(final_img,x2,y2,s);
+
+ x2=x1-dist;
+ if (x2=0 && y2=0)
+ cvSet2D(final_img,x2,y2,s);
+ }
+ for (x2=x1-dist; x2<=x1+dist;x2++)
+ {
+ y2=y1+dist;
+ if (x2=0 && y2=0)
+ cvSet2D(final_img,x2,y2,s);
+
+ y2=y1-dist;
+ if (x2=0 && y2=0)
+ cvSet2D(final_img,x2,y2,s);
+ }
+
+ return final_img;
+}
+
+IplImage* imEuclidean(IplImage *img,int x1,int y1,int dist)
+{
+ int c = cvGetSize(img).width;
+ int r = cvGetSize(img).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,3);
+ cvMerge(img,img,img,NULL,final_img);
+
+ int x2,y2,d;
+ CvScalar s;
+
+ s.val[0]=255;
+ cvSet2D(final_img,x1,y1,s);
+ s.val[0]=0;
+
+ s.val[1]=255;
+ for (x2=x1-dist; x2<=x1+dist; x2++)
+ {
+ d=(int)sqrt( (dist*dist) - ((x1-x2)*(x1-x2)) );
+ y2=y1+d;
+ if (x2=0 && y2=0)
+ cvSet2D(final_img,x2,y2,s);
+
+ y2=y1-d;
+ if (x2=0 && y2=0)
+ cvSet2D(final_img,x2,y2,s);
+ }
+
+ return final_img;
+}
+
+
+int main(int argc,char* argv[])
+{
+ int choice = atoi (argv[1]) ;
+
+ if(choice==1) {
+ int x1 = atoi(argv[2]);
+ int y1 = atoi(argv[3]);
+ int x2 = atoi(argv[4]);
+ int y2 = atoi(argv[5]);
+ if(atoi(argv[6])==1)
+ {
+ // city block
+
+ cout<
+#include
+//#include "stdafx.h"
+#include
+#include
+#include
+
+#define PI 3.1428571
+#define MAXI 999999999
+
+// Rearrange the quadrants of Fourier image so that the origin is at
+// the image center
+// src & dst arrays of equal size & type
+void cvShiftDFT(CvArr * src_arr, CvArr * dst_arr )
+{
+ CvMat * tmp;
+ CvMat q1stub, q2stub;
+ CvMat q3stub, q4stub;
+ CvMat d1stub, d2stub;
+ CvMat d3stub, d4stub;
+ CvMat * q1, * q2, * q3, * q4;
+ CvMat * d1, * d2, * d3, * d4;
+
+ CvSize size = cvGetSize(src_arr);
+ CvSize dst_size = cvGetSize(dst_arr);
+ int cx, cy;
+
+ if(src_arr==dst_arr){
+ tmp = cvCreateMat(size.height/2, size.width/2,
+ cvGetElemType(src_arr));
+ }
+
+ cx = size.width/2;
+ cy = size.height/2; // image center
+
+ q1 = cvGetSubRect( src_arr, &q1stub, cvRect(0,0,cx, cy) );
+ q2 = cvGetSubRect( src_arr, &q2stub, cvRect(cx,0,cx,cy) );
+ q3 = cvGetSubRect( src_arr, &q3stub, cvRect(cx,cy,cx,cy) );
+ q4 = cvGetSubRect( src_arr, &q4stub, cvRect(0,cy,cx,cy) );
+ d1 = cvGetSubRect( src_arr, &d1stub, cvRect(0,0,cx,cy) );
+ d2 = cvGetSubRect( src_arr, &d2stub, cvRect(cx,0,cx,cy) );
+ d3 = cvGetSubRect( src_arr, &d3stub, cvRect(cx,cy,cx,cy) );
+ d4 = cvGetSubRect( src_arr, &d4stub, cvRect(0,cy,cx,cy) );
+
+ if(src_arr!=dst_arr){
+ cvCopy(q3, d1, 0);
+ cvCopy(q4, d2, 0);
+ cvCopy(q1, d3, 0);
+ cvCopy(q2, d4, 0);
+ }
+ else{
+ cvCopy(q3, tmp, 0);
+ cvCopy(q1, q3, 0);
+ cvCopy(tmp, q1, 0);
+ cvCopy(q4, tmp, 0);
+ cvCopy(q2, q4, 0);
+ cvCopy(tmp, q2, 0);
+ }
+}
+
+int main(int argc, char ** argv)
+{
+ if(atoi(argv[1])==1)
+ {
+ IplImage * im;
+ IplImage * im1;
+ IplImage * realInput;
+ IplImage * imaginaryInput;
+ IplImage * complexInput;
+
+ int dft_M, dft_N;
+ CvMat* dft_A, tmp;
+ IplImage * image_Re;
+ IplImage * image_Im;
+ IplImage * image_Re2;
+ IplImage * image_Im2;
+ double m, M;
+
+ im1 = cvLoadImage( argv[2],0 );
+ im = cvLoadImage( argv[2], CV_LOAD_IMAGE_GRAYSCALE );
+ if( !im )
+ return -1;
+
+ realInput = cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 1);
+ imaginaryInput = cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 1);
+ complexInput = cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 2);
+
+ cvScale(im, realInput, 1.0, 0.0);
+ cvZero(imaginaryInput);
+ cvMerge(realInput, imaginaryInput, NULL, NULL, complexInput);
+
+ dft_M = cvGetOptimalDFTSize( im->height - 1 );
+ dft_N = cvGetOptimalDFTSize( im->width - 1 );
+
+ dft_A = cvCreateMat( dft_M, dft_N, CV_64FC2 );
+ image_Re = cvCreateImage( cvSize(dft_N, dft_M), IPL_DEPTH_64F, 1);
+ image_Im = cvCreateImage( cvSize(dft_N, dft_M), IPL_DEPTH_64F, 1);
+ image_Re2 = cvCreateImage( cvSize(dft_N, dft_M), IPL_DEPTH_64F, 1);
+ image_Im2 = cvCreateImage( cvSize(dft_N, dft_M), IPL_DEPTH_64F, 1);
+
+ // copy A to dft_A and pad dft_A with zeros
+ cvGetSubRect( dft_A, &tmp, cvRect(0,0, im->width, im->height));
+ cvCopy( complexInput, &tmp, NULL );
+ if( dft_A->cols > im->width )
+ {
+ cvGetSubRect( dft_A, &tmp, cvRect(im->width,0, dft_A->cols -
+ im->width, im->height));
+ cvZero( &tmp );
+ }
+
+
+ cvDFT( dft_A, dft_A, CV_DXT_FORWARD, complexInput->height );
+
+ // Split Fourier in real and imaginary parts
+ cvSplit( dft_A, image_Re, image_Im, 0, 0 );
+ cvCopyImage(image_Re,image_Re2);
+ cvCopyImage(image_Im,image_Im2);
+
+ // Compute the magnitude of the spectrum Mag = sqrt(Re^2 + Im^2)
+ cvPow( image_Re, image_Re, 2.0);
+ cvPow( image_Im, image_Im, 2.0);
+ cvAdd( image_Re, image_Im, image_Re, NULL);
+ cvPow( image_Re, image_Re, 0.5 );
+
+ // compute the phase of the spectrum Phase = atan(Re/Im)
+ int r=cvGetSize(image_Re).height;
+ int c=cvGetSize(image_Re).width;
+ CvScalar s1,s2;
+ for (int i=0;iheight );
+ cvScale(dft_A,dft_A,0.001);
+
+ // Split Fourier in real and imaginary parts
+ cvSplit( dft_A, image_Re, image_Im, 0, 0 );
+
+ // Compute the magnitude of the spectrum Mag = sqrt(Re^2 + Im^2)
+ cvPow( image_Re, image_Re, 2.0);
+ cvPow( image_Im, image_Im, 2.0);
+ cvAdd( image_Re, image_Im, image_Re, NULL);
+ cvPow( image_Re, image_Re, 0.5 );
+
+ // Compute log(1 + Mag)
+ cvAddS( image_Re, cvScalarAll(1.0), image_Re, NULL ); // 1 + Mag
+ cvLog( image_Re, image_Re ); // log(1 + Mag)
+
+ cvMinMaxLoc(image_Re, &m, &M, NULL, NULL, NULL);
+ cvScale(image_Re, image_Re, 1.0/(M-m), 1.0*(-m)/(M-m));
+ minVal = 0; maxVal = 0;
+ cvMinMaxLoc(image_Re, &minVal, &maxVal, &minLoc, &maxLoc, 0);
+ cvCvtScaleAbs(image_Re,image_Re1,255.0*(maxVal-minVal),0);
+ //cvNamedWindow("inverse",0);
+ //cvShowImage("inverse",image_Re1);
+ //cvWaitKey(-1);
+
+ cvReleaseImage(&image_Re);
+ cvReleaseImage(&image_Re1);
+ cvReleaseImage(&image_Im);
+ cvReleaseImage(&im);
+ cvReleaseImage(&im1);
+ cvReleaseImage(&realInput);
+ cvReleaseImage(&imaginaryInput);
+ cvReleaseImage(&complexInput);
+ cvReleaseMat(&dft_A);
+ }
+ else if(atoi(argv[1])==2)
+ {
+ IplImage * magImage = cvLoadImage(argv[2],0);
+ IplImage * phaseImage = cvLoadImage(argv[3],0);
+ IplImage * realInput = cvCreateImage( cvGetSize(magImage), IPL_DEPTH_64F, 1);
+ IplImage * imaginaryInput = cvCreateImage( cvGetSize(magImage), IPL_DEPTH_64F, 1);
+ IplImage * complexInput = cvCreateImage( cvGetSize(magImage), IPL_DEPTH_64F, 2);
+ IplImage * realInput2 = cvCreateImage( cvGetSize(phaseImage), IPL_DEPTH_64F, 1);
+ IplImage * imaginaryInput2 = cvCreateImage( cvGetSize(phaseImage), IPL_DEPTH_64F, 1);
+ IplImage * complexInput2 = cvCreateImage( cvGetSize(phaseImage), IPL_DEPTH_64F, 2);
+
+ cvScale(magImage, realInput, 1.0, 0.0);
+ cvZero(imaginaryInput);
+ cvMerge(realInput, imaginaryInput, NULL, NULL, complexInput);
+ int dft_M = cvGetOptimalDFTSize( (magImage->height > phaseImage->height?magImage->height:phaseImage->height) - 1 );
+ int dft_N = cvGetOptimalDFTSize( (magImage->width > phaseImage->width?magImage->width:phaseImage->width) - 1 );
+ CvMat* dft_A, tmp;
+ dft_A = cvCreateMat( dft_M, dft_N, CV_64FC2 );
+ cvGetSubRect( dft_A, &tmp, cvRect(0,0, magImage->width, magImage->height));
+ cvCopy( complexInput, &tmp, NULL );
+ if( dft_A->cols > magImage->width )
+ {
+ cvGetSubRect( dft_A, &tmp, cvRect(magImage->width,0, dft_A->cols -
+ magImage->width, magImage->height));
+ cvZero( &tmp );
+ }
+ cvDFT( dft_A, dft_A, CV_DXT_FORWARD, complexInput->height );
+ IplImage * re = cvCreateImage( cvSize(dft_N,dft_M), IPL_DEPTH_64F, 1);
+ IplImage * im = cvCreateImage( cvSize(dft_N,dft_M), IPL_DEPTH_64F, 1);
+ IplImage * mag = cvCreateImage( cvSize(dft_N,dft_M), IPL_DEPTH_64F, 1);
+ cvSplit( dft_A, re, im, 0, 0 );
+ cvPow( re, re, 2.0);
+ cvPow( im, im, 2.0);
+ cvAdd( re, im, mag, NULL);
+ cvPow( mag, mag, 0.5 );
+
+ cvScale(phaseImage, realInput2, 1.0, 0.0);
+ cvZero(imaginaryInput2);
+ cvMerge(realInput2, imaginaryInput2, NULL, NULL, complexInput2);
+ //int dft_M2 = cvGetOptimalDFTSize( phaseImage->height - 1 );
+ //int dft_N2 = cvGetOptimalDFTSize( phaseImage->width - 1 );
+ CvMat* dft_A2, tmp2;
+ dft_A2 = cvCreateMat( dft_M, dft_N, CV_64FC2 );
+ cvGetSubRect( dft_A2, &tmp2, cvRect(0,0, phaseImage->width, phaseImage->height));
+ cvCopy( complexInput2, &tmp2, NULL );
+ if( dft_A2->cols > phaseImage->width )
+ {
+ cvGetSubRect( dft_A2, &tmp2, cvRect(phaseImage->width,0, dft_A2->cols -
+ phaseImage->width, phaseImage->height));
+ cvZero( &tmp2 );
+ }
+ cvDFT( dft_A2, dft_A2, CV_DXT_FORWARD, complexInput2->height );
+ cvSplit( dft_A2, re, im, 0, 0 );
+
+
+ IplImage *realOutput = cvCreateImage(cvSize(dft_N,dft_M),IPL_DEPTH_64F,1);
+ IplImage *imagOutput = cvCreateImage(cvSize(dft_N,dft_M),IPL_DEPTH_64F,1);
+ IplImage *complexOutput = cvCreateImage(cvSize(dft_N,dft_M),IPL_DEPTH_64F,2);
+ int r=cvGetSize(mag).height;
+ int c=cvGetSize(mag).width;
+ CvScalar s1,s2,s3,s4;
+ for (int i=0;iheight );
+ cvScale(dft_A,dft_A,0.001);
+ cvSplit( dft_A, realOutput, imagOutput, 0, 0 );
+ cvPow( realOutput, realOutput, 2.0);
+ cvPow( imagOutput, imagOutput, 2.0);
+ cvAdd( realOutput, imagOutput, realOutput, NULL);
+ cvPow( realOutput, realOutput, 0.5 );
+ cvAddS( realOutput, cvScalarAll(1.0), realOutput, NULL ); // 1 + Mag
+ cvLog( realOutput, realOutput ); // log(1 + Mag)
+ double m,M;
+ cvMinMaxLoc(realOutput, &m, &M, NULL, NULL, NULL);
+ cvScale(realOutput, realOutput, 1.0/(M-m), 1.0*(-m)/(M-m));
+ IplImage * Output = cvCreateImage(cvGetSize(realOutput),IPL_DEPTH_8U,1);
+ CvPoint minLoc, maxLoc;
+ double minVal = 0; double maxVal = 0;
+ cvMinMaxLoc(realOutput, &minVal, &maxVal, &minLoc, &maxLoc, 0);
+ cvCvtScaleAbs(realOutput,Output,255.0*(maxVal-minVal),0);
+ cvSaveImage(argv[4],Output);
+ //cvNamedWindow("impofphase",0);
+ //cvShowImage("impofphase",Output);
+ //cvWaitKey(-1);
+
+
+ cvReleaseImage(&re);
+ cvReleaseImage(&im);
+ cvReleaseImage(&mag);
+ cvReleaseImage(&magImage);
+ cvReleaseImage(&phaseImage);
+ cvReleaseImage(&realInput);
+ cvReleaseImage(&imaginaryInput);
+ cvReleaseImage(&complexInput);
+ cvReleaseImage(&realOutput);
+ cvReleaseImage(&imagOutput);
+ cvReleaseImage(&complexOutput);
+ cvReleaseImage(&Output);
+ cvReleaseMat(&dft_A);
+ }
+ else if(atoi(argv[1])==3)
+ {
+ IplImage * im = cvLoadImage(argv[2],0);
+ IplImage * realInput = cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 1);
+ IplImage * imaginaryInput = cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 1);
+ IplImage * complexInput = cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 2);
+ CvMat* dft_A, tmp;
+ int theta = atoi(argv[4]);
+ int rad = atoi(argv[5]);
+ int deltheta = atoi(argv[6]);
+ int delrad = atoi(argv[7]);
+ double angle1 = theta-(deltheta/2);
+ double angle2 = theta+(deltheta/2);
+ double angle3 = 180+theta-(deltheta/2);
+ double angle4 = 180+theta+(deltheta/2);
+ double val1 = atan((angle1==90||angle1==270||angle1==-90||angle1==-270)?MAXI:tan(PI/180*angle1));
+ double val2 = atan((angle1==90||angle1==270||angle1==-90||angle1==-270)?MAXI:tan(PI/180*angle2));
+ double val3 = atan((angle1==90||angle1==270||angle1==-90||angle1==-270)?MAXI:tan(PI/180*angle3));
+ double val4 = atan((angle1==90||angle1==270||angle1==-90||angle1==-270)?MAXI:tan(PI/180*angle4));
+
+ int dft_M, dft_N;
+ cvScale(im, realInput, 1.0, 0.0);
+ cvZero(imaginaryInput);
+ cvMerge(realInput, imaginaryInput, NULL, NULL, complexInput);
+ dft_M = cvGetOptimalDFTSize( im->height - 1 );
+ dft_N = cvGetOptimalDFTSize( im->width - 1 );
+ dft_A = cvCreateMat( dft_M, dft_N, CV_64FC2 );
+ cvGetSubRect( dft_A, &tmp, cvRect(0,0, im->width, im->height));
+ cvCopy( complexInput, &tmp, NULL );
+ if( dft_A->cols > im->width )
+ {
+ cvGetSubRect( dft_A, &tmp, cvRect(im->width,0, dft_A->cols -
+ im->width, im->height));
+ cvZero( &tmp );
+ }
+ cvDFT( dft_A, dft_A, CV_DXT_FORWARD, complexInput->height );
+ IplImage * re = cvCreateImage(cvSize(dft_N,dft_M),IPL_DEPTH_64F,1);
+ IplImage * imag = cvCreateImage(cvSize(dft_N,dft_M),IPL_DEPTH_64F,1);
+ cvSplit(dft_A,re,imag,0,0);
+
+ int r = cvGetSize(imag).height;
+ int c = cvGetSize(imag).width;
+ double dist,row,col,val;
+ CvScalar s;
+ for (int i=0;i=val2 && (val>=val1||val<=val2)) || (val3>=val4 && (val>=val3||val<=val4)))
+ {
+ s.val[0]=0.0;
+ cvSet2D(imag,i,j,s);
+ cvSet2D(re,i,j,s);
+ }
+ else if ((val>=val1 && val<=val2) || (val>=val3 && val<=val4))
+ {
+ s.val[0]=0.0;
+ cvSet2D(imag,i,j,s);
+ cvSet2D(re,i,j,s);
+ }
+ }
+ }
+ }
+ }
+
+ //cvNamedWindow("imaginary",0);
+ //cvShowImage("imaginary",imag);
+ //cvNamedWindow("real",0);
+ //cvShowImage("real",re);
+
+ cvMerge(re,imag,NULL,NULL,dft_A);
+ cvDFT( dft_A, dft_A, CV_DXT_INVERSE_SCALE, dft_N);
+ cvScale(dft_A,dft_A,0.001);
+ cvSplit(dft_A,re,imag,0,0);
+ cvPow(re,re,2);
+ cvPow(imag,imag,2);
+ cvAdd(re,imag,re,NULL);
+ cvPow(re,re,0.5);
+ cvAddS( re, cvScalarAll(1.0), re, NULL ); // 1 + Mag
+ cvLog( re, re); // log(1 + Mag)
+ double m,M;
+ cvMinMaxLoc(re, &m, &M, NULL, NULL, NULL);
+ cvScale(re, re, 1.0/(M-m), 1.0*(-m)/(M-m));
+ IplImage * Output = cvCreateImage(cvGetSize(re),IPL_DEPTH_8U,1);
+ CvPoint minLoc, maxLoc;
+ double minVal = 0; double maxVal = 0;
+ cvMinMaxLoc(re, &minVal, &maxVal, &minLoc, &maxLoc, 0);
+ cvCvtScaleAbs(re,Output,255.0*(maxVal-minVal),0);
+ cvSaveImage(argv[3],Output);
+
+ //cvNamedWindow("advfourier",0);
+ //cvShowImage("advfourier",Output);
+
+ //cvWaitKey(-1);
+
+ cvReleaseImage(&im);
+ cvReleaseImage(&realInput);
+ cvReleaseImage(&imaginaryInput);
+ cvReleaseImage(&complexInput);
+ cvReleaseImage(&re);
+ cvReleaseImage(&imag);
+ cvReleaseMat(&dft_A);
+ cvReleaseImage(&Output);
+ }
+
+ return 0;
+}
diff --git a/build/codes/im_hist.cpp b/build/codes/im_hist.cpp
new file mode 100755
index 00000000..2b17cd9d
--- /dev/null
+++ b/build/codes/im_hist.cpp
@@ -0,0 +1,339 @@
+#include
+#include
+#include
+#include
+using namespace std;
+
+IplImage* adapthist(IplImage* pln, int arg3, int arg4)
+{
+ int c=cvGetSize(pln).width;
+ int r=cvGetSize(pln).height;
+
+ IplImage *p4=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+
+ IplImage *temp=cvCreateImage(cvSize(arg3,arg4),IPL_DEPTH_8U,1);
+
+ CvScalar s;
+ for (int ii=0;ii=x)?0:x); ii=y)?0:y); jjbins, hist->bins, ((float)hist_img->height)/max_value, 0 );
+
+ // calculate width
+ w_scale = ((float)hist_img->width)/hist_size;
+
+ // plot the histogram
+ for( int i = 0; i < hist_size; i++ ) {
+
+ cvRectangle( hist_img, cvPoint((int)i*w_scale , hist_img->height),
+ cvPoint((int)(i+1)*w_scale, hist_img->height - cvRound(cvGetReal1D(hist->bins,i))),
+ CV_RGB(255,255,0), -1, 8, 0 );
+
+ }
+}
+IplImage* Pre_Process(IplImage* src,int bins)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+ for(int i=0;iwidth, source->height ), IPL_DEPTH_8U, 1 );
+ if(nbins!=256)
+ bin_img = Pre_Process(source,nbins);
+ else
+ bin_img = cvCloneImage(source);
+
+ int c = cvGetSize(bin_img).width;
+ int r = cvGetSize(bin_img).height;
+
+
+ if(atoi(argv[3])==1)
+ {
+ int mn=300,mx=-1,avg=0;
+ for(int i=0;i mx)
+ mx = s1.val[0];
+ avg+=s1.val[0];
+ }
+ }
+ avg = avg/(r*c);
+ IplImage *hist_img = cvCreateImage(cvSize(300,300), 8,3);
+ cvSet( hist_img, cvScalarAll(200), 0 );
+ create_histogram_image(bin_img, hist_img,nbins);
+ char nam[30];
+ int n = sprintf(nam,"%s.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+ cvReleaseImage( &source );
+ cvReleaseImage( &hist_img );
+ cvReleaseImage( &bin_img );
+ cout<width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
+ int mn4=300,mx4=-1,avg4=0;
+ for(int i=0;i mx4)
+ mx4 = s1.val[0];
+ avg4+=s1.val[0];
+ cvSet2D(bin_img1,i,j,s);
+ }
+ }
+ avg4 = 4*avg4/(r*c);
+
+ IplImage *hist_img = cvCreateImage(cvSize(300,300), 8, 3);
+ cvSet( hist_img, cvScalarAll(200), 0 );
+ create_histogram_image(bin_img1, hist_img,nbins);
+ char nam[30];
+ int n = sprintf(nam,"%s1.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+ IplImage *bin_img2 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
+ int mn1=300,mx1=-1,avg1=0;
+ for(int i=0;i mx1)
+ mx1 = s1.val[0];
+ avg1+=s1.val[0];
+
+ cvSet2D(bin_img2,i,j-c/2,s);
+ }
+ }
+ avg1 = 4*avg1/(r*c);
+
+ hist_img = cvCreateImage(cvSize(300,300), 8, 3);
+ cvSet( hist_img, cvScalarAll(200), 0 );
+ create_histogram_image(bin_img2, hist_img,nbins);
+ n = sprintf(nam,"%s2.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+ IplImage *bin_img3 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
+ int mn2=300,mx2=-1,avg2=0;
+ for(int i=r/2;i mx2)
+ mx2 = s1.val[0];
+ avg2+=s1.val[0];
+ cvSet2D(bin_img3,i-r/2,j,s);
+ }
+ }
+ avg2 = 4*avg2/(r*c);
+
+ hist_img = cvCreateImage(cvSize(300,300), 8, 3);
+ cvSet( hist_img, cvScalarAll(200), 0 );
+ create_histogram_image(bin_img3, hist_img,nbins);
+ n = sprintf(nam,"%s3.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+
+ IplImage *bin_img4 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
+ int mn3=300,mx3=-1,avg3=0;
+ for(int i=r/2;i mx3)
+ mx3 = s1.val[0];
+ avg3+=s1.val[0];
+ cvSet2D(bin_img4,i-r/2,j-c/2,s);
+ }
+ }
+ avg3 = 4*avg3/(r*c);
+
+ hist_img = cvCreateImage(cvSize(300,300), 8,3);
+ cvSet( hist_img, cvScalarAll(200), 0 );
+ create_histogram_image(bin_img4, hist_img,nbins);
+ n = sprintf(nam,"%s4.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+ cvReleaseImage( &source );
+ cvReleaseImage( &hist_img );
+ cvReleaseImage( &bin_img );
+ cvReleaseImage( &bin_img1 );
+ cvReleaseImage( &bin_img2 );
+ cvReleaseImage( &bin_img3 );
+ cvReleaseImage( &bin_img4 );
+
+ cout<
+#include
+#include
+#include
+using namespace std;
+
+void create_histogram_image(IplImage* bin_img, IplImage* hist_img,int bins) {
+ CvHistogram *hist;
+
+ int fc = 256/bins;
+ int hist_size = 256/fc;
+ float range[]={0,256/fc};
+ float* ranges[] = { range };
+ float max_value = 0.0;
+ float w_scale = 0.0;
+
+ // create array to hold histogram values
+ hist = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1);
+
+ // calculate histogram values
+ cvCalcHist( &bin_img, hist, 0, NULL );
+
+ // Get the minimum and maximum values of the histogram
+ cvGetMinMaxHistValue( hist, 0, &max_value, 0, 0 );
+
+ // set height by using maximim value
+ cvScale( hist->bins, hist->bins, ((float)hist_img->height)/max_value, 0 );
+
+ // calculate width
+ w_scale = ((float)hist_img->width)/hist_size;
+
+ // plot the histogram
+ for( int i = 0; i < hist_size; i++ ) {
+
+ cvRectangle( hist_img, cvPoint((int)i*w_scale , hist_img->height),
+ cvPoint((int)(i+1)*w_scale, hist_img->height - cvRound(cvGetReal1D(hist->bins,i))),
+ CV_RGB(255,255,0), -1, 8, 0 );
+
+ }
+}
+IplImage* Pre_Process(IplImage* src,int bins)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+ for(int i=0;iwidth, source->height ), IPL_DEPTH_8U, 1 );
+ if(nbins!=256)
+ bin_img = Pre_Process(source,nbins);
+ else
+ bin_img = cvCloneImage(source);
+
+ int c = cvGetSize(bin_img).width;
+ int r = cvGetSize(bin_img).height;
+
+
+ if(atoi(argv[4])==1)
+ {
+ int mn=300,mx=-1,avg=0;
+ for(int i=0;i mx)
+ mx = s1.val[0];
+ avg+=s1.val[0];
+ }
+ }
+ avg = avg/(r*c);
+ IplImage *hist_img = cvCreateImage(cvSize(300,300), 8,3);
+ cvSet( hist_img, cvScalarAll(200), 0 );
+ create_histogram_image(bin_img, hist_img,nbins);
+ char nam[50];
+ int n = sprintf(nam,"%s.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+ cvReleaseImage( &source );
+ cvReleaseImage( &hist_img );
+ cvReleaseImage( &bin_img );
+ cout<width/2, bin_img->height/2 ),bin_img->depth,bin_img->nChannels );
+ int mn4=300,mx4=-1,avg4=0;
+ for(int i=0;i mx4)
+ mx4 = s1.val[0];
+ avg4+=s1.val[0];
+ cvSet2D(bin_img1,i,j,s1);
+ }
+ }
+ avg4 = 4*avg4/(r*c);
+
+
+
+ IplImage *hist_img = cvCreateImage(cvSize(300,300), 8, 3);
+ cvSet( hist_img, cvScalarAll(200), 0 );
+ create_histogram_image(bin_img1, hist_img,nbins);
+ char nam[50];
+ int n = sprintf(nam,"%s1.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+// IplImage *bin_img2 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
+ IplImage *bin_img2 = cvCreateImage(cvSize( bin_img->width/2, bin_img->height/2 ),bin_img->depth,bin_img->nChannels );
+ int mn1=300,mx1=-1,avg1=0;
+ for(int i=0;i mx1)
+ mx1 = s1.val[0];
+ avg1+=s1.val[0];
+
+ cvSet2D(bin_img2,i,j-c/2,s1);
+ }
+ }
+ avg1 = 4*avg1/(r*c);
+
+
+ hist_img = cvCreateImage(cvSize(300,300), 8, 3);
+ cvSet( hist_img, cvScalarAll(200), 0 );
+ create_histogram_image(bin_img2, hist_img,nbins);
+ n = sprintf(nam,"%s2.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+ IplImage *bin_img3 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
+ int mn2=300,mx2=-1,avg2=0;
+ for(int i=r/2;i mx2)
+ mx2 = s1.val[0];
+ avg2+=s1.val[0];
+ cvSet2D(bin_img3,i-r/2,j,s1);
+ }
+ }
+ avg2 = 4*avg2/(r*c);
+
+ hist_img = cvCreateImage(cvSize(300,300), 8, 3);
+ cvSet( hist_img, cvScalarAll(200), 0 );
+ create_histogram_image(bin_img3, hist_img,nbins);
+ n = sprintf(nam,"%s3.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+
+ IplImage *bin_img4 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
+ int mn3=300,mx3=-1,avg3=0;
+ for(int i=r/2;i mx3)
+ mx3 = s1.val[0];
+ avg3+=s1.val[0];
+ cvSet2D(bin_img4,i-r/2,j-c/2,s1);
+ }
+ }
+ avg3 = 4*avg3/(r*c);
+
+
+ hist_img = cvCreateImage(cvSize(300,300), 8,3);
+ cvSet( hist_img, cvScalarAll(200), 0 );
+ create_histogram_image(bin_img4, hist_img,nbins);
+ n = sprintf(nam,"%s4.%s",img_nm,img_typ);
+ cvSaveImage(nam,hist_img);
+
+ cout<
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+int main(int argc, char ** argv)
+{
+ IplImage * magImage = cvLoadImage(argv[1],0);
+ IplImage * phaseImage = cvLoadImage(argv[2],0);
+ IplImage * realInput = cvCreateImage( cvGetSize(magImage), IPL_DEPTH_64F, 1);
+ IplImage * imaginaryInput = cvCreateImage( cvGetSize(magImage), IPL_DEPTH_64F, 1);
+ IplImage * complexInput = cvCreateImage( cvGetSize(magImage), IPL_DEPTH_64F, 2);
+
+ cvScale(magImage, realInput, 1.0, 0.0);
+ cvZero(imaginaryInput);
+ cvMerge(realInput, imaginaryInput, NULL, NULL, complexInput);
+ int dft_M = cvGetOptimalDFTSize( magImage->height - 1 );
+ int dft_N = cvGetOptimalDFTSize( magImage->width - 1 );
+ CvMat* dft_A, tmp;
+ dft_A = cvCreateMat( dft_M, dft_N, CV_64FC2 );
+
+ cvGetSubRect( dft_A, &tmp, cvRect(0,0, magImage->width, magImage->height));
+ cvCopy( complexInput, &tmp, NULL );
+ if( dft_A->cols > magImage->width )
+ {
+ cvGetSubRect( dft_A, &tmp, cvRect(magImage->width,0, dft_A->cols -
+ magImage->width, magImage->height));
+ cvZero( &tmp );
+ }
+
+ cvDFT( dft_A, dft_A, CV_DXT_FORWARD, complexInput->height );
+ IplImage * re = cvCreateImage( cvSize(dft_N,dft_M), IPL_DEPTH_64F, 1);
+ IplImage * im = cvCreateImage( cvSize(dft_N,dft_M), IPL_DEPTH_64F, 1);
+ IplImage * mag = cvCreateImage( cvSize(dft_N,dft_M), IPL_DEPTH_64F, 1);
+ cvSplit( dft_A, re, im, 0, 0 );
+ cvPow( re, re, 2.0);
+ cvPow( im, im, 2.0);
+ cvAdd( re, im, mag, NULL);
+ cvPow( mag, mag, 0.5 );
+
+ cvScale(phaseImage, realInput, 1.0, 0.0);
+ cvZero(imaginaryInput);
+ cvMerge(realInput, imaginaryInput, NULL, NULL, complexInput);
+ //int dft_M = cvGetOptimalDFTSize( im->height - 1 );
+ //int dft_N = cvGetOptimalDFTSize( im->width - 1 );
+ //cvMat* dft_A = cvCreateMat( dft_M, dft_N, CV_64FC2 );
+ //cvMat tmp;
+ cvGetSubRect( dft_A, &tmp, cvRect(0,0, phaseImage->width, phaseImage->height));
+ cvCopy( complexInput, &tmp, NULL );
+ if( dft_A->cols > phaseImage->width )
+ {
+ cvGetSubRect( dft_A, &tmp, cvRect(phaseImage->width,0, dft_A->cols -
+ phaseImage->width, phaseImage->height));
+ cvZero( &tmp );
+ }
+ cvDFT( dft_A, dft_A, CV_DXT_FORWARD, complexInput->height );
+ cvSplit( dft_A, re, im, 0, 0 );
+
+
+ IplImage *realOutput = cvCreateImage(cvSize(dft_N,dft_M),IPL_DEPTH_64F,1);
+ IplImage *imagOutput = cvCreateImage(cvSize(dft_N,dft_M),IPL_DEPTH_64F,1);
+ IplImage *complexOutput = cvCreateImage(cvSize(dft_N,dft_M),IPL_DEPTH_64F,2);
+ int r=cvGetSize(mag).height;
+ int c=cvGetSize(mag).width;
+ CvScalar s1,s2,s3,s4;
+ for (int i=0;iheight );
+ cvScale(dft_A,dft_A,0.001);
+ cvSplit( dft_A, realOutput, imagOutput, 0, 0 );
+ cvPow( realOutput, realOutput, 2.0);
+ cvPow( imagOutput, imagOutput, 2.0);
+ cvAdd( realOutput, imagOutput, realOutput, NULL);
+ cvPow( realOutput, realOutput, 0.5 );
+ cvAddS( realOutput, cvScalarAll(1.0), realOutput, NULL ); // 1 + Mag
+ cvLog( realOutput, realOutput ); // log(1 + Mag)
+ double m,M;
+ cvMinMaxLoc(realOutput, &m, &M, NULL, NULL, NULL);
+ cvScale(realOutput, realOutput, 1.0/(M-m), 1.0*(-m)/(M-m));
+ IplImage * Output = cvCreateImage(cvGetSize(realOutput),IPL_DEPTH_8U,1);
+ CvPoint minLoc, maxLoc;
+ double minVal = 0; double maxVal = 0;
+ cvMinMaxLoc(realOutput, &minVal, &maxVal, &minLoc, &maxLoc, 0);
+ cvCvtScaleAbs(realOutput,Output,255.0*(maxVal-minVal),0);
+ cvSaveImage("impofphase.jpg",Output);
+
+
+ cvReleaseImage(&re);
+ cvReleaseImage(&im);
+ cvReleaseImage(&mag);
+ cvReleaseImage(&magImage);
+ cvReleaseImage(&phaseImage);
+ cvReleaseImage(&realInput);
+ cvReleaseImage(&imaginaryInput);
+ cvReleaseImage(&complexInput);
+ cvReleaseImage(&realOutput);
+ cvReleaseImage(&imagOutput);
+ cvReleaseImage(&complexOutput);
+ cvReleaseImage(&Output);
+ cvReleaseMat(&dft_A);
+
+ return 0;
+}
diff --git a/build/codes/im_logical.cpp b/build/codes/im_logical.cpp
new file mode 100755
index 00000000..f6e92f7d
--- /dev/null
+++ b/build/codes/im_logical.cpp
@@ -0,0 +1,154 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+IplImage* imOR(IplImage *img1,IplImage *img2)
+{
+ int c = cvGetSize(img1).width;
+ int r = cvGetSize(img1).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ for(int i=0;i 0) or (s2.val[0] > 0))
+ grval = 255;
+ s.val[0] = grval;
+ cvSet2D(final_img,i,j,s);
+ }
+ }
+ return final_img;
+}
+
+IplImage* imAND(IplImage *img1,IplImage *img2)
+{
+ int c = cvGetSize(img1).width;
+ int r = cvGetSize(img1).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+ for(int i=0;i 0) and (s2.val[0] > 0))
+ grval = 255;
+ // cout<
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+// argv[2] indicates Operation
+// argv[3] indicates Shape
+// argv[3] indicates Size
+
+int main(int argc, char* argv[])
+{
+ IplImage* source = cvLoadImage(argv[1],0);
+
+ int col = cvGetSize(source).width;
+ int row = cvGetSize(source).height;
+
+ IplImage* temp = cvCreateImage(cvSize(col,row),IPL_DEPTH_8U,1);
+ IplImage* dest = cvCreateImage(cvSize(col,row),IPL_DEPTH_8U,1);
+
+ int a=atoi(argv[3]);
+ int b=atoi(argv[4]);
+ int c=atoi(argv[5]);
+
+ IplConvKernel* se;
+
+ if (b==1)
+ {
+ if (c==1)
+ se = cvCreateStructuringElementEx( 3, 3, 1, 1, CV_SHAPE_ELLIPSE, 0 );
+ else if (c==2)
+ se = cvCreateStructuringElementEx( 5, 5, 2, 2, CV_SHAPE_ELLIPSE, 0 );
+ else if (c==3)
+ se = cvCreateStructuringElementEx( 7, 7, 2, 2, CV_SHAPE_ELLIPSE, 0 );
+ }
+ else if (b==2)
+ {
+ if (c==1)
+ se = cvCreateStructuringElementEx( 3, 3, 1, 1, CV_SHAPE_RECT, 0 );
+ else if (c==2)
+ se = cvCreateStructuringElementEx( 5, 5, 2, 2, CV_SHAPE_RECT, 0 );
+ else if (c==3)
+ se = cvCreateStructuringElementEx( 7, 7, 2, 2, CV_SHAPE_RECT, 0 );
+ }
+ else if (b==3)
+ {
+ if (c==1)
+ se = cvCreateStructuringElementEx( 3, 3, 1, 1, CV_SHAPE_ELLIPSE, 0 );
+ else if (c==2)
+ se = cvCreateStructuringElementEx( 5, 5, 2, 2, CV_SHAPE_ELLIPSE, 0 );
+ else if (c==3)
+ se = cvCreateStructuringElementEx( 7, 7, 2, 2, CV_SHAPE_ELLIPSE, 0 );
+ }
+
+ if (a==1)
+ {
+ cvErode(source,dest,se,1);
+ }
+ else if (a==2)
+ {
+ cvDilate(source,dest,se,1);
+ }
+ else if (a==3)
+ {
+ cvErode(source,temp,se,1);
+ cvDilate(temp,dest,se,1);
+ }
+ else if (a==4)
+ {
+ cvDilate(source,temp,se,1);
+ cvErode(temp,dest,se,1);
+ }
+
+ CvScalar s1,s2;
+ for (int i=0;i
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+float sum=0;
+int parm;
+
+IplImage* linear(IplImage *img, float arr[][7])
+{
+ int c = cvGetSize(img).width;
+ int r = cvGetSize(img).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,img->nChannels);
+ for(int xp=0;xp=0 && xp-(parm/2)+i=0 && yp-(parm/2)+jnChannels);
+ for(int xp=0;xp grvals;
+
+ CvScalar s,s2;
+ s = cvGet2D(img,xp,yp);
+ for(int i=0;i=0 && xp-(parm/2)+i=0 && yp-(parm/2)+jdepth, src-> nChannels);
+ IplImage *temp1 = cvCreateImage(cvGetSize(src), src->depth, src-> nChannels);
+ IplImage *temp2 = cvCreateImage(cvGetSize(src), src->depth, src-> nChannels);
+
+ cvSmooth( src, temp1, CV_GAUSSIAN, 27, 27);
+ cvSub( src,temp1, temp2, NULL );
+
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ CvScalar s1,s2,s3;
+ for (int i=0;inChannels);
+ if(parm==2) {
+ parm=atoi(argv[4]);
+ nbrd_img=medn_filt(img1);
+ }
+ else {
+ for(int i=0;i
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+IplImage* imPATH(IplImage *img,int xs,int ys,int xd,int yd,int con,int gr)
+{
+ int c = cvGetSize(img).width;
+ int r = cvGetSize(img).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,3);
+ cvMerge(img,img,img,NULL,final_img);
+
+ int dst[r][c];
+ int srcx[r][c];
+ int srcy[r][c];
+ for(int i=0;i X;
+ queue Y;
+ srcx[xs][ys]=xs;
+ srcy[xs][ys]=ys;
+ X.push(xs);
+ Y.push(ys);
+ dst[xs][ys]=0;
+ int pth_found=0;
+
+ int xp,yp;
+ while(!X.empty())
+ {
+ xp = X.front();
+ yp = Y.front();
+/* cout<<"last "<=0)
+ s1 = cvGet2D(img,xp-1,yp);
+ if(con==8 and (xp -1 >= 0) and (yp+1 =0))
+ s7 = cvGet2D(img,xp+1,yp-1);
+
+ if(yp-1 >=0)
+ s4 = cvGet2D(img,xp,yp-1);
+ if(con==8 and (xp-1 >=0) and (yp-1 >=0))
+ s8 = cvGet2D(img,xp-1,yp-1);
+
+ if(s1.val[0] ==gr)
+ {
+ if(dst[xp-1][yp] > dst[xp][yp] + 1)
+ {
+ dst[xp-1][yp]=dst[xp][yp]+1;
+ srcx[xp-1][yp]=xp;
+ srcy[xp-1][yp]=yp;
+ X.push(xp-1);
+ Y.push(yp);
+ }
+ }
+
+
+ if(s2.val[0] ==gr)
+ {
+ if(dst[xp][yp+1] > dst[xp][yp] + 1)
+ {
+ dst[xp][yp+1]=dst[xp][yp]+1;
+ srcx[xp][yp+1]=xp;
+ srcy[xp][yp+1]=yp;
+ X.push(xp);
+ Y.push(yp+1);
+ }
+ }
+
+
+ if(s3.val[0] ==gr)
+ {
+ if(dst[xp+1][yp] > dst[xp][yp] + 1)
+ {
+ dst[xp+1][yp]=dst[xp][yp]+1;
+ srcx[xp+1][yp]=xp;
+ srcy[xp+1][yp]=yp;
+ X.push(xp+1);
+ Y.push(yp);
+ }
+ }
+
+
+ if(s4.val[0] ==gr)
+ {
+ if(dst[xp][yp-1] > dst[xp][yp] + 1)
+ {
+ dst[xp][yp-1]=dst[xp][yp]+1;
+ srcx[xp][yp-1]=xp;
+ srcy[xp][yp-1]=yp;
+ X.push(xp);
+ Y.push(yp-1);
+ }
+ }
+
+ if(s5.val[0] ==gr)
+ {
+ if(dst[xp-1][yp+1] > dst[xp][yp] + 1)
+ {
+ dst[xp-1][yp+1]=dst[xp][yp]+1;
+ srcx[xp-1][yp+1]=xp;
+ srcy[xp-1][yp+1]=yp;
+ X.push(xp-1);
+ Y.push(yp+1);
+ }
+ }
+
+ if(s6.val[0] ==gr)
+ {
+ if(dst[xp+1][yp+1] > dst[xp][yp] + 1)
+ {
+ dst[xp+1][yp+1]=dst[xp][yp]+1;
+ srcx[xp+1][yp+1]=xp;
+ srcy[xp+1][yp+1]=yp;
+ X.push(xp+1);
+ Y.push(yp+1);
+ }
+ }
+
+ if(s7.val[0] ==gr)
+ {
+ if(dst[xp+1][yp-1] > dst[xp][yp] + 1)
+ {
+ dst[xp+1][yp-1]=dst[xp][yp]+1;
+ srcx[xp+1][yp-1]=xp;
+ srcy[xp+1][yp-1]=yp;
+ X.push(xp+1);
+ Y.push(yp-1);
+ }
+ }
+
+ if(s8.val[0] ==gr)
+ {
+ if(dst[xp-1][yp-1] > dst[xp][yp] + 1)
+ {
+ dst[xp-1][yp-1]=dst[xp][yp]+1;
+ srcx[xp-1][yp-1]=xp;
+ srcy[xp-1][yp-1]=yp;
+ X.push(xp-1);
+ Y.push(yp-1);
+ }
+ }
+ }
+
+ int tx=xd,ty=yd;
+ if(!pth_found)
+ {
+ cout<<"Path not found\n";
+ tx = xp;
+ ty = yp;
+// cout<<"point "<
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+IplImage* imPATH(IplImage *img,int xs,int ys,int xd,int yd)
+{
+ int c = cvGetSize(img).width;
+ int r = cvGetSize(img).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+
+ int dst[r][c];
+ for(int i=0;i X;
+ queue Y;
+ srcx[xs][ys]=xs;
+ srcy[xs][ys]=ys;
+ X.push(xs);
+ Y.push(ys);
+ dst[xs][ys]=0;
+ int pth_found=0;
+
+ int xp,yp;
+ while(!X.empty())
+ {
+ xp = X.front();
+ yp = Y.front();
+// cout<=0)
+ s1 = cvGet2D(img,xp-1,yp);
+ if(yp+1 < c)
+ s2 = cvGet2D(img,xp,yp+1);
+ if(xp+1 < r)
+ s3 = cvGet2D(img,xp+1,yp);
+ if(yp-1 >=0)
+ s4 = cvGet2D(img,xp,yp-1);
+ if(s1.val[0] > 0)
+ {
+ if(dst[xp-1][yp] > dst[xp][yp] + 1)
+ {
+ dst[xp-1][yp]=dst[xp][yp]+1;
+ srcx[xp-1][yp]=xp;
+ srcy[xp-1][yp]=yp;
+ X.push(xp-1);
+ Y.push(yp);
+ }
+ }
+ if(s2.val[0] > 0)
+ {
+ if(dst[xp][yp+1] > dst[xp][yp] + 1)
+ {
+ dst[xp][yp+1]=dst[xp][yp]+1;
+ srcx[xp][yp+1]=xp;
+ srcy[xp][yp+1]=yp;
+ X.push(xp);
+ Y.push(yp+1);
+ }
+ }
+ if(s3.val[0] > 0)
+ {
+ if(dst[xp+1][yp] > dst[xp][yp] + 1)
+ {
+ dst[xp+1][yp]=dst[xp][yp]+1;
+ srcx[xp+1][yp]=xp;
+ srcy[xp+1][yp]=yp;
+ X.push(xp+1);
+ Y.push(yp);
+ }
+ }
+ if(s4.val[0] > 0)
+ {
+ if(dst[xp][yp-1] > dst[xp][yp] + 1)
+ {
+ dst[xp][yp-1]=dst[xp][yp]+1;
+ srcx[xp][yp-1]=xp;
+ srcy[xp][yp-1]=yp;
+ X.push(xp);
+ Y.push(yp-1);
+ }
+ }
+ }
+
+ if(!pth_found)
+ {
+ cout<<"path not found\n";
+ xd = xp;
+ yd = yp;
+ cout<0 and sd.val[0]>0)
+ {
+ // cout<<"here :S \n";
+ IplImage* path_img=cvCreateImage(cvSize(c1,r1),IPL_DEPTH_8U,1);
+ path_img=imPATH(img1,xs,ys,xd,yd);
+ cvSaveImage(argv[2],path_img);
+ cvReleaseImage( &path_img );
+ }
+ cvReleaseImage( &img1 );
+ return 0;
+}
diff --git a/build/codes/im_path_bw.cpp b/build/codes/im_path_bw.cpp
new file mode 100755
index 00000000..0da8e0e0
--- /dev/null
+++ b/build/codes/im_path_bw.cpp
@@ -0,0 +1,271 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+IplImage* imPATH(IplImage *img,int xs,int ys,int xd,int yd,int con)
+{
+ int c = cvGetSize(img).width;
+ int r = cvGetSize(img).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(c,r),IPL_DEPTH_8U,1);
+
+ int dst[r][c];
+ int srcx[r][c];
+ int srcy[r][c];
+ for(int i=0;i X;
+ queue Y;
+ srcx[xs][ys]=xs;
+ srcy[xs][ys]=ys;
+ X.push(xs);
+ Y.push(ys);
+ dst[xs][ys]=0;
+ int pth_found=0;
+
+ int xp,yp;
+ while(!X.empty())
+ {
+ xp = X.front();
+ yp = Y.front();
+/* cout<<"last "<=0)
+ s1 = cvGet2D(img,xp-1,yp);
+ if(con==8 and (xp -1 >= 0) and (yp+1 =0))
+ s7 = cvGet2D(img,xp+1,yp-1);
+
+ if(yp-1 >=0)
+ s4 = cvGet2D(img,xp,yp-1);
+ if(con==8 and (xp-1 >=0) and (yp-1 >=0))
+ s8 = cvGet2D(img,xp-1,yp-1);
+
+ if(s1.val[0] > 0)
+ {
+ if(dst[xp-1][yp] > dst[xp][yp] + 1)
+ {
+ dst[xp-1][yp]=dst[xp][yp]+1;
+ srcx[xp-1][yp]=xp;
+ srcy[xp-1][yp]=yp;
+ X.push(xp-1);
+ Y.push(yp);
+ }
+ }
+
+ if(s5.val[0] > 0)
+ {
+ if(dst[xp-1][yp+1] > dst[xp][yp] + 1)
+ {
+ dst[xp-1][yp+1]=dst[xp][yp]+1;
+ srcx[xp-1][yp+1]=xp;
+ srcy[xp-1][yp+1]=yp;
+ X.push(xp-1);
+ Y.push(yp+1);
+ }
+ }
+
+ if(s2.val[0] > 0)
+ {
+ if(dst[xp][yp+1] > dst[xp][yp] + 1)
+ {
+ dst[xp][yp+1]=dst[xp][yp]+1;
+ srcx[xp][yp+1]=xp;
+ srcy[xp][yp+1]=yp;
+ X.push(xp);
+ Y.push(yp+1);
+ }
+ }
+
+ if(s6.val[0] > 0)
+ {
+ if(dst[xp+1][yp+1] > dst[xp][yp] + 1)
+ {
+ dst[xp+1][yp+1]=dst[xp][yp]+1;
+ srcx[xp+1][yp+1]=xp;
+ srcy[xp+1][yp+1]=yp;
+ X.push(xp+1);
+ Y.push(yp+1);
+ }
+ }
+
+ if(s3.val[0] > 0)
+ {
+ if(dst[xp+1][yp] > dst[xp][yp] + 1)
+ {
+ dst[xp+1][yp]=dst[xp][yp]+1;
+ srcx[xp+1][yp]=xp;
+ srcy[xp+1][yp]=yp;
+ X.push(xp+1);
+ Y.push(yp);
+ }
+ }
+
+ if(s7.val[0] > 0)
+ {
+ if(dst[xp+1][yp-1] > dst[xp][yp] + 1)
+ {
+ dst[xp+1][yp-1]=dst[xp][yp]+1;
+ srcx[xp+1][yp-1]=xp;
+ srcy[xp+1][yp-1]=yp;
+ X.push(xp+1);
+ Y.push(yp-1);
+ }
+ }
+
+ if(s4.val[0] > 0)
+ {
+ if(dst[xp][yp-1] > dst[xp][yp] + 1)
+ {
+ dst[xp][yp-1]=dst[xp][yp]+1;
+ srcx[xp][yp-1]=xp;
+ srcy[xp][yp-1]=yp;
+ X.push(xp);
+ Y.push(yp-1);
+ }
+ }
+
+ if(s8.val[0] > 0)
+ {
+ if(dst[xp-1][yp-1] > dst[xp][yp] + 1)
+ {
+ dst[xp-1][yp-1]=dst[xp][yp]+1;
+ srcx[xp-1][yp-1]=xp;
+ srcy[xp-1][yp-1]=yp;
+ X.push(xp-1);
+ Y.push(yp-1);
+ }
+ }
+ }
+
+ int tx,ty;
+ if(!pth_found)
+ {
+// cout<<"path not found\n";
+ tx = xp;
+ ty = yp;
+// cout<<"point "<0 and sd.val[0]>0)
+ {
+ // cout<<"here :S \n";
+ IplImage* path_img=cvCreateImage(cvSize(c1,r1),IPL_DEPTH_8U,1);
+ path_img=imPATH(img1,xs,ys,xd,yd,con);
+ cvSaveImage(argv[2],path_img);
+ cvReleaseImage( &path_img );
+ }
+ cvReleaseImage( &img1 );
+ return 0;
+}
diff --git a/build/codes/im_point.cpp b/build/codes/im_point.cpp
new file mode 100755
index 00000000..a4fc731f
--- /dev/null
+++ b/build/codes/im_point.cpp
@@ -0,0 +1,185 @@
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+IplImage* Log_Image(IplImage *src,int cn)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+ for(int i=0;i 255)
+ grval= 255;
+ if(grval < 0)
+ grval = 0;
+ s.val[0] = grval;
+ cvSet2D(final_img,i,j,s);
+ }
+ }
+ return final_img;
+}
+
+IplImage* Contrast_Stretch(IplImage *src,float a,float b)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+ for(int i=0;i 255)
+ grval = 255;
+ else if(grval < 0)
+ grval = 0;
+ s.val[0] = grval;
+ cvSet2D(final_img,i,j,s);
+
+ }
+ }
+ return final_img;
+}
+
+IplImage* Clipped_Image(IplImage *src,float a,float b,float beta)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+ for(int i=0;i (int)(b))
+ grval = 255;
+ else
+ grval = (int)(beta * grval);
+ if(grval > 255)
+ grval = 255;
+ s.val[0] = grval;
+ cvSet2D(final_img,i,j,s);
+ }
+ }
+ return final_img;
+}
+
+IplImage* Windowed_Image(IplImage *src,float a,float b,float beta)
+{
+ int c = cvGetSize(src).width;
+ int r = cvGetSize(src).height;
+
+ IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ cvZero(final_img);
+ for(int i=0;i (int)(b)))
+ grval = 0;
+ else
+ grval = (int)(beta * grval);
+ if(grval > 255)
+ grval = 255;
+ s.val[0] = grval;
+ cvSet2D(final_img,i,j,s);
+ }
+ }
+ return final_img;
+}
+
+int main(int argc,char *argv[])
+{
+ int p[3];
+ p[0] = CV_IMWRITE_JPEG_QUALITY;
+ p[1] = 90;
+ p[2] = 0;
+
+ char *img_nm,*img_typ;
+ IplImage* src = cvLoadImage(argv[1],0);
+ IplImage* dst;
+
+ char *pch,*rem,*f_img;
+ pch = strtok (argv[1],"/");
+ while (pch != NULL)
+ {
+ f_img = pch;
+ pch = strtok (NULL, "/");
+
+ }
+
+ img_nm = strtok (f_img,".");
+ img_typ = strtok (NULL, ".");
+
+
+ if(atoi(argv[3])==1)
+ {
+// cout<<"2\n";
+ float a,b;
+ a = atof(argv[4]);
+ b = atof(argv[5]);
+ dst=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ dst=Contrast_Stretch(src,a,b);
+ }
+ if(atoi(argv[3])==2)
+ {
+// cout<<"3\n";
+ int c;
+ c = atof(argv[4]);
+ dst=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ dst=Log_Image(src,c);
+ }
+
+ if(atoi(argv[3])==3)
+ {
+ float a,b,beta;
+ a = atof(argv[4]);
+ b = atof(argv[5]);
+ beta = atof(argv[6]);
+ dst=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ dst=Clipped_Image(src,a,b,beta);
+ }
+
+ if(atoi(argv[3])==4)
+ {
+ float a,b,beta;
+ a = atof(argv[4]);
+ b = atof(argv[5]);
+ float slope = atof(argv[6]);
+ dst=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
+ dst=Windowed_Image(src,a,b,slope);
+ }
+
+
+
+ cvSaveImage(argv[2],dst);
+ cvReleaseImage( &src );
+ cvReleaseImage( &dst);
+ return 0;
+}
diff --git a/build/codes/im_resample.cpp b/build/codes/im_resample.cpp
new file mode 100755
index 00000000..5c21e238
--- /dev/null
+++ b/build/codes/im_resample.cpp
@@ -0,0 +1,91 @@
+#include
+#include
+#include