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
7ab43585
Commit
7ab43585
authored
Sep 13, 2013
by
siddharth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove cloning_example.cpp
parent
50c19423
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
243 deletions
+0
-243
cloning_example.cpp
samples/cpp/cloning_example.cpp
+0
-243
No files found.
samples/cpp/cloning_example.cpp
deleted
100644 → 0
View file @
50c19423
/*
* cloning.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.
*/
#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
)
{
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
;
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
,
.2
,
.4
);
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
);
}
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