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
052bf4df
Commit
052bf4df
authored
May 25, 2011
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added number of bands cropping in multi-bands blending
parent
c65a39be
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
blenders.cpp
modules/stitching/blenders.cpp
+9
-0
blenders.hpp
modules/stitching/blenders.hpp
+3
-3
No files found.
modules/stitching/blenders.cpp
View file @
052bf4df
...
@@ -158,8 +158,15 @@ void FeatherBlender::blend(Mat &dst, Mat &dst_mask)
...
@@ -158,8 +158,15 @@ void FeatherBlender::blend(Mat &dst, Mat &dst_mask)
void
MultiBandBlender
::
prepare
(
Rect
dst_roi
)
void
MultiBandBlender
::
prepare
(
Rect
dst_roi
)
{
{
dst_roi_final_
=
dst_roi
;
dst_roi_final_
=
dst_roi
;
// Crop unnecessary bands
double
max_len
=
static_cast
<
double
>
(
max
(
dst_roi
.
width
,
dst_roi
.
height
));
num_bands_
=
min
(
actual_num_bands_
,
static_cast
<
int
>
(
ceil
(
log
(
max_len
)
/
log
(
2.0
))));
// Add border to the final image, to ensure sizes are divided by (1 << num_bands_)
dst_roi
.
width
+=
((
1
<<
num_bands_
)
-
dst_roi
.
width
%
(
1
<<
num_bands_
))
%
(
1
<<
num_bands_
);
dst_roi
.
width
+=
((
1
<<
num_bands_
)
-
dst_roi
.
width
%
(
1
<<
num_bands_
))
%
(
1
<<
num_bands_
);
dst_roi
.
height
+=
((
1
<<
num_bands_
)
-
dst_roi
.
height
%
(
1
<<
num_bands_
))
%
(
1
<<
num_bands_
);
dst_roi
.
height
+=
((
1
<<
num_bands_
)
-
dst_roi
.
height
%
(
1
<<
num_bands_
))
%
(
1
<<
num_bands_
);
Blender
::
prepare
(
dst_roi
);
Blender
::
prepare
(
dst_roi
);
dst_pyr_laplace_
.
resize
(
num_bands_
+
1
);
dst_pyr_laplace_
.
resize
(
num_bands_
+
1
);
...
@@ -186,12 +193,14 @@ void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl)
...
@@ -186,12 +193,14 @@ void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl)
CV_Assert
(
img
.
type
()
==
CV_16SC3
);
CV_Assert
(
img
.
type
()
==
CV_16SC3
);
CV_Assert
(
mask
.
type
()
==
CV_8U
);
CV_Assert
(
mask
.
type
()
==
CV_8U
);
// Keep source image in memory with small border
int
gap
=
3
*
(
1
<<
num_bands_
);
int
gap
=
3
*
(
1
<<
num_bands_
);
Point
tl_new
(
max
(
dst_roi_
.
x
,
tl
.
x
-
gap
),
Point
tl_new
(
max
(
dst_roi_
.
x
,
tl
.
x
-
gap
),
max
(
dst_roi_
.
y
,
tl
.
y
-
gap
));
max
(
dst_roi_
.
y
,
tl
.
y
-
gap
));
Point
br_new
(
min
(
dst_roi_
.
br
().
x
,
tl
.
x
+
img
.
cols
+
gap
),
Point
br_new
(
min
(
dst_roi_
.
br
().
x
,
tl
.
x
+
img
.
cols
+
gap
),
min
(
dst_roi_
.
br
().
y
,
tl
.
y
+
img
.
rows
+
gap
));
min
(
dst_roi_
.
br
().
y
,
tl
.
y
+
img
.
rows
+
gap
));
// Ensure coordinates of top-left, bootom-right corners are divided by (1 << num_bands_)
tl_new
.
x
=
dst_roi_
.
x
+
(((
tl_new
.
x
-
dst_roi_
.
x
)
>>
num_bands_
)
<<
num_bands_
);
tl_new
.
x
=
dst_roi_
.
x
+
(((
tl_new
.
x
-
dst_roi_
.
x
)
>>
num_bands_
)
<<
num_bands_
);
tl_new
.
y
=
dst_roi_
.
y
+
(((
tl_new
.
y
-
dst_roi_
.
y
)
>>
num_bands_
)
<<
num_bands_
);
tl_new
.
y
=
dst_roi_
.
y
+
(((
tl_new
.
y
-
dst_roi_
.
y
)
>>
num_bands_
)
<<
num_bands_
);
int
width
=
br_new
.
x
-
tl_new
.
x
;
int
width
=
br_new
.
x
-
tl_new
.
x
;
...
...
modules/stitching/blenders.hpp
View file @
052bf4df
...
@@ -84,15 +84,15 @@ class MultiBandBlender : public Blender
...
@@ -84,15 +84,15 @@ class MultiBandBlender : public Blender
{
{
public
:
public
:
MultiBandBlender
(
int
num_bands
=
5
)
{
setNumBands
(
num_bands
);
}
MultiBandBlender
(
int
num_bands
=
5
)
{
setNumBands
(
num_bands
);
}
int
numBands
()
const
{
return
num_bands_
;
}
int
numBands
()
const
{
return
actual_
num_bands_
;
}
void
setNumBands
(
int
val
)
{
num_bands_
=
val
;
}
void
setNumBands
(
int
val
)
{
actual_
num_bands_
=
val
;
}
void
prepare
(
cv
::
Rect
dst_roi
);
void
prepare
(
cv
::
Rect
dst_roi
);
void
feed
(
const
cv
::
Mat
&
img
,
const
cv
::
Mat
&
mask
,
cv
::
Point
tl
);
void
feed
(
const
cv
::
Mat
&
img
,
const
cv
::
Mat
&
mask
,
cv
::
Point
tl
);
void
blend
(
cv
::
Mat
&
dst
,
cv
::
Mat
&
dst_mask
);
void
blend
(
cv
::
Mat
&
dst
,
cv
::
Mat
&
dst_mask
);
private
:
private
:
int
num_bands_
;
int
actual_num_bands_
,
num_bands_
;
std
::
vector
<
cv
::
Mat
>
dst_pyr_laplace_
;
std
::
vector
<
cv
::
Mat
>
dst_pyr_laplace_
;
std
::
vector
<
cv
::
Mat
>
dst_band_weights_
;
std
::
vector
<
cv
::
Mat
>
dst_band_weights_
;
cv
::
Rect
dst_roi_final_
;
cv
::
Rect
dst_roi_final_
;
...
...
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