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
d46c466e
Commit
d46c466e
authored
Sep 29, 2014
by
Adrien BAK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove useless buffers
parent
89be83e5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
40 deletions
+33
-40
seamless_cloning.hpp
modules/photo/src/seamless_cloning.hpp
+1
-4
seamless_cloning_impl.cpp
modules/photo/src/seamless_cloning_impl.cpp
+32
-36
No files found.
modules/photo/src/seamless_cloning.hpp
View file @
d46c466e
...
...
@@ -80,11 +80,9 @@ namespace cv
private
:
std
::
vector
<
cv
::
Mat
>
rgb_channel
,
rgbx_channel
,
rgby_channel
,
output
;
cv
::
Mat
gradientX
,
g
radientY
;
cv
::
Mat
destinationGradientX
,
destinationG
radientY
;
cv
::
Mat
patchGradientX
,
patchGradientY
;
cv
::
Mat
srx32
,
sry32
,
grx32
,
gry32
;
cv
::
Mat
binaryMaskFloat
,
binaryMaskFloatInverted
;
};
}
#endif
\ No newline at end of file
modules/photo/src/seamless_cloning_impl.cpp
View file @
d46c466e
...
...
@@ -326,27 +326,23 @@ void Cloning::poisson_solver(const Mat &img, Mat &gxx , Mat &gyy, Mat &result)
void
Cloning
::
init_var
(
const
Mat
&
I
,
const
Mat
&
wmask
)
{
g
radientX
=
Mat
(
I
.
size
(),
CV_32FC3
);
g
radientY
=
Mat
(
I
.
size
(),
CV_32FC3
);
destinationG
radientX
=
Mat
(
I
.
size
(),
CV_32FC3
);
destinationG
radientY
=
Mat
(
I
.
size
(),
CV_32FC3
);
patchGradientX
=
Mat
(
I
.
size
(),
CV_32FC3
);
patchGradientY
=
Mat
(
I
.
size
(),
CV_32FC3
);
split
(
I
,
rgb_channel
);
binaryMaskFloat
=
Mat
(
wmask
.
size
(),
CV_32FC1
);
srx32
=
Mat
(
I
.
size
(),
CV_32FC3
);
sry32
=
Mat
(
I
.
size
(),
CV_32FC3
);
binaryMaskFloatInverted
=
Mat
(
wmask
.
size
(),
CV_32FC1
);
grx32
=
Mat
(
I
.
size
(),
CV_32FC3
);
gry32
=
Mat
(
I
.
size
(),
CV_32FC3
);
}
void
Cloning
::
compute_derivatives
(
const
Mat
&
destination
,
const
Mat
&
patch
,
const
Mat
&
binaryMask
)
{
init_var
(
destination
,
binaryMask
);
computeGradientX
(
destination
,
g
radientX
);
computeGradientY
(
destination
,
g
radientY
);
computeGradientX
(
destination
,
destinationG
radientX
);
computeGradientY
(
destination
,
destinationG
radientY
);
computeGradientX
(
patch
,
patchGradientX
);
computeGradientY
(
patch
,
patchGradientY
);
...
...
@@ -412,10 +408,10 @@ void Cloning::evaluate(const Mat &I, const Mat &wmask, const Mat &cloned)
wmask
.
convertTo
(
binaryMaskFloatInverted
,
CV_32FC1
,
1.0
/
255.0
);
array_product
(
gradientX
,
binaryMaskFloatInverted
,
grx32
);
array_product
(
gradientY
,
binaryMaskFloatInverted
,
gry32
);
array_product
(
destinationGradientX
,
binaryMaskFloatInverted
,
destinationGradientX
);
array_product
(
destinationGradientY
,
binaryMaskFloatInverted
,
destinationGradientY
);
poisson
(
I
,
grx32
,
gry32
,
srx32
,
sry32
);
poisson
(
I
,
destinationGradientX
,
destinationGradientY
,
patchGradientX
,
patchGradientY
);
merge
(
output
,
cloned
);
}
...
...
@@ -431,8 +427,8 @@ void Cloning::normal_clone(const Mat &destination, const Mat &patch, const Mat &
switch
(
flag
)
{
case
NORMAL_CLONE
:
array_product
(
patchGradientX
,
binaryMaskFloat
,
srx32
);
array_product
(
patchGradientY
,
binaryMaskFloat
,
sry32
);
array_product
(
patchGradientX
,
binaryMaskFloat
,
patchGradientX
);
array_product
(
patchGradientY
,
binaryMaskFloat
,
patchGradientY
);
break
;
case
MIXED_CLONE
:
...
...
@@ -444,19 +440,19 @@ void Cloning::normal_clone(const Mat &destination, const Mat &patch, const Mat &
for
(
int
c
=
0
;
c
<
channel
;
++
c
)
{
if
(
abs
(
patchGradientX
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
-
patchGradientY
.
at
<
float
>
(
i
,
j
*
channel
+
c
))
>
abs
(
gradientX
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
-
g
radientY
.
at
<
float
>
(
i
,
j
*
channel
+
c
)))
abs
(
destinationGradientX
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
-
destinationG
radientY
.
at
<
float
>
(
i
,
j
*
channel
+
c
)))
{
srx32
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
=
patchGradientX
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
patchGradientX
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
=
patchGradientX
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
*
binaryMaskFloat
.
at
<
float
>
(
i
,
j
);
sry32
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
=
patchGradientY
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
patchGradientY
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
=
patchGradientY
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
*
binaryMaskFloat
.
at
<
float
>
(
i
,
j
);
}
else
{
srx32
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
=
g
radientX
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
patchGradientX
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
=
destinationG
radientX
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
*
binaryMaskFloat
.
at
<
float
>
(
i
,
j
);
sry32
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
=
g
radientY
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
patchGradientY
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
=
destinationG
radientY
.
at
<
float
>
(
i
,
j
*
channel
+
c
)
*
binaryMaskFloat
.
at
<
float
>
(
i
,
j
);
}
}
...
...
@@ -479,8 +475,8 @@ void Cloning::normal_clone(const Mat &destination, const Mat &patch, const Mat &
computeGradientX
(
gray8
,
patchGradientX
);
computeGradientY
(
gray8
,
patchGradientY
);
array_product
(
patchGradientX
,
binaryMaskFloat
,
srx32
);
array_product
(
patchGradientY
,
binaryMaskFloat
,
sry32
);
array_product
(
patchGradientX
,
binaryMaskFloat
,
patchGradientX
);
array_product
(
patchGradientY
,
binaryMaskFloat
,
patchGradientY
);
break
;
}
...
...
@@ -493,10 +489,10 @@ void Cloning::local_color_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, flo
{
compute_derivatives
(
I
,
mask
,
wmask
);
array_product
(
patchGradientX
,
binaryMaskFloat
,
srx32
);
array_product
(
patchGradientY
,
binaryMaskFloat
,
sry32
);
scalar_product
(
srx32
,
red_mul
,
green_mul
,
blue_mul
);
scalar_product
(
sry32
,
red_mul
,
green_mul
,
blue_mul
);
array_product
(
patchGradientX
,
binaryMaskFloat
,
patchGradientX
);
array_product
(
patchGradientY
,
binaryMaskFloat
,
patchGradientY
);
scalar_product
(
patchGradientX
,
red_mul
,
green_mul
,
blue_mul
);
scalar_product
(
patchGradientY
,
red_mul
,
green_mul
,
blue_mul
);
evaluate
(
I
,
wmask
,
cloned
);
}
...
...
@@ -505,26 +501,26 @@ void Cloning::illum_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float alp
{
compute_derivatives
(
I
,
mask
,
wmask
);
array_product
(
patchGradientX
,
binaryMaskFloat
,
srx32
);
array_product
(
patchGradientY
,
binaryMaskFloat
,
sry32
);
array_product
(
patchGradientX
,
binaryMaskFloat
,
patchGradientX
);
array_product
(
patchGradientY
,
binaryMaskFloat
,
patchGradientY
);
Mat
mag
=
Mat
(
I
.
size
(),
CV_32FC3
);
magnitude
(
srx32
,
sry32
,
mag
);
magnitude
(
patchGradientX
,
patchGradientY
,
mag
);
Mat
multX
,
multY
,
multx_temp
,
multy_temp
;
multiply
(
srx32
,
pow
(
alpha
,
beta
),
multX
);
multiply
(
patchGradientX
,
pow
(
alpha
,
beta
),
multX
);
pow
(
mag
,
-
1
*
beta
,
multx_temp
);
multiply
(
multX
,
multx_temp
,
srx32
);
multiply
(
multX
,
multx_temp
,
patchGradientX
);
multiply
(
sry32
,
pow
(
alpha
,
beta
),
multY
);
multiply
(
patchGradientY
,
pow
(
alpha
,
beta
),
multY
);
pow
(
mag
,
-
1
*
beta
,
multy_temp
);
multiply
(
multY
,
multy_temp
,
sry32
);
multiply
(
multY
,
multy_temp
,
patchGradientY
);
Mat
zeroMask
=
(
srx32
!=
0
);
Mat
zeroMask
=
(
patchGradientX
!=
0
);
srx32
.
copyTo
(
srx32
,
zeroMask
);
sry32
.
copyTo
(
sry32
,
zeroMask
);
patchGradientX
.
copyTo
(
patchGradientX
,
zeroMask
);
patchGradientY
.
copyTo
(
patchGradientY
,
zeroMask
);
evaluate
(
I
,
wmask
,
cloned
);
}
...
...
@@ -543,8 +539,8 @@ void Cloning::texture_flatten(Mat &I, Mat &mask, Mat &wmask, double low_threshol
zeros
.
copyTo
(
patchGradientX
,
zerosMask
);
zeros
.
copyTo
(
patchGradientY
,
zerosMask
);
array_product
(
patchGradientX
,
binaryMaskFloat
,
srx32
);
array_product
(
patchGradientY
,
binaryMaskFloat
,
sry32
);
array_product
(
patchGradientX
,
binaryMaskFloat
,
patchGradientX
);
array_product
(
patchGradientY
,
binaryMaskFloat
,
patchGradientY
);
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