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
b3ddc2b9
Commit
b3ddc2b9
authored
Sep 29, 2014
by
Adrien BAK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor array_product
parent
33c15d63
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
22 deletions
+24
-22
seamless_cloning.hpp
modules/photo/src/seamless_cloning.hpp
+1
-1
seamless_cloning_impl.cpp
modules/photo/src/seamless_cloning_impl.cpp
+23
-21
No files found.
modules/photo/src/seamless_cloning.hpp
View file @
b3ddc2b9
...
...
@@ -63,7 +63,6 @@ namespace cv
void
init_var
(
const
cv
::
Mat
&
I
,
const
cv
::
Mat
&
wmask
);
void
compute_derivatives
(
const
cv
::
Mat
&
I
,
const
cv
::
Mat
&
mask
,
const
cv
::
Mat
&
wmask
);
void
scalar_product
(
cv
::
Mat
mat
,
float
r
,
float
g
,
float
b
);
void
array_product
(
cv
::
Mat
mat1
,
cv
::
Mat
mat2
,
cv
::
Mat
mat3
);
void
poisson
(
const
cv
::
Mat
&
I
,
const
cv
::
Mat
&
gx
,
const
cv
::
Mat
&
gy
,
const
cv
::
Mat
&
sx
,
const
cv
::
Mat
&
sy
);
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
);
...
...
@@ -72,6 +71,7 @@ namespace cv
void
solve
(
const
cv
::
Mat
&
img
,
double
*
mod_diff
,
cv
::
Mat
&
result
);
void
poisson_solver
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
gxx
,
cv
::
Mat
&
gyy
,
cv
::
Mat
&
result
);
void
array_product
(
const
cv
::
Mat
&
lhs
,
const
cv
::
Mat
&
rhs
,
cv
::
Mat
&
result
)
const
;
void
computeGradientX
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
gx
);
void
computeGradientY
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
gy
);
...
...
modules/photo/src/seamless_cloning_impl.cpp
View file @
b3ddc2b9
...
...
@@ -369,16 +369,18 @@ void Cloning::scalar_product(Mat mat, float r, float g, float b)
merge
(
channels
,
mat
);
}
void
Cloning
::
array_product
(
Mat
mat1
,
Mat
mat2
,
Mat
mat3
)
void
Cloning
::
array_product
(
const
cv
::
Mat
&
lhs
,
const
cv
::
Mat
&
rhs
,
cv
::
Mat
&
result
)
const
{
vector
<
Mat
>
channels_temp1
;
vector
<
Mat
>
channels_temp2
;
split
(
mat1
,
channels_temp1
);
split
(
mat2
,
channels_temp2
);
multiply
(
channels_temp2
[
2
],
mat3
,
channels_temp1
[
2
]);
multiply
(
channels_temp2
[
1
],
mat3
,
channels_temp1
[
1
]);
multiply
(
channels_temp2
[
0
],
mat3
,
channels_temp1
[
0
]);
merge
(
channels_temp1
,
mat1
);
vector
<
Mat
>
lhs_channels
;
vector
<
Mat
>
result_channels
;
split
(
lhs
,
lhs_channels
);
split
(
result
,
result_channels
);
for
(
int
chan
=
0
;
chan
<
3
;
++
chan
)
multiply
(
lhs_channels
[
chan
],
rhs
,
result_channels
[
chan
]);
merge
(
result_channels
,
result
);
}
void
Cloning
::
poisson
(
const
Mat
&
I
,
const
Mat
&
gx
,
const
Mat
&
gy
,
const
Mat
&
sx
,
const
Mat
&
sy
)
...
...
@@ -413,8 +415,8 @@ void Cloning::evaluate(const Mat &I, const Mat &wmask, const Mat &cloned)
I
.
convertTo
(
grx32
,
CV_32FC3
,
1.0
/
255.0
);
I
.
convertTo
(
gry32
,
CV_32FC3
,
1.0
/
255.0
);
array_product
(
grx
32
,
grx
,
smask1
);
array_product
(
gry
32
,
gry
,
smask1
);
array_product
(
grx
,
smask1
,
grx32
);
array_product
(
gry
,
smask1
,
gry32
);
poisson
(
I
,
grx32
,
gry32
,
srx32
,
sry32
);
...
...
@@ -433,8 +435,8 @@ void Cloning::normal_clone(const Mat &destination, const Mat &mask, const Mat &w
switch
(
flag
)
{
case
NORMAL_CLONE
:
array_product
(
s
rx32
,
sgx
,
smask
);
array_product
(
s
ry32
,
sgy
,
smask
);
array_product
(
s
gx
,
smask
,
srx32
);
array_product
(
s
gy
,
smask
,
sry32
);
break
;
case
MIXED_CLONE
:
...
...
@@ -481,8 +483,8 @@ void Cloning::normal_clone(const Mat &destination, const Mat &mask, const Mat &w
computeGradientX
(
gray8
,
sgx
);
computeGradientY
(
gray8
,
sgy
);
array_product
(
s
rx32
,
sgx
,
smask
);
array_product
(
s
ry32
,
sgy
,
smask
);
array_product
(
s
gx
,
smask
,
srx32
);
array_product
(
s
gy
,
smask
,
sry32
);
break
;
}
...
...
@@ -495,8 +497,8 @@ void Cloning::local_color_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, flo
{
compute_derivatives
(
I
,
mask
,
wmask
);
array_product
(
s
rx32
,
sgx
,
smask
);
array_product
(
s
ry32
,
sgy
,
smask
);
array_product
(
s
gx
,
smask
,
srx32
);
array_product
(
s
gy
,
smask
,
sry32
);
scalar_product
(
srx32
,
red_mul
,
green_mul
,
blue_mul
);
scalar_product
(
sry32
,
red_mul
,
green_mul
,
blue_mul
);
...
...
@@ -507,8 +509,8 @@ void Cloning::illum_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float alp
{
compute_derivatives
(
I
,
mask
,
wmask
);
array_product
(
s
rx32
,
sgx
,
smask
);
array_product
(
s
ry32
,
sgy
,
smask
);
array_product
(
s
gx
,
smask
,
srx32
);
array_product
(
s
gy
,
smask
,
sry32
);
Mat
mag
=
Mat
(
I
.
size
(),
CV_32FC3
);
magnitude
(
srx32
,
sry32
,
mag
);
...
...
@@ -545,8 +547,8 @@ void Cloning::texture_flatten(Mat &I, Mat &mask, Mat &wmask, double low_threshol
zeros
.
copyTo
(
sgx
,
zerosMask
);
zeros
.
copyTo
(
sgy
,
zerosMask
);
array_product
(
s
rx32
,
sgx
,
smask
);
array_product
(
s
ry32
,
sgy
,
smask
);
array_product
(
s
gx
,
smask
,
srx32
);
array_product
(
s
gy
,
smask
,
sry32
);
evaluate
(
I
,
wmask
,
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