Skip to content

Commit 1d74b69

Browse files
Merge pull request #4 from virtual-labs/testing
removed old header in the simulation page
2 parents 34ce0c7 + 3c26f64 commit 1d74b69

File tree

937 files changed

+63129
-1041
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

937 files changed

+63129
-1041
lines changed

experiment/simulation/build/1.png

44.6 KB
Loading

experiment/simulation/build/2.png

95.6 KB
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export OPENCV_INC=/usr/include/opencv
2+
export OPENCV_LIB=/usr/lib/
3+
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"
4+
5+
sudo apt-get update
6+
sudo apt-get install -y gcc
7+
sudo apt-get update
8+
gcc -I$OPENCV_INC codes/latest_affine.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/affine.out
9+
gcc -I$OPENCV_INC codes/im_arith.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/arith.out
10+
gcc -I$OPENCV_INC codes/im_dist.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/dist.out
11+
gcc -I$OPENCV_INC codes/im_fourier.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/fourier.out
12+
gcc -I$OPENCV_INC codes/im_hist.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/hist.out
13+
gcc -I$OPENCV_INC codes/im_morphology.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/morpho.out
14+
gcc -I$OPENCV_INC codes/im_nbrhood.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/neigh.out
15+
gcc -I$OPENCV_INC codes/im_path.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/path.out
16+
gcc -I$OPENCV_INC codes/im_point.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/point.out
17+
gcc -I$OPENCV_INC codes/im_segment.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/segment.out
18+
gcc -I$OPENCV_INC codes/im_colour.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/colour.out
19+
gcc -I$OPENCV_INC codes/im_colourLin.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/colour2.out
20+
gcc -I$OPENCV_INC codes/im_colhist.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/colour3.out
21+
gcc -I$OPENCV_INC codes/im_colhist.cpp -L$OPENCV_LIB $OPENCV_LIB_OPTS -o execs/colhist.out
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- Google Analytics Code starts here -->
2+
<script>
3+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
4+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
5+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
6+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
7+
8+
ga('create', 'UA-42255654-1', 'virtual-labs.ac.in');
9+
ga('send', 'pageview');
10+
11+
</script>
12+
<!-- Google Analytics Code ends here -->
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
session_start();
3+
$exp=$_GET["exp"];
4+
?>
5+
6+
<head>
7+
<script class='gtm'>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-W59SWTR');</script>
8+
9+
<title> Assignment - Virtual Lab in Image Processing</title>
10+
<!-- The Primary External CSS style sheet. -->
11+
<link rel="stylesheet" type="text/css" href="css/psd2css.css" media="screen" />
12+
13+
<!-- We use the jquery javascript library for DOM manipulation and
14+
some javascript tricks. We serve the script from Google because it's
15+
faster than most ISPs. Get more information and documentation
16+
at http://jquery.com
17+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> -->
18+
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
19+
20+
<!-- All the javascript generated for your design is in this file -->
21+
<script type="text/javascript" src="js/psd2css.js"></script>
22+
23+
<!--http://www.cssmenumaker.com/builder/menu_info.php?menu=057-->
24+
<link type="text/css" rel="StyleSheet" href="menu/menu_style.css" />
25+
26+
27+
</head>
28+
29+
30+
<body>
31+
32+
<!-- This is 'Backgound_bkgnd_center_jpg' -->
33+
<div id="Layer-1" class="Backgound_bkgnd_center_jpg" >
34+
35+
36+
<!-- This is 'TopBar_jpg' -->
37+
<div id="Layer-3" class="TopBar_jpg" >
38+
<!-- <img src="images/Layer-3.jpg" width="894" height="96" alt="TopBar" /> -->
39+
<!-- This is 'IIIT' -->
40+
<!-- <div id="Layer-6" class="IIIT" >
41+
<img src="images/iiit.png" width="100" height="70" alt="IIIT" class="pngimg" />
42+
</div>
43+
44+
<div id="topMenu">
45+
<h1>VIRTUAL LAB in IMAGE PROCESSING</h1>
46+
<div class="home">
47+
<a href="index.html">home</a>
48+
</div>
49+
50+
<div class="menu">
51+
<ul>
52+
<li><a href="objective.php?exp=<?php echo $exp; ?>" target="_self" >Objective</a>
53+
</li>
54+
<li><a href="intro.php?exp=<?php echo $exp; ?>" target="_self" >Introduction</a>
55+
</li>
56+
<li><a href="theory.php?exp=<?php echo $exp; ?>" target="_self" >Theory</a>
57+
</li>
58+
<li><a href="procedure.php?exp=<?php echo $exp; ?>" target="_self" >Procedure</a>
59+
</li>
60+
<li><a href="<?php echo $exp; ?>.php" target="_self" >Experiment</a>
61+
</li> -->
62+
<!-- <li><sel><a href="#" target="_self" >Assessment</a>
63+
</sel>
64+
--> <!-- <ul>
65+
<li><a href="quiz.php?exp=<?php echo $exp; ?>">Quiz</a></li> -->
66+
<li><a href="assign.php?exp=<?php echo $exp; ?>">Assignment</a></li>
67+
<!-- </ul>
68+
69+
</li> -->
70+
<!-- <li><a href="references.php?exp=<?php echo $exp; ?>" target="_self" >References</a>
71+
</li> -->
72+
</ul>
73+
</div>
74+
</div>
75+
<div class="experiment front" style="text-indent: 20px; background-color: #DDDDDD;" >
76+
77+
<b>Obtain the figure of the right from the figure on the left.</b>
78+
<br/><br/>
79+
<img src="images/temp/<?php echo $exp; ?>1_1.<?php if($exp=="colour") { echo 'jpg'; } else { echo 'png';} ?>"/>&nbsp;&nbsp; <img src="images/temp/<?php echo $exp; ?>1_1_result.<?php if($exp=="colour") { echo 'jpg'; } else { echo 'png';} ?>"/>
80+
<br/>
81+
82+
Click <a href="<?php echo $exp; ?>.php?assess=<?php echo $exp; ?>1" target="_blank">here</a> to try it out.
83+
</div>
84+
</div>
85+
</body>
86+
87+
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
#include <opencv/cv.h>
2+
#include <opencv/highgui.h>
3+
#include <stdio.h>
4+
#include<iostream>
5+
using namespace std;
6+
7+
void create_histogram_image(IplImage* bin_img, IplImage* hist_img,int bins) {
8+
CvHistogram *hist;
9+
10+
int fc = 256/bins;
11+
int hist_size = 256/fc;
12+
float range[]={0,256/fc};
13+
float* ranges[] = { range };
14+
float max_value = 0.0;
15+
float w_scale = 0.0;
16+
17+
// create array to hold histogram values
18+
hist = cvCreateHist(1, &hist_size, CV_HIST_ARRAY, ranges, 1);
19+
20+
// calculate histogram values
21+
cvCalcHist( &bin_img, hist, 0, NULL );
22+
23+
// Get the minimum and maximum values of the histogram
24+
cvGetMinMaxHistValue( hist, 0, &max_value, 0, 0 );
25+
26+
// set height by using maximim value
27+
cvScale( hist->bins, hist->bins, ((float)hist_img->height)/max_value, 0 );
28+
29+
// calculate width
30+
w_scale = ((float)hist_img->width)/hist_size;
31+
32+
// plot the histogram
33+
for( int i = 0; i < hist_size; i++ ) {
34+
35+
cvRectangle( hist_img, cvPoint((int)i*w_scale , hist_img->height),
36+
cvPoint((int)(i+1)*w_scale, hist_img->height - cvRound(cvGetReal1D(hist->bins,i))),
37+
cvScalar(0), -1, 8, 0 );
38+
39+
}
40+
}
41+
IplImage* Pre_Process(IplImage* src,int bins)
42+
{
43+
int c = cvGetSize(src).width;
44+
int r = cvGetSize(src).height;
45+
46+
IplImage* final_img=cvCreateImage(cvSize(src->width,src->height),src->depth,src->nChannels);
47+
cvZero(final_img);
48+
for(int i=0;i<r;i++)
49+
{
50+
for(int j=0;j<c;j++)
51+
{
52+
CvScalar s1,s;
53+
s1 = cvGet2D(src,i,j);
54+
int grval = s1.val[0];
55+
if(bins==32)
56+
grval = grval/8;
57+
if(bins==64)
58+
grval = grval/4;
59+
if(bins==128)
60+
grval = grval/2;
61+
// cout<<grval<<" ";
62+
s.val[0]=grval;
63+
cvSet2D(final_img,i,j,s);
64+
}
65+
}
66+
return final_img;
67+
}
68+
69+
int main( int argc, char** argv )
70+
71+
{
72+
IplImage *source = cvLoadImage(argv[1],0);
73+
char *img_nm,*img_typ;
74+
img_nm = strtok (argv[2],".");
75+
img_typ = strtok (NULL, ".");
76+
int nbins = atoi(argv[3]);
77+
IplImage *bin_img = cvCreateImage(cvSize( source->width, source->height ), IPL_DEPTH_8U, 1 );
78+
if(nbins!=256)
79+
bin_img = Pre_Process(source,nbins);
80+
else
81+
bin_img = cvCloneImage(source);
82+
83+
int c = cvGetSize(bin_img).width;
84+
int r = cvGetSize(bin_img).height;
85+
86+
IplImage *bin_img1 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
87+
int mn4=300,mx4=-1,avg4=0;
88+
for(int i=0;i<r/2;i++)
89+
{
90+
for(int j=0;j<c/2;j++)
91+
{
92+
CvScalar s;
93+
s = cvGet2D(bin_img,i,j);
94+
if(s.val[0] < mn4)
95+
mn4 = s.val[0];
96+
if(s.val[0] > mx4)
97+
mx4 = s.val[0];
98+
avg4+=s.val[0];
99+
cvSet2D(bin_img1,i,j,s);
100+
}
101+
}
102+
avg4 = 4*avg4/(r*c);
103+
104+
IplImage *hist_img = cvCreateImage(cvSize(300,300), 8, 1);
105+
cvSet( hist_img, cvScalarAll(255), 0 );
106+
create_histogram_image(bin_img1, hist_img,nbins);
107+
char nam[30];
108+
int n = sprintf(nam,"%s_1.%s",img_nm,img_typ);
109+
cvSaveImage(nam,hist_img);
110+
111+
IplImage *bin_img2 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
112+
int mn1=300,mx1=-1,avg1=0;
113+
for(int i=0;i<r/2;i++)
114+
{
115+
for(int j=c/2;j<c;j++)
116+
{
117+
CvScalar s;
118+
s = cvGet2D(bin_img,i,j);
119+
if(s.val[0] < mn1)
120+
mn1 = s.val[0];
121+
if(s.val[0] > mx1)
122+
mx1 = s.val[0];
123+
avg1+=s.val[0];
124+
cvSet2D(bin_img2,i,j-c/2,s);
125+
}
126+
}
127+
avg1 = 4*avg1/(r*c);
128+
129+
hist_img = cvCreateImage(cvSize(300,300), 8, 1);
130+
cvSet( hist_img, cvScalarAll(255), 0 );
131+
create_histogram_image(bin_img2, hist_img,nbins);
132+
n = sprintf(nam,"%s_2.%s",img_nm,img_typ);
133+
cvSaveImage(nam,hist_img);
134+
135+
IplImage *bin_img3 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
136+
int mn2=300,mx2=-1,avg2=0;
137+
for(int i=r/2;i<r;i++)
138+
{
139+
for(int j=0;j<c/2;j++)
140+
{
141+
CvScalar s;
142+
s = cvGet2D(bin_img,i,j);
143+
if(s.val[0] < mn2)
144+
mn2 = s.val[0];
145+
if(s.val[0] > mx2)
146+
mx2 = s.val[0];
147+
avg2+=s.val[0];
148+
cvSet2D(bin_img3,i-r/2,j,s);
149+
}
150+
}
151+
avg2 = 4*avg2/(r*c);
152+
153+
hist_img = cvCreateImage(cvSize(300,300), 8, 1);
154+
cvSet( hist_img, cvScalarAll(255), 0 );
155+
create_histogram_image(bin_img3, hist_img,nbins);
156+
n = sprintf(nam,"%s_3.%s",img_nm,img_typ);
157+
cvSaveImage(nam,hist_img);
158+
159+
160+
IplImage *bin_img4 = cvCreateImage(cvSize( source->width/2, source->height/2 ), IPL_DEPTH_8U, 1 );
161+
int mn3=300,mx3=-1,avg3=0;
162+
for(int i=r/2;i<r;i++)
163+
{
164+
for(int j=c/2;j<c;j++)
165+
{
166+
CvScalar s;
167+
s = cvGet2D(bin_img,i,j);
168+
if(s.val[0] < mn3)
169+
mn3 = s.val[0];
170+
if(s.val[0] > mx3)
171+
mx3 = s.val[0];
172+
avg3+=s.val[0];
173+
cvSet2D(bin_img4,i-r/2,j-c/2,s);
174+
}
175+
}
176+
avg3 = 4*avg3/(r*c);
177+
178+
hist_img = cvCreateImage(cvSize(300,300), 8, 1);
179+
cvSet( hist_img, cvScalarAll(255), 0 );
180+
create_histogram_image(bin_img4, hist_img,nbins);
181+
n = sprintf(nam,"%s_4.%s",img_nm,img_typ);
182+
cvSaveImage(nam,hist_img);
183+
184+
cvReleaseImage( &source );
185+
cvReleaseImage( &hist_img );
186+
cvReleaseImage( &bin_img );
187+
cvReleaseImage( &bin_img1 );
188+
cvReleaseImage( &bin_img2 );
189+
cvReleaseImage( &bin_img3 );
190+
cvReleaseImage( &bin_img4 );
191+
192+
cout<<mn1<<" "<<mx1<<" "<<avg1<<" "<<mn2<<" "<<mx2<<" "<<avg2<<" "<<mn3<<" "<<mx3<<" "<<avg3<<" "<<mn4<<" "<<mx4<<" "<<avg4<<endl;
193+
return 0;
194+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o affine.out latest_affine.cpp
2+
./affine.out stock1.jpg dst.jpg 1 0 1 186 88 64 3 2 1
3+
# display stock1.jpg
4+
# display dst.jpg
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
gcc -I/home/intel/opencv/include/opencv -L/home/intel/opencv/lib -lcv -lhighgui -lstdc++ -o arith.out im_arith.cpp
2+
./arith.out dst_1.jpg dst_2.jpg dst.jpg 3 2
3+
display dst_1.jpg
4+
display dst_2.jpg
5+
display dst.jpg
6+

0 commit comments

Comments
 (0)