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
6bfea737
Commit
6bfea737
authored
Oct 10, 2014
by
Adrien BAK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move calls to ptr<>
parent
4a5ea850
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
21 deletions
+39
-21
seamless_cloning_impl.cpp
modules/photo/src/seamless_cloning_impl.cpp
+39
-21
No files found.
modules/photo/src/seamless_cloning_impl.cpp
View file @
6bfea737
...
...
@@ -87,9 +87,11 @@ void Cloning::dst(const Mat& src, Mat& dest, bool invert)
for
(
int
j
=
0
;
j
<
src
.
rows
;
++
j
)
{
float
*
tempLinePtr
=
temp
.
ptr
<
float
>
(
j
);
const
float
*
srcLinePtr
=
src
.
ptr
<
float
>
(
j
);
for
(
int
i
=
0
;
i
<
src
.
cols
;
++
i
)
{
temp
.
ptr
<
float
>
(
j
)[
src
.
cols
+
2
+
i
]
=
-
src
.
ptr
<
float
>
(
j
)
[
src
.
cols
-
1
-
i
];
temp
LinePtr
[
src
.
cols
+
2
+
i
]
=
-
srcLinePtr
[
src
.
cols
-
1
-
i
];
}
}
...
...
@@ -104,11 +106,12 @@ void Cloning::dst(const Mat& src, Mat& dest, bool invert)
for
(
int
j
=
0
;
j
<
src
.
cols
;
++
j
)
{
float
*
tempLinePtr
=
temp
.
ptr
<
float
>
(
j
);
for
(
int
i
=
0
;
i
<
src
.
rows
;
++
i
)
{
float
val
=
planes
[
1
].
ptr
<
float
>
(
i
)[
j
+
1
];
temp
.
ptr
<
float
>
(
j
)
[
i
+
1
]
=
val
;
temp
.
ptr
<
float
>
(
j
)
[
temp
.
cols
-
1
-
i
]
=
-
val
;
temp
LinePtr
[
i
+
1
]
=
val
;
temp
LinePtr
[
temp
.
cols
-
1
-
i
]
=
-
val
;
}
}
...
...
@@ -140,43 +143,54 @@ void Cloning::solve(const Mat &img, std::vector<float>& mod_diff, Mat &result)
for
(
int
j
=
0
;
j
<
h
-
2
;
j
++
)
{
float
*
resLinePtr
=
res
.
ptr
<
float
>
(
j
);
for
(
int
i
=
0
;
i
<
w
-
2
;
i
++
)
{
res
.
ptr
<
float
>
(
j
)
[
i
]
/=
(
filter_X
[
i
]
+
filter_Y
[
j
]
-
4
);
res
LinePtr
[
i
]
/=
(
filter_X
[
i
]
+
filter_Y
[
j
]
-
4
);
}
}
idst
(
res
,
ModDiff
);
unsigned
char
*
resLinePtr
=
result
.
ptr
<
unsigned
char
>
(
0
);
const
unsigned
char
*
imgLinePtr
=
img
.
ptr
<
unsigned
char
>
(
0
);
const
float
*
interpLinePtr
=
NULL
;
//first col
for
(
int
i
=
0
;
i
<
w
;
++
i
)
result
.
ptr
<
unsigned
char
>
(
0
)[
i
]
=
img
.
ptr
<
unsigned
char
>
(
0
)[
i
];
for
(
int
j
=
1
;
j
<
h
-
1
;
++
j
)
{
resLinePtr
=
result
.
ptr
<
unsigned
char
>
(
j
);
imgLinePtr
=
img
.
ptr
<
unsigned
char
>
(
j
);
interpLinePtr
=
ModDiff
.
ptr
<
float
>
(
j
-
1
);
//first row
res
ult
.
ptr
<
unsigned
char
>
(
j
)[
0
]
=
img
.
ptr
<
unsigned
char
>
(
j
)
[
0
];
res
LinePtr
[
0
]
=
imgLinePtr
[
0
];
for
(
int
i
=
1
;
i
<
w
-
1
;
++
i
)
{
//saturate cast is not used here, because it behaves differently from the previous implementation
//most notable, saturate_cast rounds before truncating, here it's the opposite.
float
value
=
ModDiff
.
ptr
<
float
>
(
j
-
1
)
[
i
-
1
];
float
value
=
interpLinePtr
[
i
-
1
];
if
(
value
<
0.
)
res
ult
.
ptr
<
unsigned
char
>
(
j
)
[
i
]
=
0
;
res
LinePtr
[
i
]
=
0
;
else
if
(
value
>
255.0
)
res
ult
.
ptr
<
unsigned
char
>
(
j
)
[
i
]
=
255
;
res
LinePtr
[
i
]
=
255
;
else
res
ult
.
ptr
<
unsigned
char
>
(
j
)
[
i
]
=
static_cast
<
unsigned
char
>
(
value
);
res
LinePtr
[
i
]
=
static_cast
<
unsigned
char
>
(
value
);
}
//last row
res
ult
.
ptr
<
unsigned
char
>
(
j
)[
w
-
1
]
=
img
.
ptr
<
unsigned
char
>
(
j
)
[
w
-
1
];
res
LinePtr
[
w
-
1
]
=
imgLinePtr
[
w
-
1
];
}
//last col
resLinePtr
=
result
.
ptr
<
unsigned
char
>
(
h
-
1
);
imgLinePtr
=
img
.
ptr
<
unsigned
char
>
(
h
-
1
);
for
(
int
i
=
0
;
i
<
w
;
++
i
)
res
ult
.
ptr
<
unsigned
char
>
(
h
-
1
)[
i
]
=
img
.
ptr
<
unsigned
char
>
(
h
-
1
)
[
i
];
res
LinePtr
[
i
]
=
imgLinePtr
[
i
];
}
...
...
@@ -351,25 +365,29 @@ void Cloning::normalClone(const Mat &destination, const Mat &patch, const Mat &b
for
(
int
i
=
0
;
i
<
h
;
i
++
)
{
float
*
patchXLinePtr
=
patchGradientX
.
ptr
<
float
>
(
i
);
float
*
patchYLinePtr
=
patchGradientY
.
ptr
<
float
>
(
i
);
const
float
*
destinationXLinePtr
=
destinationGradientX
.
ptr
<
float
>
(
i
);
const
float
*
destinationYLinePtr
=
destinationGradientY
.
ptr
<
float
>
(
i
);
const
float
*
binaryMaskLinePtr
=
binaryMaskFloat
.
ptr
<
float
>
(
i
);
for
(
int
j
=
0
;
j
<
w
;
j
++
)
{
for
(
int
c
=
0
;
c
<
channel
;
++
c
)
{
if
(
abs
(
patch
GradientX
.
ptr
<
float
>
(
i
)[
j
*
channel
+
c
]
-
patchGradientY
.
ptr
<
float
>
(
i
)
[
j
*
channel
+
c
])
>
abs
(
destination
GradientX
.
ptr
<
float
>
(
i
)[
j
*
channel
+
c
]
-
destinationGradientY
.
ptr
<
float
>
(
i
)
[
j
*
channel
+
c
]))
if
(
abs
(
patch
XLinePtr
[
j
*
channel
+
c
]
-
patchYLinePtr
[
j
*
channel
+
c
])
>
abs
(
destination
XLinePtr
[
j
*
channel
+
c
]
-
destinationYLinePtr
[
j
*
channel
+
c
]))
{
patchGradientX
.
ptr
<
float
>
(
i
)[
j
*
channel
+
c
]
=
patchGradientX
.
ptr
<
float
>
(
i
)[
j
*
channel
+
c
]
*
binaryMaskFloat
.
ptr
<
float
>
(
i
)[
j
];
patchGradientY
.
ptr
<
float
>
(
i
)[
j
*
channel
+
c
]
=
patchGradientY
.
ptr
<
float
>
(
i
)[
j
*
channel
+
c
]
*
binaryMaskFloat
.
ptr
<
float
>
(
i
)[
j
];
patchXLinePtr
[
j
*
channel
+
c
]
*=
binaryMaskLinePtr
[
j
];
patchYLinePtr
[
j
*
channel
+
c
]
*=
binaryMaskLinePtr
[
j
];
}
else
{
patch
GradientX
.
ptr
<
float
>
(
i
)[
j
*
channel
+
c
]
=
destinationGradientX
.
ptr
<
float
>
(
i
)
[
j
*
channel
+
c
]
*
binaryMask
Float
.
ptr
<
float
>
(
i
)
[
j
];
patchGradientY
.
ptr
<
float
>
(
i
)[
j
*
channel
+
c
]
=
destination
GradientY
.
ptr
<
float
>
(
i
)
[
j
*
channel
+
c
]
*
binaryMask
Float
.
ptr
<
float
>
(
i
)
[
j
];
patch
XLinePtr
[
j
*
channel
+
c
]
=
destinationXLinePtr
[
j
*
channel
+
c
]
*
binaryMask
LinePtr
[
j
];
patchGradientY
.
ptr
<
float
>
(
i
)[
j
*
channel
+
c
]
=
destination
YLinePtr
[
j
*
channel
+
c
]
*
binaryMask
LinePtr
[
j
];
}
}
}
...
...
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