Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
14d0b763
Commit
14d0b763
authored
Apr 11, 2014
by
siddharth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed demo tutorial path
parent
1a14d850
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
378 additions
and
0 deletions
+378
-0
decolor.cpp
samples/cpp/tutorial_code/photo/decolorization/decolor.cpp
+36
-0
npr_demo.cpp
...rial_code/photo/non_photorealistic_rendering/npr_demo.cpp
+96
-0
cloning_demo.cpp
...cpp/tutorial_code/photo/seamless_cloning/cloning_demo.cpp
+246
-0
cloning_gui.cpp
.../cpp/tutorial_code/photo/seamless_cloning/cloning_gui.cpp
+0
-0
No files found.
samples/cpp/tutorial_code/photo/decolorization/decolor.cpp
0 → 100644
View file @
14d0b763
/*
* decolor.cpp
*
* Author:
* Siddharth Kherada <siddharthkherada27[at]gmail[dot]com>
*
* This tutorial demonstrates how to use OpenCV Decolorization Module.
*
* Output:
* 1) Grayscale image
* 2) Color boost image
*
*/
#include "opencv2/photo.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core.hpp"
#include <iostream>
using
namespace
std
;
using
namespace
cv
;
int
main
(
int
argc
,
char
*
argv
[])
{
Mat
I
;
I
=
imread
(
argv
[
1
]);
Mat
gray
=
Mat
(
I
.
size
(),
CV_8UC1
);
Mat
color_boost
=
Mat
(
I
.
size
(),
CV_8UC3
);
decolor
(
I
,
gray
,
color_boost
);
imshow
(
"grayscale"
,
gray
);
imshow
(
"color_boost"
,
color_boost
);
waitKey
(
0
);
}
samples/cpp/tutorial_code/photo/non_photorealistic_rendering/npr_demo.cpp
0 → 100644
View file @
14d0b763
/*
* npr_demo.cpp
*
* Author:
* Siddharth Kherada <siddharthkherada27[at]gmail[dot]com>
*
* This tutorial demonstrates how to use OpenCV Non-Photorealistic Rendering Module.
* 1) Edge Preserve Smoothing
* -> Using Normalized convolution Filter
* -> Using Recursive Filter
* 2) Detail Enhancement
* 3) Pencil sketch/Color Pencil Drawing
* 4) Stylization
*
*/
#include <signal.h>
#include "opencv2/photo.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core.hpp"
#include <iostream>
#include <stdlib.h>
using
namespace
std
;
using
namespace
cv
;
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
<
2
)
{
cout
<<
"usage: "
<<
argv
[
0
]
<<
" <Input image> "
<<
endl
;
exit
(
0
);
}
int
num
,
type
;
Mat
I
=
imread
(
argv
[
1
]);
if
(
!
I
.
data
)
{
cout
<<
"Image not found"
<<
endl
;
exit
(
0
);
}
cout
<<
endl
;
cout
<<
" Edge Preserve Filter"
<<
endl
;
cout
<<
"----------------------"
<<
endl
;
cout
<<
"Options: "
<<
endl
;
cout
<<
endl
;
cout
<<
"1) Edge Preserve Smoothing"
<<
endl
;
cout
<<
" -> Using Normalized convolution Filter"
<<
endl
;
cout
<<
" -> Using Recursive Filter"
<<
endl
;
cout
<<
"2) Detail Enhancement"
<<
endl
;
cout
<<
"3) Pencil sketch/Color Pencil Drawing"
<<
endl
;
cout
<<
"4) Stylization"
<<
endl
;
cout
<<
endl
;
cout
<<
"Press number 1-4 to choose from above techniques: "
;
cin
>>
num
;
Mat
img
;
if
(
num
==
1
)
{
cout
<<
endl
;
cout
<<
"Press 1 for Normalized Convolution Filter and 2 for Recursive Filter: "
;
cin
>>
type
;
edgePreservingFilter
(
I
,
img
,
type
);
imshow
(
"Edge Preserve Smoothing"
,
img
);
}
else
if
(
num
==
2
)
{
detailEnhance
(
I
,
img
);
imshow
(
"Detail Enhanced"
,
img
);
}
else
if
(
num
==
3
)
{
Mat
img1
;
pencilSketch
(
I
,
img1
,
img
,
10
,
0.1
f
,
0.03
f
);
imshow
(
"Pencil Sketch"
,
img1
);
imshow
(
"Color Pencil Sketch"
,
img
);
}
else
if
(
num
==
4
)
{
stylization
(
I
,
img
);
imshow
(
"Stylization"
,
img
);
}
waitKey
(
0
);
}
samples/cpp/tutorial_code/photo/seamless_cloning/cloning_demo.cpp
0 → 100644
View file @
14d0b763
/*
* cloning_demo.cpp
*
* Author:
* Siddharth Kherada <siddharthkherada27[at]gmail[dot]com>
*
* This tutorial demonstrates how to use OpenCV seamless cloning
* module without GUI.
*
* 1- Normal Cloning
* 2- Mixed Cloning
* 3- Monochrome Transfer
* 4- Color Change
* 5- Illumination change
* 6- Texture Flattening
* The program takes as input a source and a destination image (for 1-3 methods)
* and ouputs the cloned image.
*
* Download test images from opencv_extra folder @github.
*
*/
#include "opencv2/photo.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core.hpp"
#include <iostream>
#include <stdlib.h>
using
namespace
std
;
using
namespace
cv
;
int
main
()
{
cout
<<
endl
;
cout
<<
"Cloning Module"
<<
endl
;
cout
<<
"---------------"
<<
endl
;
cout
<<
"Options: "
<<
endl
;
cout
<<
endl
;
cout
<<
"1) Normal Cloning "
<<
endl
;
cout
<<
"2) Mixed Cloning "
<<
endl
;
cout
<<
"3) Monochrome Transfer "
<<
endl
;
cout
<<
"4) Local Color Change "
<<
endl
;
cout
<<
"5) Local Illumination Change "
<<
endl
;
cout
<<
"6) Texture Flattening "
<<
endl
;
cout
<<
endl
;
cout
<<
"Press number 1-6 to choose from above techniques: "
;
int
num
=
1
;
cin
>>
num
;
cout
<<
endl
;
if
(
num
==
1
)
{
string
folder
=
"cloning/Normal_Cloning/"
;
string
original_path1
=
folder
+
"source1.png"
;
string
original_path2
=
folder
+
"destination1.png"
;
string
original_path3
=
folder
+
"mask.png"
;
Mat
source
=
imread
(
original_path1
,
IMREAD_COLOR
);
Mat
destination
=
imread
(
original_path2
,
IMREAD_COLOR
);
Mat
mask
=
imread
(
original_path3
,
IMREAD_COLOR
);
if
(
source
.
empty
())
{
cout
<<
"Could not load source image "
<<
original_path1
<<
endl
;
exit
(
0
);
}
if
(
destination
.
empty
())
{
cout
<<
"Could not load destination image "
<<
original_path2
<<
endl
;
exit
(
0
);
}
if
(
mask
.
empty
())
{
cout
<<
"Could not load mask image "
<<
original_path3
<<
endl
;
exit
(
0
);
}
Mat
result
;
Point
p
;
p
.
x
=
400
;
p
.
y
=
100
;
seamlessClone
(
source
,
destination
,
mask
,
p
,
result
,
1
);
imshow
(
"Output"
,
result
);
imwrite
(
folder
+
"cloned.png"
,
result
);
}
else
if
(
num
==
2
)
{
string
folder
=
"cloning/Mixed_Cloning/"
;
string
original_path1
=
folder
+
"source1.png"
;
string
original_path2
=
folder
+
"destination1.png"
;
string
original_path3
=
folder
+
"mask.png"
;
Mat
source
=
imread
(
original_path1
,
IMREAD_COLOR
);
Mat
destination
=
imread
(
original_path2
,
IMREAD_COLOR
);
Mat
mask
=
imread
(
original_path3
,
IMREAD_COLOR
);
if
(
source
.
empty
())
{
cout
<<
"Could not load source image "
<<
original_path1
<<
endl
;
exit
(
0
);
}
if
(
destination
.
empty
())
{
cout
<<
"Could not load destination image "
<<
original_path2
<<
endl
;
exit
(
0
);
}
if
(
mask
.
empty
())
{
cout
<<
"Could not load mask image "
<<
original_path3
<<
endl
;
exit
(
0
);
}
Mat
result
;
Point
p
;
p
.
x
=
destination
.
size
().
width
/
2
;
p
.
y
=
destination
.
size
().
height
/
2
;
seamlessClone
(
source
,
destination
,
mask
,
p
,
result
,
2
);
imshow
(
"Output"
,
result
);
imwrite
(
folder
+
"cloned.png"
,
result
);
}
else
if
(
num
==
3
)
{
string
folder
=
"cloning/Monochrome_Transfer/"
;
string
original_path1
=
folder
+
"source1.png"
;
string
original_path2
=
folder
+
"destination1.png"
;
string
original_path3
=
folder
+
"mask.png"
;
Mat
source
=
imread
(
original_path1
,
IMREAD_COLOR
);
Mat
destination
=
imread
(
original_path2
,
IMREAD_COLOR
);
Mat
mask
=
imread
(
original_path3
,
IMREAD_COLOR
);
if
(
source
.
empty
())
{
cout
<<
"Could not load source image "
<<
original_path1
<<
endl
;
exit
(
0
);
}
if
(
destination
.
empty
())
{
cout
<<
"Could not load destination image "
<<
original_path2
<<
endl
;
exit
(
0
);
}
if
(
mask
.
empty
())
{
cout
<<
"Could not load mask image "
<<
original_path3
<<
endl
;
exit
(
0
);
}
Mat
result
;
Point
p
;
p
.
x
=
destination
.
size
().
width
/
2
;
p
.
y
=
destination
.
size
().
height
/
2
;
seamlessClone
(
source
,
destination
,
mask
,
p
,
result
,
3
);
imshow
(
"Output"
,
result
);
imwrite
(
folder
+
"cloned.png"
,
result
);
}
else
if
(
num
==
4
)
{
string
folder
=
"cloning/Color_Change/"
;
string
original_path1
=
folder
+
"source1.png"
;
string
original_path2
=
folder
+
"mask.png"
;
Mat
source
=
imread
(
original_path1
,
IMREAD_COLOR
);
Mat
mask
=
imread
(
original_path2
,
IMREAD_COLOR
);
if
(
source
.
empty
())
{
cout
<<
"Could not load source image "
<<
original_path1
<<
endl
;
exit
(
0
);
}
if
(
mask
.
empty
())
{
cout
<<
"Could not load mask image "
<<
original_path2
<<
endl
;
exit
(
0
);
}
Mat
result
;
colorChange
(
source
,
mask
,
result
,
1.5
,
.5
,
.5
);
imshow
(
"Output"
,
result
);
imwrite
(
folder
+
"cloned.png"
,
result
);
}
else
if
(
num
==
5
)
{
string
folder
=
"cloning/Illumination_Change/"
;
string
original_path1
=
folder
+
"source1.png"
;
string
original_path2
=
folder
+
"mask.png"
;
Mat
source
=
imread
(
original_path1
,
IMREAD_COLOR
);
Mat
mask
=
imread
(
original_path2
,
IMREAD_COLOR
);
if
(
source
.
empty
())
{
cout
<<
"Could not load source image "
<<
original_path1
<<
endl
;
exit
(
0
);
}
if
(
mask
.
empty
())
{
cout
<<
"Could not load mask image "
<<
original_path2
<<
endl
;
exit
(
0
);
}
Mat
result
;
illuminationChange
(
source
,
mask
,
result
,
0.2
f
,
0.4
f
);
imshow
(
"Output"
,
result
);
imwrite
(
folder
+
"cloned.png"
,
result
);
}
else
if
(
num
==
6
)
{
string
folder
=
"cloning/Texture_Flattening/"
;
string
original_path1
=
folder
+
"source1.png"
;
string
original_path2
=
folder
+
"mask.png"
;
Mat
source
=
imread
(
original_path1
,
IMREAD_COLOR
);
Mat
mask
=
imread
(
original_path2
,
IMREAD_COLOR
);
if
(
source
.
empty
())
{
cout
<<
"Could not load source image "
<<
original_path1
<<
endl
;
exit
(
0
);
}
if
(
mask
.
empty
())
{
cout
<<
"Could not load mask image "
<<
original_path2
<<
endl
;
exit
(
0
);
}
Mat
result
;
textureFlattening
(
source
,
mask
,
result
,
30
,
45
,
3
);
imshow
(
"Output"
,
result
);
imwrite
(
folder
+
"cloned.png"
,
result
);
}
waitKey
(
0
);
}
samples/cpp/tutorial_code/photo/seamless_cloning/cloning_gui.cpp
0 → 100644
View file @
14d0b763
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment