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
a683a496
Commit
a683a496
authored
Jul 12, 2017
by
Vladislav Sovrasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: use matlab-style 1d fftShift in pc
parent
cddf8685
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
phasecorr.cpp
modules/imgproc/src/phasecorr.cpp
+5
-4
test_pc.cpp
modules/imgproc/test/test_pc.cpp
+17
-0
No files found.
modules/imgproc/src/phasecorr.cpp
View file @
a683a496
...
@@ -372,17 +372,18 @@ static void fftShift(InputOutputArray _out)
...
@@ -372,17 +372,18 @@ static void fftShift(InputOutputArray _out)
if
(
is_1d
)
if
(
is_1d
)
{
{
int
is_odd
=
(
xMid
>
0
&&
out
.
cols
%
2
==
1
)
||
(
yMid
>
0
&&
out
.
rows
%
2
==
1
);
xMid
=
xMid
+
yMid
;
xMid
=
xMid
+
yMid
;
for
(
size_t
i
=
0
;
i
<
planes
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
planes
.
size
();
i
++
)
{
{
Mat
tmp
;
Mat
tmp
;
Mat
half0
(
planes
[
i
],
Rect
(
0
,
0
,
xMid
,
1
));
Mat
half0
(
planes
[
i
],
Rect
(
0
,
0
,
xMid
+
is_odd
,
1
));
Mat
half1
(
planes
[
i
],
Rect
(
xMid
,
0
,
xMid
,
1
));
Mat
half1
(
planes
[
i
],
Rect
(
xMid
+
is_odd
,
0
,
xMid
,
1
));
half0
.
copyTo
(
tmp
);
half0
.
copyTo
(
tmp
);
half1
.
copyTo
(
half0
);
half1
.
copyTo
(
planes
[
i
](
Rect
(
0
,
0
,
xMid
,
1
))
);
tmp
.
copyTo
(
half1
);
tmp
.
copyTo
(
planes
[
i
](
Rect
(
xMid
,
0
,
xMid
+
is_odd
,
1
))
);
}
}
}
}
else
else
...
...
modules/imgproc/test/test_pc.cpp
View file @
a683a496
...
@@ -86,4 +86,21 @@ void CV_PhaseCorrelatorTest::run( int )
...
@@ -86,4 +86,21 @@ void CV_PhaseCorrelatorTest::run( int )
TEST
(
Imgproc_PhaseCorrelatorTest
,
accuracy
)
{
CV_PhaseCorrelatorTest
test
;
test
.
safe_run
();
}
TEST
(
Imgproc_PhaseCorrelatorTest
,
accuracy
)
{
CV_PhaseCorrelatorTest
test
;
test
.
safe_run
();
}
TEST
(
Imgproc_PhaseCorrelatorTest
,
accuracy_1d_odd_fft
)
{
Mat
r1
=
Mat
::
ones
(
Size
(
129
,
1
),
CV_64F
)
*
255
;
// 129 will be completed to 135 before FFT
Mat
r2
=
Mat
::
ones
(
Size
(
129
,
1
),
CV_64F
)
*
255
;
const
int
xShift
=
10
;
for
(
int
i
=
6
;
i
<
20
;
i
++
)
{
r1
.
at
<
double
>
(
i
)
=
1
;
r2
.
at
<
double
>
(
i
+
xShift
)
=
1
;
}
Point2d
phaseShift
=
phaseCorrelate
(
r1
,
r2
);
ASSERT_NEAR
(
phaseShift
.
x
,
(
double
)
xShift
,
.5
);
}
}
}
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