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
b8e70ea6
Commit
b8e70ea6
authored
Apr 23, 2012
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NORM_L2SQR added too (ticket #1840)
parent
40f2c716
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
10 deletions
+32
-10
stat.cpp
modules/core/src/stat.cpp
+16
-4
test_arithm.cpp
modules/core/test/test_arithm.cpp
+10
-4
ts_func.cpp
modules/ts/src/ts_func.cpp
+6
-2
No files found.
modules/core/src/stat.cpp
View file @
b8e70ea6
...
...
@@ -1270,7 +1270,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
int
depth
=
src
.
depth
(),
cn
=
src
.
channels
();
normType
&=
7
;
CV_Assert
(
normType
==
NORM_INF
||
normType
==
NORM_L1
||
normType
==
NORM_L2
||
CV_Assert
(
normType
==
NORM_INF
||
normType
==
NORM_L1
||
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
||
((
normType
==
NORM_HAMMING
||
normType
==
NORM_HAMMING2
)
&&
src
.
type
()
==
CV_8U
)
);
if
(
src
.
isContinuous
()
&&
mask
.
empty
()
)
...
...
@@ -1288,6 +1288,12 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
GET_OPTIMIZED
(
normL2_32f
)(
data
,
0
,
&
result
,
(
int
)
len
,
1
);
return
std
::
sqrt
(
result
);
}
if
(
normType
==
NORM_L2SQR
)
{
double
result
=
0
;
GET_OPTIMIZED
(
normL2_32f
)(
data
,
0
,
&
result
,
(
int
)
len
,
1
);
return
result
;
}
if
(
normType
==
NORM_L1
)
{
double
result
=
0
;
...
...
@@ -1354,7 +1360,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
NAryMatIterator
it
(
arrays
,
ptrs
);
int
j
,
total
=
(
int
)
it
.
size
,
blockSize
=
total
,
intSumBlockSize
=
0
,
count
=
0
;
bool
blockSum
=
(
normType
==
NORM_L1
&&
depth
<=
CV_16S
)
||
(
normType
==
NORM_L2
&&
depth
<=
CV_8S
);
(
(
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
)
&&
depth
<=
CV_8S
);
int
isum
=
0
;
int
*
ibuf
=
&
result
.
i
;
size_t
esz
=
0
;
...
...
@@ -1413,7 +1419,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
CV_Assert
(
src1
.
size
==
src2
.
size
&&
src1
.
type
()
==
src2
.
type
()
);
normType
&=
7
;
CV_Assert
(
normType
==
NORM_INF
||
normType
==
NORM_L1
||
normType
==
NORM_L2
||
CV_Assert
(
normType
==
NORM_INF
||
normType
==
NORM_L1
||
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
||
((
normType
==
NORM_HAMMING
||
normType
==
NORM_HAMMING2
)
&&
src1
.
type
()
==
CV_8U
)
);
if
(
src1
.
isContinuous
()
&&
src2
.
isContinuous
()
&&
mask
.
empty
()
)
...
...
@@ -1432,6 +1438,12 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
GET_OPTIMIZED
(
normDiffL2_32f
)(
data1
,
data2
,
0
,
&
result
,
(
int
)
len
,
1
);
return
std
::
sqrt
(
result
);
}
if
(
normType
==
NORM_L2SQR
)
{
double
result
=
0
;
GET_OPTIMIZED
(
normDiffL2_32f
)(
data1
,
data2
,
0
,
&
result
,
(
int
)
len
,
1
);
return
result
;
}
if
(
normType
==
NORM_L1
)
{
double
result
=
0
;
...
...
@@ -1490,7 +1502,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
NAryMatIterator
it
(
arrays
,
ptrs
);
int
j
,
total
=
(
int
)
it
.
size
,
blockSize
=
total
,
intSumBlockSize
=
0
,
count
=
0
;
bool
blockSum
=
(
normType
==
NORM_L1
&&
depth
<=
CV_16S
)
||
(
normType
==
NORM_L2
&&
depth
<=
CV_8S
);
(
(
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
)
&&
depth
<=
CV_8S
);
unsigned
isum
=
0
;
unsigned
*
ibuf
=
&
result
.
u
;
size_t
esz
=
0
;
...
...
modules/core/test/test_arithm.cpp
View file @
b8e70ea6
...
...
@@ -1227,11 +1227,17 @@ struct NormOp : public BaseElemWiseOp
int
getRandomType
(
RNG
&
rng
)
{
int
type
=
cvtest
::
randomType
(
rng
,
DEPTH_MASK_ALL_BUT_8S
,
1
,
4
);
normType
=
1
<<
rng
.
uniform
(
0
,
3
);
if
(
CV_MAT_DEPTH
(
type
)
==
CV_8U
&&
(
rng
.
next
()
&
8
)
!=
0
)
for
(;;)
{
normType
=
cv
::
NORM_HAMMING
+
rng
.
uniform
(
0
,
2
);
type
=
CV_MAT_DEPTH
(
type
);
normType
=
rng
.
uniform
(
1
,
8
);
if
(
normType
==
NORM_INF
||
normType
==
NORM_L1
||
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
||
normType
==
NORM_HAMMING
||
normType
==
NORM_HAMMING2
)
break
;
}
if
(
normType
==
NORM_HAMMING
||
normType
==
NORM_HAMMING2
)
{
type
=
CV_8U
;
}
return
type
;
}
...
...
modules/ts/src/ts_func.cpp
View file @
b8e70ea6
...
...
@@ -1257,6 +1257,8 @@ double norm(const Mat& src, int normType, const Mat& mask)
result
+=
normHamming
(
planes
[
0
].
data
,
total
,
cellSize
);
return
result
;
}
int
normType0
=
normType
;
normType
=
normType
==
NORM_L2SQR
?
NORM_L2
:
normType
;
CV_Assert
(
mask
.
empty
()
||
(
src
.
size
==
mask
.
size
&&
mask
.
type
()
==
CV_8U
)
);
CV_Assert
(
normType
==
NORM_INF
||
normType
==
NORM_L1
||
normType
==
NORM_L2
);
...
...
@@ -1302,7 +1304,7 @@ double norm(const Mat& src, int normType, const Mat& mask)
CV_Error
(
CV_StsUnsupportedFormat
,
""
);
};
}
if
(
normType
==
NORM_L2
)
if
(
normType
0
==
NORM_L2
)
result
=
sqrt
(
result
);
return
result
;
}
...
...
@@ -1332,6 +1334,8 @@ double norm(const Mat& src1, const Mat& src2, int normType, const Mat& mask)
result
+=
normHamming
(
planes
[
0
].
data
,
total
,
cellSize
);
return
result
;
}
int
normType0
=
normType
;
normType
=
normType
==
NORM_L2SQR
?
NORM_L2
:
normType
;
CV_Assert
(
src1
.
type
()
==
src2
.
type
()
&&
src1
.
size
==
src2
.
size
);
CV_Assert
(
mask
.
empty
()
||
(
src1
.
size
==
mask
.
size
&&
mask
.
type
()
==
CV_8U
)
);
...
...
@@ -1378,7 +1382,7 @@ double norm(const Mat& src1, const Mat& src2, int normType, const Mat& mask)
CV_Error
(
CV_StsUnsupportedFormat
,
""
);
};
}
if
(
normType
==
NORM_L2
)
if
(
normType
0
==
NORM_L2
)
result
=
sqrt
(
result
);
return
result
;
}
...
...
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