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
9e7b8d5f
Commit
9e7b8d5f
authored
Nov 12, 2010
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrote matchTemplate in C++; added border awareness to crossCorr (ticket #557)
parent
66d10b18
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
10 deletions
+39
-10
filter.cpp
modules/imgproc/src/filter.cpp
+8
-5
precomp.hpp
modules/imgproc/src/precomp.hpp
+1
-5
utils.cpp
modules/imgproc/src/utils.cpp
+1
-0
image.cpp
samples/c/image.cpp
+29
-0
No files found.
modules/imgproc/src/filter.cpp
View file @
9e7b8d5f
...
...
@@ -2994,15 +2994,18 @@ void filter2D( const Mat& src, Mat& dst, int ddepth,
dst
.
create
(
src
.
size
(),
CV_MAKETYPE
(
ddepth
,
src
.
channels
())
);
anchor
=
normalizeAnchor
(
anchor
,
kernel
.
size
());
if
(
kernel
.
cols
*
kernel
.
rows
>=
dft_filter_size
/*&&
kernel.cols <= src.cols && kernel.rows <= src.rows*/
)
if
(
kernel
.
cols
*
kernel
.
rows
>=
dft_filter_size
)
{
Mat
temp
;
if
(
src
.
data
!=
dst
.
data
)
temp
=
src
;
temp
=
dst
;
else
src
.
copyTo
(
temp
);
crossCorr
(
temp
,
kernel
,
dst
,
anchor
,
delta
,
borderType
);
temp
.
create
(
dst
.
size
(),
dst
.
type
());
crossCorr
(
src
,
kernel
,
temp
,
src
.
size
(),
CV_MAKETYPE
(
ddepth
,
src
.
channels
()),
anchor
,
delta
,
borderType
);
if
(
temp
.
data
!=
dst
.
data
)
temp
.
copyTo
(
dst
);
return
;
}
...
...
modules/imgproc/src/precomp.hpp
View file @
9e7b8d5f
...
...
@@ -92,6 +92,7 @@ static inline Point normalizeAnchor( Point anchor, Size ksize )
void
preprocess2DKernel
(
const
Mat
&
kernel
,
vector
<
Point
>&
coords
,
vector
<
uchar
>&
coeffs
);
void
crossCorr
(
const
Mat
&
src
,
const
Mat
&
templ
,
Mat
&
dst
,
Size
corrsize
,
int
ctype
,
Point
anchor
=
Point
(
0
,
0
),
double
delta
=
0
,
int
borderType
=
BORDER_REFLECT_101
);
...
...
@@ -124,11 +125,6 @@ void icvSepConvSmall3_32f( float* src, int src_step, float* dst, int dst_step,
#undef CV_CALC_MAX
#define CV_CALC_MAX(a, b) if((a) < (b)) (a) = (b)
void
icvCrossCorr
(
const
CvArr
*
_img
,
const
CvArr
*
_templ
,
CvArr
*
_corr
,
CvPoint
anchor
=
cvPoint
(
0
,
0
),
double
delta
=
0
,
int
borderType
=
IPL_BORDER_REPLICATE
);
CvStatus
CV_STDCALL
icvCopyReplicateBorder_8u
(
const
uchar
*
src
,
int
srcstep
,
CvSize
srcroi
,
uchar
*
dst
,
int
dststep
,
CvSize
dstroi
,
...
...
modules/imgproc/src/utils.cpp
View file @
9e7b8d5f
...
...
@@ -442,6 +442,7 @@ cvCopyMakeBorder( const CvArr* srcarr, CvArr* dstarr, CvPoint offset,
if
(
dststep
==
0
)
dststep
=
CV_STUB_STEP
;
bordertype
&=
15
;
if
(
bordertype
==
IPL_BORDER_REPLICATE
)
{
icvCopyReplicateBorder_8u
(
src
->
data
.
ptr
,
srcstep
,
srcsize
,
...
...
samples/c/image.cpp
View file @
9e7b8d5f
...
...
@@ -4,6 +4,8 @@
using
namespace
cv
;
// all the new API is put into "cv" namespace. Export its content
#if 0
// enable/disable use of mixed API in the code below.
#define DEMO_MIXED_API_USE 1
...
...
@@ -108,3 +110,30 @@ int main( int argc, char** argv )
// all the memory will automatically be released by Vector<>, Mat and Ptr<> destructors.
}
#else
int
main
(
int
argc
,
char
*
argv
[])
{
Mat
im
(
160
,
160
,
CV_32F
);
randu
(
im
,
Scalar
(
0.0
),
Scalar
(
1.0
));
Mat
dd
=
Mat
::
zeros
(
17
,
1
,
CV_32F
);
Mat
lp
=
Mat
::
zeros
(
17
,
1
,
CV_32F
);
dd
.
at
<
float
>
(
0
)
=
0.5
;
dd
.
at
<
float
>
(
16
)
=
-
0.5
;
lp
.
at
<
float
>
(
0
)
=
0.5
;
lp
.
at
<
float
>
(
16
)
=
0.5
;
int
p
=
16
;
Mat
H
=
dd
*
lp
.
t
();
Mat
imcrop
(
im
,
Rect
(
17
,
17
,
im
.
cols
-
2
*
p
,
im
.
rows
-
2
*
p
));
Mat
out1
,
out2
;
filter2D
(
imcrop
,
out1
,
CV_32F
,
H
,
Point
(
-
1
,
-
1
));
sepFilter2D
(
imcrop
,
out2
,
CV_32F
,
lp
,
dd
,
Point
(
-
1
,
-
1
));
Mat
temp
;
out1
.
convertTo
(
temp
,
CV_16U
,
65535.0
,
32768.0
);
imshow
(
"filtered1.png"
,
temp
);
out2
.
convertTo
(
temp
,
CV_16U
,
65535.0
,
32768.0
);
imshow
(
"filtered2.png"
,
temp
);
waitKey
();
}
#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