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
eddd417d
Commit
eddd417d
authored
Oct 04, 2016
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7282 from alalek:fix_calculations
parents
3bd5055a
c66efd05
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
42 deletions
+39
-42
smooth.cpp
modules/imgproc/src/smooth.cpp
+39
-42
No files found.
modules/imgproc/src/smooth.cpp
View file @
eddd417d
...
@@ -90,25 +90,25 @@ struct RowSum :
...
@@ -90,25 +90,25 @@ struct RowSum :
{
{
for
(
i
=
0
;
i
<
width
+
cn
;
i
++
)
for
(
i
=
0
;
i
<
width
+
cn
;
i
++
)
{
{
D
[
i
]
=
(
ST
)
(
S
[
i
]
+
S
[
i
+
cn
]
+
S
[
i
+
cn
*
2
])
;
D
[
i
]
=
(
ST
)
S
[
i
]
+
(
ST
)
S
[
i
+
cn
]
+
(
ST
)
S
[
i
+
cn
*
2
]
;
}
}
}
}
else
if
(
ksize
==
5
)
else
if
(
ksize
==
5
)
{
{
for
(
i
=
0
;
i
<
width
+
cn
;
i
++
)
for
(
i
=
0
;
i
<
width
+
cn
;
i
++
)
{
{
D
[
i
]
=
(
ST
)
(
S
[
i
]
+
S
[
i
+
cn
]
+
S
[
i
+
cn
*
2
]
+
S
[
i
+
cn
*
3
]
+
S
[
i
+
cn
*
4
])
;
D
[
i
]
=
(
ST
)
S
[
i
]
+
(
ST
)
S
[
i
+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s2
+=
S
[
i
+
ksz_cn
+
2
]
-
S
[
i
+
2
];
s2
+=
(
ST
)
S
[
i
+
ksz_cn
+
2
]
-
(
ST
)
S
[
i
+
2
];
s3
+=
S
[
i
+
ksz_cn
+
3
]
-
S
[
i
+
3
];
s3
+=
(
ST
)
S
[
i
+
ksz_cn
+
3
]
-
(
ST
)
S
[
i
+
3
];
D
[
i
+
4
]
=
s0
;
D
[
i
+
4
]
=
s0
;
D
[
i
+
5
]
=
s1
;
D
[
i
+
5
]
=
s1
;
D
[
i
+
6
]
=
s2
;
D
[
i
+
6
]
=
s2
;
...
@@ -165,11 +165,11 @@ struct RowSum :
...
@@ -165,11 +165,11 @@ struct RowSum :
{
{
ST
s
=
0
;
ST
s
=
0
;
for
(
i
=
0
;
i
<
ksz_cn
;
i
+=
cn
)
for
(
i
=
0
;
i
<
ksz_cn
;
i
+=
cn
)
s
+=
S
[
i
];
s
+=
(
ST
)
S
[
i
];
D
[
0
]
=
s
;
D
[
0
]
=
s
;
for
(
i
=
0
;
i
<
width
;
i
+=
cn
)
for
(
i
=
0
;
i
<
width
;
i
+=
cn
)
{
{
s
+=
S
[
i
+
ksz_cn
]
-
S
[
i
];
s
+=
(
ST
)
S
[
i
+
ksz_cn
]
-
(
ST
)
S
[
i
];
D
[
i
+
cn
]
=
s
;
D
[
i
+
cn
]
=
s
;
}
}
}
}
...
@@ -292,7 +292,6 @@ struct ColumnSum<int, uchar> :
...
@@ -292,7 +292,6 @@ struct ColumnSum<int, uchar> :
virtual
void
operator
()(
const
uchar
**
src
,
uchar
*
dst
,
int
dststep
,
int
count
,
int
width
)
virtual
void
operator
()(
const
uchar
**
src
,
uchar
*
dst
,
int
dststep
,
int
count
,
int
width
)
{
{
int
i
;
int
*
SUM
;
int
*
SUM
;
bool
haveScale
=
scale
!=
1
;
bool
haveScale
=
scale
!=
1
;
double
_scale
=
scale
;
double
_scale
=
scale
;
...
@@ -316,7 +315,7 @@ struct ColumnSum<int, uchar> :
...
@@ -316,7 +315,7 @@ struct ColumnSum<int, uchar> :
for
(
;
sumCount
<
ksize
-
1
;
sumCount
++
,
src
++
)
for
(
;
sumCount
<
ksize
-
1
;
sumCount
++
,
src
++
)
{
{
const
int
*
Sp
=
(
const
int
*
)
src
[
0
];
const
int
*
Sp
=
(
const
int
*
)
src
[
0
];
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -351,7 +350,7 @@ struct ColumnSum<int, uchar> :
...
@@ -351,7 +350,7 @@ struct ColumnSum<int, uchar> :
uchar
*
D
=
(
uchar
*
)
dst
;
uchar
*
D
=
(
uchar
*
)
dst
;
if
(
haveScale
)
if
(
haveScale
)
{
{
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -406,7 +405,7 @@ struct ColumnSum<int, uchar> :
...
@@ -406,7 +405,7 @@ struct ColumnSum<int, uchar> :
}
}
else
else
{
{
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -478,7 +477,7 @@ public BaseColumnFilter
...
@@ -478,7 +477,7 @@ public BaseColumnFilter
if
(
scale
!=
1
)
if
(
scale
!=
1
)
{
{
int
d
=
cvRound
(
1.
/
scale
);
int
d
=
cvRound
(
1.
/
scale
);
double
scalef
=
(
1
<<
16
)
/
d
;
double
scalef
=
(
(
double
)(
1
<<
16
)
)
/
d
;
divScale
=
cvFloor
(
scalef
);
divScale
=
cvFloor
(
scalef
);
scalef
-=
divScale
;
scalef
-=
divScale
;
divDelta
=
d
/
2
;
divDelta
=
d
/
2
;
...
@@ -493,9 +492,10 @@ public BaseColumnFilter
...
@@ -493,9 +492,10 @@ public BaseColumnFilter
virtual
void
operator
()(
const
uchar
**
src
,
uchar
*
dst
,
int
dststep
,
int
count
,
int
width
)
virtual
void
operator
()(
const
uchar
**
src
,
uchar
*
dst
,
int
dststep
,
int
count
,
int
width
)
{
{
int
i
,
ds
=
divScale
,
dd
=
divDelta
;
const
int
ds
=
divScale
;
const
int
dd
=
divDelta
;
ushort
*
SUM
;
ushort
*
SUM
;
bool
haveScale
=
scale
!=
1
;
const
bool
haveScale
=
scale
!=
1
;
#if CV_SSE2
#if CV_SSE2
bool
haveSSE2
=
checkHardwareSupport
(
CV_CPU_SSE2
);
bool
haveSSE2
=
checkHardwareSupport
(
CV_CPU_SSE2
);
...
@@ -516,7 +516,7 @@ public BaseColumnFilter
...
@@ -516,7 +516,7 @@ public BaseColumnFilter
for
(
;
sumCount
<
ksize
-
1
;
sumCount
++
,
src
++
)
for
(
;
sumCount
<
ksize
-
1
;
sumCount
++
,
src
++
)
{
{
const
ushort
*
Sp
=
(
const
ushort
*
)
src
[
0
];
const
ushort
*
Sp
=
(
const
ushort
*
)
src
[
0
];
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -551,7 +551,7 @@ public BaseColumnFilter
...
@@ -551,7 +551,7 @@ public BaseColumnFilter
uchar
*
D
=
(
uchar
*
)
dst
;
uchar
*
D
=
(
uchar
*
)
dst
;
if
(
haveScale
)
if
(
haveScale
)
{
{
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -586,7 +586,7 @@ public BaseColumnFilter
...
@@ -586,7 +586,7 @@ public BaseColumnFilter
}
}
else
else
{
{
i
=
0
;
i
nt
i
=
0
;
for
(
;
i
<
width
;
i
++
)
for
(
;
i
<
width
;
i
++
)
{
{
int
s0
=
SUM
[
i
]
+
Sp
[
i
];
int
s0
=
SUM
[
i
]
+
Sp
[
i
];
...
@@ -804,7 +804,6 @@ struct ColumnSum<int, ushort> :
...
@@ -804,7 +804,6 @@ struct ColumnSum<int, ushort> :
virtual
void
operator
()(
const
uchar
**
src
,
uchar
*
dst
,
int
dststep
,
int
count
,
int
width
)
virtual
void
operator
()(
const
uchar
**
src
,
uchar
*
dst
,
int
dststep
,
int
count
,
int
width
)
{
{
int
i
;
int
*
SUM
;
int
*
SUM
;
bool
haveScale
=
scale
!=
1
;
bool
haveScale
=
scale
!=
1
;
double
_scale
=
scale
;
double
_scale
=
scale
;
...
@@ -828,7 +827,7 @@ struct ColumnSum<int, ushort> :
...
@@ -828,7 +827,7 @@ struct ColumnSum<int, ushort> :
for
(
;
sumCount
<
ksize
-
1
;
sumCount
++
,
src
++
)
for
(
;
sumCount
<
ksize
-
1
;
sumCount
++
,
src
++
)
{
{
const
int
*
Sp
=
(
const
int
*
)
src
[
0
];
const
int
*
Sp
=
(
const
int
*
)
src
[
0
];
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -863,7 +862,7 @@ struct ColumnSum<int, ushort> :
...
@@ -863,7 +862,7 @@ struct ColumnSum<int, ushort> :
ushort
*
D
=
(
ushort
*
)
dst
;
ushort
*
D
=
(
ushort
*
)
dst
;
if
(
haveScale
)
if
(
haveScale
)
{
{
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -913,7 +912,7 @@ struct ColumnSum<int, ushort> :
...
@@ -913,7 +912,7 @@ struct ColumnSum<int, ushort> :
}
}
else
else
{
{
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -982,7 +981,6 @@ struct ColumnSum<int, int> :
...
@@ -982,7 +981,6 @@ struct ColumnSum<int, int> :
virtual
void
operator
()(
const
uchar
**
src
,
uchar
*
dst
,
int
dststep
,
int
count
,
int
width
)
virtual
void
operator
()(
const
uchar
**
src
,
uchar
*
dst
,
int
dststep
,
int
count
,
int
width
)
{
{
int
i
;
int
*
SUM
;
int
*
SUM
;
bool
haveScale
=
scale
!=
1
;
bool
haveScale
=
scale
!=
1
;
double
_scale
=
scale
;
double
_scale
=
scale
;
...
@@ -1006,7 +1004,7 @@ struct ColumnSum<int, int> :
...
@@ -1006,7 +1004,7 @@ struct ColumnSum<int, int> :
for
(
;
sumCount
<
ksize
-
1
;
sumCount
++
,
src
++
)
for
(
;
sumCount
<
ksize
-
1
;
sumCount
++
,
src
++
)
{
{
const
int
*
Sp
=
(
const
int
*
)
src
[
0
];
const
int
*
Sp
=
(
const
int
*
)
src
[
0
];
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -1041,7 +1039,7 @@ struct ColumnSum<int, int> :
...
@@ -1041,7 +1039,7 @@ struct ColumnSum<int, int> :
int
*
D
=
(
int
*
)
dst
;
int
*
D
=
(
int
*
)
dst
;
if
(
haveScale
)
if
(
haveScale
)
{
{
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -1083,7 +1081,7 @@ struct ColumnSum<int, int> :
...
@@ -1083,7 +1081,7 @@ struct ColumnSum<int, int> :
}
}
else
else
{
{
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -1144,7 +1142,6 @@ struct ColumnSum<int, float> :
...
@@ -1144,7 +1142,6 @@ struct ColumnSum<int, float> :
virtual
void
operator
()(
const
uchar
**
src
,
uchar
*
dst
,
int
dststep
,
int
count
,
int
width
)
virtual
void
operator
()(
const
uchar
**
src
,
uchar
*
dst
,
int
dststep
,
int
count
,
int
width
)
{
{
int
i
;
int
*
SUM
;
int
*
SUM
;
bool
haveScale
=
scale
!=
1
;
bool
haveScale
=
scale
!=
1
;
double
_scale
=
scale
;
double
_scale
=
scale
;
...
@@ -1168,7 +1165,7 @@ struct ColumnSum<int, float> :
...
@@ -1168,7 +1165,7 @@ struct ColumnSum<int, float> :
for
(
;
sumCount
<
ksize
-
1
;
sumCount
++
,
src
++
)
for
(
;
sumCount
<
ksize
-
1
;
sumCount
++
,
src
++
)
{
{
const
int
*
Sp
=
(
const
int
*
)
src
[
0
];
const
int
*
Sp
=
(
const
int
*
)
src
[
0
];
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
{
{
...
@@ -1204,7 +1201,7 @@ struct ColumnSum<int, float> :
...
@@ -1204,7 +1201,7 @@ struct ColumnSum<int, float> :
float
*
D
=
(
float
*
)
dst
;
float
*
D
=
(
float
*
)
dst
;
if
(
haveScale
)
if
(
haveScale
)
{
{
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
...
@@ -1248,7 +1245,7 @@ struct ColumnSum<int, float> :
...
@@ -1248,7 +1245,7 @@ struct ColumnSum<int, float> :
}
}
else
else
{
{
i
=
0
;
i
nt
i
=
0
;
#if CV_SSE2
#if CV_SSE2
if
(
haveSSE2
)
if
(
haveSSE2
)
...
...
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