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
a361cc94
Commit
a361cc94
authored
Oct 01, 2014
by
Adrien BAK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove some more useless buffers and rename a bunch of variables
parent
61fe623c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
36 deletions
+32
-36
seamless_cloning.hpp
modules/photo/src/seamless_cloning.hpp
+3
-3
seamless_cloning_impl.cpp
modules/photo/src/seamless_cloning_impl.cpp
+29
-33
No files found.
modules/photo/src/seamless_cloning.hpp
View file @
a361cc94
...
...
@@ -60,10 +60,10 @@ namespace cv
protected
:
void
init_var
(
const
cv
::
Mat
&
I
,
const
cv
::
Mat
&
wm
ask
);
void
init_var
(
const
cv
::
Mat
&
destination
,
const
cv
::
Mat
&
binaryM
ask
);
void
compute_derivatives
(
const
cv
::
Mat
&
destination
,
const
cv
::
Mat
&
patch
,
const
cv
::
Mat
&
binaryMask
);
void
scalar_product
(
cv
::
Mat
mat
,
float
r
,
float
g
,
float
b
);
void
poisson
(
const
cv
::
Mat
&
destination
,
const
cv
::
Mat
&
gx
,
const
cv
::
Mat
&
gy
,
const
cv
::
Mat
&
sx
,
const
cv
::
Mat
&
sy
);
void
poisson
(
const
cv
::
Mat
&
destination
);
void
evaluate
(
const
cv
::
Mat
&
I
,
const
cv
::
Mat
&
wmask
,
const
cv
::
Mat
&
cloned
);
void
dst
(
double
*
mod_diff
,
double
*
sineTransform
,
int
h
,
int
w
);
void
idst
(
double
*
mod_diff
,
double
*
sineTransform
,
int
h
,
int
w
);
...
...
@@ -79,7 +79,7 @@ namespace cv
void
computeLaplacianY
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
gyy
);
private
:
std
::
vector
<
cv
::
Mat
>
rgb
_channel
,
rgb
x_channel
,
rgby_channel
,
output
;
std
::
vector
<
cv
::
Mat
>
rgbx_channel
,
rgby_channel
,
output
;
cv
::
Mat
destinationGradientX
,
destinationGradientY
;
cv
::
Mat
patchGradientX
,
patchGradientY
;
cv
::
Mat
binaryMaskFloat
,
binaryMaskFloatInverted
;
...
...
modules/photo/src/seamless_cloning_impl.cpp
View file @
a361cc94
...
...
@@ -65,20 +65,20 @@ void Cloning::computeGradientY( const Mat &img, Mat &gy)
filter2D
(
img
,
gy
,
CV_32F
,
kernel
);
}
void
Cloning
::
computeLaplacianX
(
const
Mat
&
img
,
Mat
&
gxx
)
void
Cloning
::
computeLaplacianX
(
const
Mat
&
img
,
Mat
&
laplacianX
)
{
Mat
kernel
=
Mat
::
zeros
(
1
,
3
,
CV_8S
);
kernel
.
at
<
char
>
(
0
,
0
)
=
-
1
;
kernel
.
at
<
char
>
(
0
,
1
)
=
1
;
filter2D
(
img
,
gxx
,
CV_32F
,
kernel
);
filter2D
(
img
,
laplacianX
,
CV_32F
,
kernel
);
}
void
Cloning
::
computeLaplacianY
(
const
Mat
&
img
,
Mat
&
gyy
)
void
Cloning
::
computeLaplacianY
(
const
Mat
&
img
,
Mat
&
laplacianY
)
{
Mat
kernel
=
Mat
::
zeros
(
3
,
1
,
CV_8S
);
kernel
.
at
<
char
>
(
0
,
0
)
=
-
1
;
kernel
.
at
<
char
>
(
1
,
0
)
=
1
;
filter2D
(
img
,
gyy
,
CV_32F
,
kernel
);
filter2D
(
img
,
laplacianY
,
CV_32F
,
kernel
);
}
void
Cloning
::
dst
(
double
*
mod_diff
,
double
*
sineTransform
,
int
h
,
int
w
)
...
...
@@ -270,17 +270,17 @@ void Cloning::solve(const Mat &img, double *mod_diff, Mat &result)
delete
[]
img_d
;
}
void
Cloning
::
poisson_solver
(
const
Mat
&
img
,
Mat
&
gxx
,
Mat
&
gyy
,
Mat
&
result
)
void
Cloning
::
poisson_solver
(
const
Mat
&
img
,
Mat
&
laplacianX
,
Mat
&
laplacianY
,
Mat
&
result
)
{
int
w
=
img
.
size
().
width
;
int
h
=
img
.
size
().
height
;
const
int
w
=
img
.
size
().
width
;
const
int
h
=
img
.
size
().
height
;
unsigned
long
int
idx
;
Mat
lap
=
Mat
(
img
.
size
(),
CV_32FC1
);
lap
=
gxx
+
gyy
;
lap
=
laplacianX
+
laplacianY
;
Mat
bound
=
img
.
clone
();
...
...
@@ -324,17 +324,15 @@ void Cloning::poisson_solver(const Mat &img, Mat &gxx , Mat &gyy, Mat &result)
delete
[]
boundary_point
;
}
void
Cloning
::
init_var
(
const
Mat
&
I
,
const
Mat
&
wm
ask
)
void
Cloning
::
init_var
(
const
Mat
&
destination
,
const
Mat
&
binaryM
ask
)
{
destinationGradientX
=
Mat
(
I
.
size
(),
CV_32FC3
);
destinationGradientY
=
Mat
(
I
.
size
(),
CV_32FC3
);
patchGradientX
=
Mat
(
I
.
size
(),
CV_32FC3
);
patchGradientY
=
Mat
(
I
.
size
(),
CV_32FC3
);
destinationGradientX
=
Mat
(
destination
.
size
(),
CV_32FC3
);
destinationGradientY
=
Mat
(
destination
.
size
(),
CV_32FC3
);
patchGradientX
=
Mat
(
destination
.
size
(),
CV_32FC3
);
patchGradientY
=
Mat
(
destination
.
size
(),
CV_32FC3
);
split
(
I
,
rgb_channel
);
binaryMaskFloat
=
Mat
(
wmask
.
size
(),
CV_32FC1
);
binaryMaskFloatInverted
=
Mat
(
wmask
.
size
(),
CV_32FC1
);
binaryMaskFloat
=
Mat
(
binaryMask
.
size
(),
CV_32FC1
);
binaryMaskFloatInverted
=
Mat
(
binaryMask
.
size
(),
CV_32FC1
);
}
void
Cloning
::
compute_derivatives
(
const
Mat
&
destination
,
const
Mat
&
patch
,
const
Mat
&
binaryMask
)
...
...
@@ -378,28 +376,26 @@ void Cloning::array_product(const cv::Mat& lhs, const cv::Mat& rhs, cv::Mat& res
merge
(
result_channels
,
result
);
}
void
Cloning
::
poisson
(
const
Mat
&
destination
,
const
Mat
&
gx
,
const
Mat
&
gy
,
const
Mat
&
sx
,
const
Mat
&
sy
)
void
Cloning
::
poisson
(
const
Mat
&
destination
)
{
Mat
fx
=
Mat
(
destination
.
size
(),
CV_32FC3
);
Mat
fy
=
Mat
(
destination
.
size
(),
CV_32FC3
);
fx
=
gx
+
sx
;
fy
=
gy
+
sy
;
Mat
laplacianX
=
Mat
(
destination
.
size
(),
CV_32FC3
);
Mat
laplacianY
=
Mat
(
destination
.
size
(),
CV_32FC3
);
Mat
gxx
=
Mat
(
destination
.
size
(),
CV_32FC3
)
;
Mat
gyy
=
Mat
(
destination
.
size
(),
CV_32FC3
)
;
laplacianX
=
destinationGradientX
+
patchGradientX
;
laplacianY
=
destinationGradientY
+
patchGradientY
;
computeLaplacianX
(
fx
,
gxx
);
computeLaplacianY
(
fy
,
gyy
);
computeLaplacianX
(
laplacianX
,
laplacianX
);
computeLaplacianY
(
laplacianY
,
laplacianY
);
split
(
gxx
,
rgbx_channel
);
split
(
gyy
,
rgby_channel
);
split
(
laplacianX
,
rgbx_channel
);
split
(
laplacianY
,
rgby_channel
);
split
(
destination
,
output
);
poisson_solver
(
rgb_channel
[
2
],
rgbx_channel
[
2
],
rgby_channel
[
2
],
output
[
2
]);
poisson_solver
(
rgb_channel
[
1
],
rgbx_channel
[
1
],
rgby_channel
[
1
],
output
[
1
]);
poisson_solver
(
rgb_channel
[
0
],
rgbx_channel
[
0
],
rgby_channel
[
0
],
output
[
0
]);
for
(
int
chan
=
0
;
chan
<
3
;
++
chan
)
{
poisson_solver
(
output
[
chan
],
rgbx_channel
[
chan
],
rgby_channel
[
chan
],
output
[
chan
]);
}
}
void
Cloning
::
evaluate
(
const
Mat
&
I
,
const
Mat
&
wmask
,
const
Mat
&
cloned
)
...
...
@@ -411,7 +407,7 @@ void Cloning::evaluate(const Mat &I, const Mat &wmask, const Mat &cloned)
array_product
(
destinationGradientX
,
binaryMaskFloatInverted
,
destinationGradientX
);
array_product
(
destinationGradientY
,
binaryMaskFloatInverted
,
destinationGradientY
);
poisson
(
I
,
destinationGradientX
,
destinationGradientY
,
patchGradientX
,
patchGradientY
);
poisson
(
I
);
merge
(
output
,
cloned
);
}
...
...
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