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
262fc330
Commit
262fc330
authored
Jun 03, 2011
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added 16-bit support to Bayer2RGB & Bayer2Gray (ticket #686)
parent
ce8437d3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
22 deletions
+69
-22
test_color.cpp
modules/imgproc/test/test_color.cpp
+34
-22
test_main.cpp
modules/imgproc/test/test_main.cpp
+35
-0
No files found.
modules/imgproc/test/test_color.cpp
View file @
262fc330
...
...
@@ -1528,7 +1528,7 @@ protected:
};
CV_ColorBayerTest
::
CV_ColorBayerTest
()
:
CV_ColorCvtBaseTest
(
false
,
false
,
fals
e
)
CV_ColorBayerTest
::
CV_ColorBayerTest
()
:
CV_ColorCvtBaseTest
(
false
,
false
,
tru
e
)
{
test_array
[
OUTPUT
].
pop_back
();
test_array
[
REF_OUTPUT
].
pop_back
();
...
...
@@ -1545,8 +1545,8 @@ void CV_ColorBayerTest::get_test_array_types_and_sizes( int test_case_idx, vecto
RNG
&
rng
=
ts
->
get_rng
();
CV_ColorCvtBaseTest
::
get_test_array_types_and_sizes
(
test_case_idx
,
sizes
,
types
);
types
[
INPUT
][
0
]
=
CV_
8UC1
;
types
[
OUTPUT
][
0
]
=
types
[
REF_OUTPUT
][
0
]
=
CV_
8UC3
;
types
[
INPUT
][
0
]
=
CV_
MAT_DEPTH
(
types
[
INPUT
][
0
])
;
types
[
OUTPUT
][
0
]
=
types
[
REF_OUTPUT
][
0
]
=
CV_
MAKETYPE
(
CV_MAT_DEPTH
(
types
[
INPUT
][
0
]),
3
)
;
inplace
=
false
;
fwd_code
=
cvtest
::
randInt
(
rng
)
%
4
+
CV_BayerBG2BGR
;
...
...
@@ -1571,22 +1571,20 @@ void CV_ColorBayerTest::run_func()
}
void
CV_ColorBayerTest
::
prepare_to_validation
(
int
/*test_case_idx*/
)
template
<
typename
T
>
static
void
bayer2BGR_
(
const
Mat
&
src
,
Mat
&
dst
,
int
code
)
{
const
Mat
&
src
=
test_mat
[
INPUT
][
0
];
Mat
&
dst
=
test_mat
[
REF_OUTPUT
][
0
];
int
i
,
j
,
cols
=
src
.
cols
-
2
;
int
code
=
fwd_code
;
int
bi
=
0
;
int
step
=
src
.
step
;
if
(
fwd_code
==
CV_BayerRG2BGR
||
fwd_
code
==
CV_BayerGR2BGR
)
int
step
=
(
int
)(
src
.
step
/
sizeof
(
T
))
;
if
(
code
==
CV_BayerRG2BGR
||
code
==
CV_BayerGR2BGR
)
bi
^=
2
;
for
(
i
=
1
;
i
<
src
.
rows
-
1
;
i
++
)
{
const
uchar
*
ptr
=
src
.
ptr
(
i
)
+
1
;
uchar
*
dst_row
=
dst
.
ptr
(
i
)
+
3
;
const
T
*
ptr
=
src
.
ptr
<
T
>
(
i
)
+
1
;
T
*
dst_row
=
dst
.
ptr
<
T
>
(
i
)
+
3
;
int
save_code
=
code
;
if
(
cols
<=
0
)
{
...
...
@@ -1594,7 +1592,7 @@ void CV_ColorBayerTest::prepare_to_validation( int /*test_case_idx*/ )
dst_row
[
cols
*
3
]
=
dst_row
[
cols
*
3
+
1
]
=
dst_row
[
cols
*
3
+
2
]
=
0
;
continue
;
}
for
(
j
=
0
;
j
<
cols
;
j
++
)
{
int
b
,
g
,
r
;
...
...
@@ -1611,9 +1609,9 @@ void CV_ColorBayerTest::prepare_to_validation( int /*test_case_idx*/ )
r
=
(
ptr
[
j
-
step
]
+
ptr
[
j
+
step
])
>>
1
;
}
code
^=
1
;
dst_row
[
j
*
3
+
bi
]
=
(
uchar
)
b
;
dst_row
[
j
*
3
+
1
]
=
(
uchar
)
g
;
dst_row
[
j
*
3
+
(
bi
^
2
)]
=
(
uchar
)
r
;
dst_row
[
j
*
3
+
bi
]
=
(
T
)
b
;
dst_row
[
j
*
3
+
1
]
=
(
T
)
g
;
dst_row
[
j
*
3
+
(
bi
^
2
)]
=
(
T
)
r
;
}
dst_row
[
-
3
]
=
dst_row
[
0
];
...
...
@@ -1629,14 +1627,14 @@ void CV_ColorBayerTest::prepare_to_validation( int /*test_case_idx*/ )
if
(
src
.
rows
<=
2
)
{
memset
(
dst
.
ptr
(),
0
,
(
cols
+
2
)
*
3
);
memset
(
dst
.
ptr
(
dst
.
rows
-
1
),
0
,
(
cols
+
2
)
*
3
);
memset
(
dst
.
ptr
(),
0
,
(
cols
+
2
)
*
3
*
sizeof
(
T
)
);
memset
(
dst
.
ptr
(
dst
.
rows
-
1
),
0
,
(
cols
+
2
)
*
3
*
sizeof
(
T
)
);
}
else
{
uchar
*
top_row
=
dst
.
ptr
();
uchar
*
bottom_row
=
dst
.
ptr
(
dst
.
rows
-
1
);
int
dstep
=
dst
.
step
;
T
*
top_row
=
dst
.
ptr
<
T
>
();
T
*
bottom_row
=
dst
.
ptr
<
T
>
(
dst
.
rows
-
1
);
int
dstep
=
(
int
)(
dst
.
step
/
sizeof
(
T
))
;
for
(
j
=
0
;
j
<
(
cols
+
2
)
*
3
;
j
++
)
{
...
...
@@ -1646,6 +1644,20 @@ void CV_ColorBayerTest::prepare_to_validation( int /*test_case_idx*/ )
}
}
void
CV_ColorBayerTest
::
prepare_to_validation
(
int
/*test_case_idx*/
)
{
const
Mat
&
src
=
test_mat
[
INPUT
][
0
];
Mat
&
dst
=
test_mat
[
REF_OUTPUT
][
0
];
int
depth
=
src
.
depth
();
if
(
depth
==
CV_8U
)
bayer2BGR_
<
uchar
>
(
src
,
dst
,
fwd_code
);
else
if
(
depth
==
CV_16U
)
bayer2BGR_
<
ushort
>
(
src
,
dst
,
fwd_code
);
else
CV_Error
(
CV_StsUnsupportedFormat
,
""
);
}
/////////////////////////////////////////////////////////////////////////////////////////////////
TEST
(
Imgproc_ColorGray
,
accuracy
)
{
CV_ColorGrayTest
test
;
test
.
safe_run
();
}
...
...
modules/imgproc/test/test_main.cpp
View file @
262fc330
#include "test_precomp.hpp"
CV_TEST_MAIN
(
"cv"
)
#if 0
using namespace cv;
using namespace std;
int main(int, char**)
{
#if 0
Mat src = imread("/Users/vp/Downloads/resize/original.png"), dst;
//resize(src, dst, Size(), 0.25, 0.25, INTER_NEAREST);
//imwrite("/Users/vp/Downloads/resize/xnview_nn_opencv.png", dst);
printf("\n\n\n\n\n\n***************************************\n");
//resize(src, dst, Size(), 0.25, 0.25, INTER_AREA);
//int nsteps = 4;
//double rate = pow(0.25,1./nsteps);
//for( int i = 0; i < nsteps; i++ )
// resize(src, src, Size(), rate, rate, INTER_LINEAR );
//GaussianBlur(src, src, Size(5, 5), 2, 2);
resize(src, src, Size(), 0.25, 0.25, INTER_NEAREST);
imwrite("/Users/vp/Downloads/resize/xnview_bilinear_opencv.png", src);
//resize(src, dst, Size(), 0.25, 0.25, INTER_LANCZOS4);
//imwrite("/Users/vp/Downloads/resize/xnview_lanczos3_opencv.png", dst);
#else
float data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24};
Mat src(5,5,CV_32FC1, data);
Mat dst;
resize(src, dst, Size(), 3, 3, INTER_NEAREST);
cout << src << endl;
cout << dst << endl;
#endif
return
0
;
}
#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