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
88bc8812
Commit
88bc8812
authored
Jun 19, 2015
by
Seon-Wook Park
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spatialGradient: Vectorise inner area
parent
770e742e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
1 deletion
+97
-1
precomp.hpp
modules/imgproc/src/precomp.hpp
+1
-0
spatialgradient.cpp
modules/imgproc/src/spatialgradient.cpp
+96
-1
No files found.
modules/imgproc/src/precomp.hpp
View file @
88bc8812
...
...
@@ -49,6 +49,7 @@
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/private.hpp"
#include "opencv2/core/ocl.hpp"
#include "opencv2/hal.hpp"
#include <math.h>
#include <assert.h>
...
...
modules/imgproc/src/spatialgradient.cpp
View file @
88bc8812
...
...
@@ -41,6 +41,7 @@
//M*/
#include "precomp.hpp"
#include "opencv2/hal/intrin.hpp"
namespace
cv
{
...
...
@@ -96,7 +97,6 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy, int ksi
// No-SSE
int
idx
;
p_dx
[
0
]
=
0
;
// Top-left corner
p_dy
[
0
]
=
0
;
p_dx
[
W
-
1
]
=
0
;
// Top-right corner
...
...
@@ -168,6 +168,100 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy, int ksi
}
// Do Inner area
#if CV_SIMD128
// Characters in variable names have the following meanings:
// u: unsigned char
// s: signed int
//
// [row][column]
// m: offset -1
// n: offset 0
// p: offset 1
// Example: umn is offset -1 in row and offset 0 in column
v_uint8x16
v_umm
,
v_umn
,
v_ump
,
v_unm
,
v_unn
,
v_unp
,
v_upm
,
v_upn
,
v_upp
;
v_uint16x8
v_umm1
,
v_umm2
,
v_umn1
,
v_umn2
,
v_ump1
,
v_ump2
,
v_unm1
,
v_unm2
,
v_unn1
,
v_unn2
,
v_unp1
,
v_unp2
,
v_upm1
,
v_upm2
,
v_upn1
,
v_upn2
,
v_upp1
,
v_upp2
;
v_int16x8
v_smm1
,
v_smm2
,
v_smn1
,
v_smn2
,
v_smp1
,
v_smp2
,
v_snm1
,
v_snm2
,
v_snn1
,
v_snn2
,
v_snp1
,
v_snp2
,
v_spm1
,
v_spm2
,
v_spn1
,
v_spn2
,
v_spp1
,
v_spp2
,
v_two
=
v_setall_s16
(
2
),
v_sdx1
,
v_sdx2
,
v_sdy1
,
v_sdy2
;
for
(
i
=
1
;
i
<
H
-
1
;
i
++
)
for
(
j
=
1
;
j
<
W
-
1
-
15
;
j
+=
16
)
{
// Load
idx
=
i
*
W
+
j
;
v_umm
=
v_load
(
&
p_src
[
idx
-
W
-
1
]);
v_umn
=
v_load
(
&
p_src
[
idx
-
W
]);
v_ump
=
v_load
(
&
p_src
[
idx
-
W
+
1
]);
v_unm
=
v_load
(
&
p_src
[
idx
-
1
]);
v_unn
=
v_load
(
&
p_src
[
idx
]);
v_unp
=
v_load
(
&
p_src
[
idx
+
1
]);
v_upm
=
v_load
(
&
p_src
[
idx
+
W
-
1
]);
v_upn
=
v_load
(
&
p_src
[
idx
+
W
]);
v_upp
=
v_load
(
&
p_src
[
idx
+
W
+
1
]);
// Expand to uint
v_expand
(
v_umm
,
v_umm1
,
v_umm2
);
v_expand
(
v_umn
,
v_umn1
,
v_umn2
);
v_expand
(
v_ump
,
v_ump1
,
v_ump2
);
v_expand
(
v_unm
,
v_unm1
,
v_unm2
);
v_expand
(
v_unn
,
v_unn1
,
v_unn2
);
v_expand
(
v_unp
,
v_unp1
,
v_unp2
);
v_expand
(
v_upm
,
v_upm1
,
v_upm2
);
v_expand
(
v_upn
,
v_upn1
,
v_upn2
);
v_expand
(
v_upp
,
v_upp1
,
v_upp2
);
// Convert to int
v_smm1
=
v_reinterpret_as_s16
(
v_umm1
);
v_smm2
=
v_reinterpret_as_s16
(
v_umm2
);
v_smn1
=
v_reinterpret_as_s16
(
v_umn1
);
v_smn2
=
v_reinterpret_as_s16
(
v_umn2
);
v_smp1
=
v_reinterpret_as_s16
(
v_ump1
);
v_smp2
=
v_reinterpret_as_s16
(
v_ump2
);
v_snm1
=
v_reinterpret_as_s16
(
v_unm1
);
v_snm2
=
v_reinterpret_as_s16
(
v_unm2
);
v_snn1
=
v_reinterpret_as_s16
(
v_unn1
);
v_snn2
=
v_reinterpret_as_s16
(
v_unn2
);
v_snp1
=
v_reinterpret_as_s16
(
v_unp1
);
v_snp2
=
v_reinterpret_as_s16
(
v_unp2
);
v_spm1
=
v_reinterpret_as_s16
(
v_upm1
);
v_spm2
=
v_reinterpret_as_s16
(
v_upm2
);
v_spn1
=
v_reinterpret_as_s16
(
v_upn1
);
v_spn2
=
v_reinterpret_as_s16
(
v_upn2
);
v_spp1
=
v_reinterpret_as_s16
(
v_upp1
);
v_spp2
=
v_reinterpret_as_s16
(
v_upp2
);
// dx
v_sdx1
=
(
v_smp1
-
v_smm1
)
+
v_two
*
(
v_snp1
-
v_snm1
)
+
(
v_spp1
-
v_spm1
);
v_sdx2
=
(
v_smp2
-
v_smm2
)
+
v_two
*
(
v_snp2
-
v_snm2
)
+
(
v_spp2
-
v_spm2
);
// dy
v_sdy1
=
(
v_spm1
-
v_smm1
)
+
v_two
*
(
v_spn1
-
v_smn1
)
+
(
v_spp1
-
v_smp1
);
v_sdy2
=
(
v_spm2
-
v_smm2
)
+
v_two
*
(
v_spn2
-
v_smn2
)
+
(
v_spp2
-
v_smp2
);
// Store
v_store
(
&
p_dx
[
idx
],
v_sdx1
);
v_store
(
&
p_dx
[
idx
+
8
],
v_sdx2
);
v_store
(
&
p_dy
[
idx
],
v_sdy1
);
v_store
(
&
p_dy
[
idx
+
8
],
v_sdy2
);
}
// Cleanup
int
end_j
=
j
;
for
(
i
=
1
;
i
<
H
-
1
;
i
++
)
for
(
j
=
end_j
;
j
<
W
-
1
;
j
++
)
{
idx
=
i
*
W
+
j
;
p_dx
[
idx
]
=
-
(
p_src
[
idx
-
W
-
1
]
+
2
*
p_src
[
idx
-
1
]
+
p_src
[
idx
+
W
-
1
])
+
(
p_src
[
idx
-
W
+
1
]
+
2
*
p_src
[
idx
+
1
]
+
p_src
[
idx
+
W
+
1
]);
p_dy
[
idx
]
=
-
(
p_src
[
idx
-
W
-
1
]
+
2
*
p_src
[
idx
-
W
]
+
p_src
[
idx
-
W
+
1
])
+
(
p_src
[
idx
+
W
-
1
]
+
2
*
p_src
[
idx
+
W
]
+
p_src
[
idx
+
W
+
1
]);
}
#else
for
(
i
=
1
;
i
<
H
-
1
;
i
++
)
for
(
j
=
1
;
j
<
W
-
1
;
j
++
)
{
...
...
@@ -177,6 +271,7 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy, int ksi
p_dy
[
idx
]
=
-
(
p_src
[
idx
-
W
-
1
]
+
2
*
p_src
[
idx
-
W
]
+
p_src
[
idx
-
W
+
1
])
+
(
p_src
[
idx
+
W
-
1
]
+
2
*
p_src
[
idx
+
W
]
+
p_src
[
idx
+
W
+
1
]);
}
#endif
}
...
...
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