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
35133df0
Commit
35133df0
authored
Jul 12, 2013
by
Fedor Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MTB alignment. Code, tests, application
parent
0aee5b61
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
4 deletions
+62
-4
photo.hpp
modules/photo/include/opencv2/photo.hpp
+6
-2
hdr_fusion.cpp
modules/photo/src/hdr_fusion.cpp
+32
-2
test_hdr.cpp
modules/photo/test/test_hdr.cpp
+24
-0
No files found.
modules/photo/include/opencv2/photo.hpp
View file @
35133df0
...
...
@@ -94,12 +94,16 @@ CV_EXPORTS_W void fastNlMeansDenoisingColoredMulti( InputArrayOfArrays srcImgs,
float
h
=
3
,
float
hColor
=
3
,
int
templateWindowSize
=
7
,
int
searchWindowSize
=
21
);
CV_EXPORTS_W
void
makeHDR
(
InputArrayOfArrays
srcImgs
,
const
std
::
vector
<
float
>&
exp_times
,
OutputArray
dst
);
CV_EXPORTS_W
void
makeHDR
(
InputArrayOfArrays
srcImgs
,
const
std
::
vector
<
float
>&
exp_times
,
OutputArray
dst
,
bool
align
=
false
);
CV_EXPORTS_W
void
tonemap
(
InputArray
src
,
OutputArray
dst
,
tonemap_algorithms
algorithm
,
const
std
::
vector
<
float
>&
params
=
std
::
vector
<
float
>
());
CV_EXPORTS_W
void
exposureFusion
(
InputArrayOfArrays
srcImgs
,
OutputArray
dst
,
float
wc
=
1
,
float
ws
=
1
,
float
we
=
0
);
CV_EXPORTS_W
void
exposureFusion
(
InputArrayOfArrays
srcImgs
,
OutputArray
dst
,
bool
align
=
false
,
float
wc
=
1
,
float
ws
=
1
,
float
we
=
0
);
CV_EXPORTS_W
void
shiftMat
(
InputArray
src
,
Point
shift
,
OutputArray
dst
);
CV_EXPORTS_W
Point
getExpShift
(
InputArray
img0
,
InputArray
img1
,
int
max_bits
=
6
,
int
exclude_range
=
4
);
}
// cv
#endif
modules/photo/src/hdr_fusion.cpp
View file @
35133df0
...
...
@@ -85,7 +85,27 @@ static void checkImages(std::vector<Mat>& images, bool hdr, const std::vector<fl
}
}
void
makeHDR
(
InputArrayOfArrays
_images
,
const
std
::
vector
<
float
>&
_exp_times
,
OutputArray
_dst
)
static
void
alignImages
(
std
::
vector
<
Mat
>&
src
,
std
::
vector
<
Mat
>&
dst
)
{
dst
.
resize
(
src
.
size
());
size_t
pivot
=
src
.
size
()
/
2
;
dst
[
pivot
]
=
src
[
pivot
];
Mat
gray_base
;
cvtColor
(
src
[
pivot
],
gray_base
,
COLOR_RGB2GRAY
);
for
(
size_t
i
=
0
;
i
<
src
.
size
();
i
++
)
{
if
(
i
==
pivot
)
{
continue
;
}
Mat
gray
;
cvtColor
(
src
[
i
],
gray
,
COLOR_RGB2GRAY
);
Point
shift
=
getExpShift
(
gray_base
,
gray
);
shiftMat
(
src
[
i
],
shift
,
dst
[
i
]);
}
}
void
makeHDR
(
InputArrayOfArrays
_images
,
const
std
::
vector
<
float
>&
_exp_times
,
OutputArray
_dst
,
bool
align
)
{
std
::
vector
<
Mat
>
images
;
_images
.
getMatVector
(
images
);
...
...
@@ -93,6 +113,11 @@ void makeHDR(InputArrayOfArrays _images, const std::vector<float>& _exp_times, O
_dst
.
create
(
images
[
0
].
size
(),
CV_32FC3
);
Mat
result
=
_dst
.
getMat
();
if
(
align
)
{
std
::
vector
<
Mat
>
new_images
;
alignImages
(
images
,
new_images
);
images
=
new_images
;
}
std
::
vector
<
float
>
exp_times
(
_exp_times
.
size
());
for
(
size_t
i
=
0
;
i
<
exp_times
.
size
();
i
++
)
{
exp_times
[
i
]
=
log
(
_exp_times
[
i
]);
...
...
@@ -128,12 +153,17 @@ void makeHDR(InputArrayOfArrays _images, const std::vector<float>& _exp_times, O
result
=
result
/
max
;
}
void
exposureFusion
(
InputArrayOfArrays
_images
,
OutputArray
_dst
,
float
wc
,
float
ws
,
float
we
)
void
exposureFusion
(
InputArrayOfArrays
_images
,
OutputArray
_dst
,
bool
align
,
float
wc
,
float
ws
,
float
we
)
{
std
::
vector
<
Mat
>
images
;
_images
.
getMatVector
(
images
);
checkImages
(
images
,
false
);
if
(
align
)
{
std
::
vector
<
Mat
>
new_images
;
alignImages
(
images
,
new_images
);
images
=
new_images
;
}
std
::
vector
<
Mat
>
weights
(
images
.
size
());
Mat
weight_sum
=
Mat
::
zeros
(
images
[
0
].
size
(),
CV_32FC1
);
for
(
size_t
im
=
0
;
im
<
images
.
size
();
im
++
)
{
...
...
modules/photo/test/test_hdr.cpp
View file @
35133df0
...
...
@@ -118,3 +118,26 @@ TEST(Photo_Tonemap, regression)
ASSERT_FALSE
(
max
>
0
);
}
}
TEST
(
Photo_Align
,
regression
)
{
const
int
TESTS_COUNT
=
100
;
string
folder
=
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"hdr/"
;
string
file_name
=
folder
+
"grand_canal_1_45.jpg"
;
Mat
img
=
imread
(
file_name
);
ASSERT_FALSE
(
img
.
empty
())
<<
"Could not load input image "
<<
file_name
;
cvtColor
(
img
,
img
,
COLOR_RGB2GRAY
);
int
max_bits
=
6
;
int
max_shift
=
64
;
srand
(
time
(
0
));
for
(
int
i
=
0
;
i
<
TESTS_COUNT
;
i
++
)
{
Point
shift
(
rand
()
%
max_shift
,
rand
()
%
max_shift
);
Mat
res
;
shiftMat
(
img
,
shift
,
res
);
Point
calc
=
getExpShift
(
img
,
res
,
max_bits
);
ASSERT_TRUE
(
calc
==
-
shift
);
}
}
\ No newline at end of file
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