From de361671b272be8c411789a3f98b0cb9b6af29ac Mon Sep 17 00:00:00 2001 From: Davis King Date: Fri, 18 Oct 2013 22:49:58 -0400 Subject: [PATCH] Added overloads of fhog_to_image() and image_to_fhog() that work on rectangles. --- dlib/image_transforms/fhog.h | 22 +++++++++++++++++++++ dlib/image_transforms/fhog_abstract.h | 28 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/dlib/image_transforms/fhog.h b/dlib/image_transforms/fhog.h index 571ee5575..86fea3de5 100644 --- a/dlib/image_transforms/fhog.h +++ b/dlib/image_transforms/fhog.h @@ -415,6 +415,17 @@ namespace dlib return p/cell_size - point(1,1); } +// ---------------------------------------------------------------------------------------- + + inline rectangle image_to_fhog ( + const rectangle& rect, + int cell_size = 8 + ) + { + return rectangle(image_to_fhog(rect.tl_corner(),cell_size), + image_to_fhog(rect.br_corner(),cell_size)); + } + // ---------------------------------------------------------------------------------------- inline point fhog_to_image ( @@ -426,6 +437,17 @@ namespace dlib return (p+point(1,1))*cell_size + point(1,1) + point(cell_size/2,cell_size/2); } +// ---------------------------------------------------------------------------------------- + + inline rectangle fhog_to_image ( + const rectangle& rect, + int cell_size = 8 + ) + { + return rectangle(fhog_to_image(rect.tl_corner(),cell_size), + fhog_to_image(rect.br_corner(),cell_size)); + } + // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- diff --git a/dlib/image_transforms/fhog_abstract.h b/dlib/image_transforms/fhog_abstract.h index e776741ee..4d7390d69 100644 --- a/dlib/image_transforms/fhog_abstract.h +++ b/dlib/image_transforms/fhog_abstract.h @@ -100,6 +100,20 @@ namespace dlib input image. !*/ +// ---------------------------------------------------------------------------------------- + + inline rectangle image_to_fhog ( + const rectangle& rect, + int cell_size = 8 + ); + /*! + requires + - cell_size > 0 + ensures + - maps a rectangle from image space to fhog space. In particular this function returns: + rectangle(image_to_fhog(rect.tl_corner(),cell_size), image_to_fhog(rect.br_corner(),cell_size)) + !*/ + // ---------------------------------------------------------------------------------------- inline point fhog_to_image ( @@ -118,6 +132,20 @@ namespace dlib cell_size should be set to the value used by the call to extract_fhog_features(). !*/ +// ---------------------------------------------------------------------------------------- + + inline rectangle fhog_to_image ( + const rectangle& rect, + int cell_size = 8 + ); + /*! + requires + - cell_size > 0 + ensures + - 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)) + !*/ + // ---------------------------------------------------------------------------------------- template <