mirror of https://github.com/davisking/dlib.git
Changed fhog coordinate transforms so that they are properly invertible.
This commit is contained in:
parent
a67c7c73c9
commit
011758824a
|
@ -434,7 +434,13 @@ namespace dlib
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Convert to image space and then set to the center of the cell.
|
// Convert to image space and then set to the center of the cell.
|
||||||
return (p+point(1,1))*cell_size + point(1,1) + point(cell_size/2,cell_size/2);
|
point offset;
|
||||||
|
|
||||||
|
if (p.x() >= 0 && p.y() >= 0) offset = point(cell_size/2,cell_size/2);
|
||||||
|
if (p.x() < 0 && p.y() >= 0) offset = point(-cell_size/2,cell_size/2);
|
||||||
|
if (p.x() >= 0 && p.y() < 0) offset = point(cell_size/2,-cell_size/2);
|
||||||
|
if (p.x() < 0 && p.y() < 0) offset = point(-cell_size/2,-cell_size/2);
|
||||||
|
return (p+point(1,1))*cell_size + point(1,1) + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -130,6 +130,8 @@ namespace dlib
|
||||||
invertible. Therefore, the returned location will be the center of the cell
|
invertible. Therefore, the returned location will be the center of the cell
|
||||||
in the original image that contained the FHOG vector at position p. Moreover,
|
in the original image that contained the FHOG vector at position p. Moreover,
|
||||||
cell_size should be set to the value used by the call to extract_fhog_features().
|
cell_size should be set to the value used by the call to extract_fhog_features().
|
||||||
|
- Mapping from fhog space to image space is an invertible transformation. That
|
||||||
|
is, for any point P we have P == image_to_fhog(fhog_to_image(P,cell_size),cell_size).
|
||||||
!*/
|
!*/
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
@ -144,6 +146,8 @@ namespace dlib
|
||||||
ensures
|
ensures
|
||||||
- maps a rectangle from fhog space to image space. In particular this function returns:
|
- maps a rectangle from fhog space to image space. In particular this function returns:
|
||||||
rectangle(fhog_to_image(rect.tl_corner(),cell_size), fhog_to_image(rect.br_corner(),cell_size))
|
rectangle(fhog_to_image(rect.tl_corner(),cell_size), fhog_to_image(rect.br_corner(),cell_size))
|
||||||
|
- Mapping from fhog space to image space is an invertible transformation. That
|
||||||
|
is, for any rectangle R we have R == image_to_fhog(fhog_to_image(R,cell_size),cell_size).
|
||||||
!*/
|
!*/
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -103,9 +103,33 @@ namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_point_transforms()
|
||||||
|
{
|
||||||
|
for (int cell_size = 1; cell_size < 10; ++cell_size)
|
||||||
|
{
|
||||||
|
print_spinner();
|
||||||
|
for (long i = -10; i <= 10; ++i)
|
||||||
|
{
|
||||||
|
for (long j = -10; j <= 10; ++j)
|
||||||
|
{
|
||||||
|
for (long k = -10; k <= 10; ++k)
|
||||||
|
{
|
||||||
|
for (long l = -10; l <= 10; ++l)
|
||||||
|
{
|
||||||
|
rectangle rect(point(i,j), point(k,l));
|
||||||
|
DLIB_TEST(rect == image_to_fhog(fhog_to_image(rect,cell_size),cell_size));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void perform_test (
|
void perform_test (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
test_point_transforms();
|
||||||
test_on_small();
|
test_on_small();
|
||||||
|
|
||||||
print_spinner();
|
print_spinner();
|
||||||
|
|
Loading…
Reference in New Issue