Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
2ec475cc
Commit
2ec475cc
authored
Oct 03, 2013
by
Davis King
Browse files
Fixed some compile time errors in the new overload of resize_image().
parent
f35a90c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
+23
-20
dlib/image_transforms/interpolation.h
dlib/image_transforms/interpolation.h
+23
-20
No files found.
dlib/image_transforms/interpolation.h
View file @
2ec475cc
...
@@ -524,8 +524,8 @@ namespace dlib
...
@@ -524,8 +524,8 @@ namespace dlib
typename
image_type2
typename
image_type2
>
>
void
resize_image
(
void
resize_image
(
const
image_type1
&
img
,
const
image_type1
&
in_
img
,
image_type2
&
out
,
image_type2
&
out
_img
,
interpolate_bilinear
interpolate_bilinear
)
)
{
{
...
@@ -537,55 +537,58 @@ namespace dlib
...
@@ -537,55 +537,58 @@ namespace dlib
);
);
typedef
typename
image_type1
::
type
T
;
typedef
typename
image_type1
::
type
T
;
const
double
x_scale
=
(
img
.
nc
()
-
1
)
/
(
double
)
std
::
max
<
long
>
((
out
.
nc
()
-
1
),
1
);
const
double
x_scale
=
(
in_
img
.
nc
()
-
1
)
/
(
double
)
std
::
max
<
long
>
((
out
_img
.
nc
()
-
1
),
1
);
const
double
y_scale
=
(
img
.
nr
()
-
1
)
/
(
double
)
std
::
max
<
long
>
((
out
.
nr
()
-
1
),
1
);
const
double
y_scale
=
(
in_
img
.
nr
()
-
1
)
/
(
double
)
std
::
max
<
long
>
((
out
_img
.
nr
()
-
1
),
1
);
double
y
=
-
y_scale
;
double
y
=
-
y_scale
;
for
(
long
r
=
0
;
r
<
out
.
nr
();
++
r
)
for
(
long
r
=
0
;
r
<
out
_img
.
nr
();
++
r
)
{
{
y
+=
y_scale
;
y
+=
y_scale
;
const
long
top
=
static_cast
<
long
>
(
std
::
floor
(
y
));
const
long
top
=
static_cast
<
long
>
(
std
::
floor
(
y
));
const
long
bottom
=
std
::
min
(
top
+
1
,
img
.
nr
()
-
1
);
const
long
bottom
=
std
::
min
(
top
+
1
,
in_
img
.
nr
()
-
1
);
const
double
tb_frac
=
y
-
top
;
const
double
tb_frac
=
y
-
top
;
double
x
=
-
x_scale
;
double
x
=
-
x_scale
;
if
(
!
pixel_traits
<
T
>::
rgb
)
if
(
!
pixel_traits
<
T
>::
rgb
)
{
{
for
(
long
c
=
0
;
c
<
out
.
nc
();
++
c
)
for
(
long
c
=
0
;
c
<
out
_img
.
nc
();
++
c
)
{
{
x
+=
x_scale
;
x
+=
x_scale
;
const
long
left
=
static_cast
<
long
>
(
std
::
floor
(
x
));
const
long
left
=
static_cast
<
long
>
(
std
::
floor
(
x
));
const
long
right
=
std
::
min
(
left
+
1
,
img
.
nc
()
-
1
);
const
long
right
=
std
::
min
(
left
+
1
,
in_
img
.
nc
()
-
1
);
const
double
lr_frac
=
x
-
left
;
const
double
lr_frac
=
x
-
left
;
double
tl
=
0
,
tr
=
0
,
bl
=
0
,
br
=
0
;
double
tl
=
0
,
tr
=
0
,
bl
=
0
,
br
=
0
;
assign_pixel
(
tl
,
img
[
top
][
left
]);
assign_pixel
(
tl
,
in_
img
[
top
][
left
]);
assign_pixel
(
tr
,
img
[
top
][
right
]);
assign_pixel
(
tr
,
in_
img
[
top
][
right
]);
assign_pixel
(
bl
,
img
[
bottom
][
left
]);
assign_pixel
(
bl
,
in_
img
[
bottom
][
left
]);
assign_pixel
(
br
,
img
[
bottom
][
right
]);
assign_pixel
(
br
,
in_
img
[
bottom
][
right
]);
double
temp
=
(
1
-
tb_frac
)
*
((
1
-
lr_frac
)
*
tl
+
lr_frac
*
tr
)
+
double
temp
=
(
1
-
tb_frac
)
*
((
1
-
lr_frac
)
*
tl
+
lr_frac
*
tr
)
+
tb_frac
*
((
1
-
lr_frac
)
*
bl
+
lr_frac
*
br
);
tb_frac
*
((
1
-
lr_frac
)
*
bl
+
lr_frac
*
br
);
assign_pixel
(
out
[
r
][
c
],
temp
);
assign_pixel
(
out
_img
[
r
][
c
],
temp
);
}
}
}
}
else
else
{
{
for
(
long
c
=
0
;
c
<
out
.
nc
();
++
c
)
for
(
long
c
=
0
;
c
<
out
_img
.
nc
();
++
c
)
{
{
x
+=
x_scale
;
x
+=
x_scale
;
const
long
left
=
static_cast
<
long
>
(
std
::
floor
(
x
));
const
long
left
=
static_cast
<
long
>
(
std
::
floor
(
x
));
const
long
right
=
std
::
min
(
left
+
1
,
img
.
nc
()
-
1
);
const
long
right
=
std
::
min
(
left
+
1
,
in_
img
.
nc
()
-
1
);
const
double
lr_frac
=
x
-
left
;
const
double
lr_frac
=
x
-
left
;
const
T
tl
=
img
[
top
][
left
];
const
T
tl
=
in_
img
[
top
][
left
];
const
T
tr
=
img
[
top
][
right
];
const
T
tr
=
in_
img
[
top
][
right
];
const
T
bl
=
img
[
bottom
][
left
];
const
T
bl
=
in_
img
[
bottom
][
left
];
const
T
br
=
img
[
bottom
][
right
];
const
T
br
=
in_
img
[
bottom
][
right
];
vector_to_pixel
(
out
[
r
][
c
],
T
temp
;
assign_pixel
(
temp
,
0
);
vector_to_pixel
(
temp
,
(
1
-
tb_frac
)
*
((
1
-
lr_frac
)
*
pixel_to_vector
<
double
>
(
tl
)
+
lr_frac
*
pixel_to_vector
<
double
>
(
tr
))
+
(
1
-
tb_frac
)
*
((
1
-
lr_frac
)
*
pixel_to_vector
<
double
>
(
tl
)
+
lr_frac
*
pixel_to_vector
<
double
>
(
tr
))
+
tb_frac
*
((
1
-
lr_frac
)
*
pixel_to_vector
<
double
>
(
bl
)
+
lr_frac
*
pixel_to_vector
<
double
>
(
br
)));
tb_frac
*
((
1
-
lr_frac
)
*
pixel_to_vector
<
double
>
(
bl
)
+
lr_frac
*
pixel_to_vector
<
double
>
(
br
)));
assign_pixel
(
out_img
[
r
][
c
],
temp
);
}
}
}
}
}
}
...
...
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