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
5dddb478
Commit
5dddb478
authored
Jun 30, 2015
by
Seon-Wook Park
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spatialGradient: Remove pointers caching
parent
cf0fdfa2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
21 deletions
+24
-21
spatialgradient.cpp
modules/imgproc/src/spatialgradient.cpp
+24
-21
No files found.
modules/imgproc/src/spatialgradient.cpp
View file @
5dddb478
...
@@ -102,12 +102,7 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
...
@@ -102,12 +102,7 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
int
i
=
0
,
int
i
=
0
,
j
=
0
;
j
=
0
;
// Store pointers to rows of input/output data
// Handle border types
// Padded by two rows for border handling
std
::
vector
<
uchar
*>
P_src
(
H
+
2
);
std
::
vector
<
short
*>
P_dx
(
H
+
2
);
std
::
vector
<
short
*>
P_dy
(
H
+
2
);
int
i_top
=
0
,
// Case for H == 1 && W == 1 && BORDER_REPLICATE
int
i_top
=
0
,
// Case for H == 1 && W == 1 && BORDER_REPLICATE
i_bottom
=
H
-
1
,
i_bottom
=
H
-
1
,
j_offl
=
0
,
// j offset from 0th pixel to reach -1st pixel
j_offl
=
0
,
// j offset from 0th pixel to reach -1st pixel
...
@@ -127,16 +122,6 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
...
@@ -127,16 +122,6 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
}
}
}
}
P_src
[
0
]
=
src
.
ptr
<
uchar
>
(
i_top
);
// Mirrored top border
P_src
[
H
+
1
]
=
src
.
ptr
<
uchar
>
(
i_bottom
);
// Mirrored bottom border
for
(
i
=
0
;
i
<
H
;
i
++
)
{
P_src
[
i
+
1
]
=
src
.
ptr
<
uchar
>
(
i
);
P_dx
[
i
]
=
dx
.
ptr
<
short
>
(
i
);
P_dy
[
i
]
=
dy
.
ptr
<
short
>
(
i
);
}
// Pointer to row vectors
// Pointer to row vectors
uchar
*
p_src
,
*
c_src
,
*
n_src
;
// previous, current, next row
uchar
*
p_src
,
*
c_src
,
*
n_src
;
// previous, current, next row
short
*
c_dx
,
*
c_dy
;
short
*
c_dx
,
*
c_dy
;
...
@@ -158,8 +143,19 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
...
@@ -158,8 +143,19 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
// Example: umn is offset -1 in row and offset 0 in column
// Example: umn is offset -1 in row and offset 0 in column
for
(
i
=
0
;
i
<
H
-
1
;
i
+=
2
)
for
(
i
=
0
;
i
<
H
-
1
;
i
+=
2
)
{
{
p_src
=
P_src
[
i
];
c_src
=
P_src
[
i
+
1
];
n_src
=
P_src
[
i
+
2
];
m_src
=
P_src
[
i
+
3
];
if
(
i
==
0
)
p_src
=
src
.
ptr
<
uchar
>
(
i_top
);
c_dx
=
P_dx
[
i
];
c_dy
=
P_dy
[
i
];
n_dx
=
P_dx
[
i
+
1
];
n_dy
=
P_dy
[
i
+
1
];
else
p_src
=
src
.
ptr
<
uchar
>
(
i
-
1
);
c_src
=
src
.
ptr
<
uchar
>
(
i
);
n_src
=
src
.
ptr
<
uchar
>
(
i
+
1
);
if
(
i
==
H
-
2
)
m_src
=
src
.
ptr
<
uchar
>
(
i_bottom
);
else
m_src
=
src
.
ptr
<
uchar
>
(
i
+
2
);
c_dx
=
dx
.
ptr
<
short
>
(
i
);
c_dy
=
dy
.
ptr
<
short
>
(
i
);
n_dx
=
dx
.
ptr
<
short
>
(
i
+
1
);
n_dy
=
dy
.
ptr
<
short
>
(
i
+
1
);
// Process rest of columns 16-column chunks at a time
// Process rest of columns 16-column chunks at a time
for
(
j
=
1
;
j
<
W
-
16
;
j
+=
16
)
for
(
j
=
1
;
j
<
W
-
16
;
j
+=
16
)
...
@@ -266,9 +262,16 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
...
@@ -266,9 +262,16 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
uchar
v00
,
v01
,
v02
,
v10
,
v11
,
v12
,
v20
,
v21
,
v22
;
uchar
v00
,
v01
,
v02
,
v10
,
v11
,
v12
,
v20
,
v21
,
v22
;
for
(
i
=
0
;
i
<
H
;
i
++
)
for
(
i
=
0
;
i
<
H
;
i
++
)
{
{
p_src
=
P_src
[
i
];
c_src
=
P_src
[
i
+
1
];
n_src
=
P_src
[
i
+
2
];
if
(
i
==
0
)
p_src
=
src
.
ptr
<
uchar
>
(
i_top
);
c_dx
=
P_dx
[
i
];
else
p_src
=
src
.
ptr
<
uchar
>
(
i
-
1
);
c_dy
=
P_dy
[
i
];
c_src
=
src
.
ptr
<
uchar
>
(
i
);
if
(
i
==
H
-
1
)
n_src
=
src
.
ptr
<
uchar
>
(
i_bottom
);
else
n_src
=
src
.
ptr
<
uchar
>
(
i
+
1
);
c_dx
=
dx
.
ptr
<
short
>
(
i
);
c_dy
=
dy
.
ptr
<
short
>
(
i
);
// Process left-most column
// Process left-most column
j
=
0
;
j
=
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