Commit a4609486 authored by Davis King's avatar Davis King

Previously, when using spatially_filter_image(), the intermediate filter computations

were carried out using variables of the same basic type as the input image's pixels.
I changed this to use the scalar type used by the actual filter given to this function
since this should result in fewer surprises (since the filter usually determines what
type is appropriate, not the input image).
parent 3e569392
...@@ -71,9 +71,9 @@ namespace dlib ...@@ -71,9 +71,9 @@ namespace dlib
{ {
for (long c = first_col; c < last_col; ++c) for (long c = first_col; c < last_col; ++c)
{ {
typedef typename pixel_traits<typename in_image_type::type>::basic_pixel_type bp_type; typedef typename EXP::type ptype;
typename promote<bp_type>::type p; ptype p;
typename promote<bp_type>::type temp = 0; ptype temp = 0;
for (long m = 0; m < filter.nr(); ++m) for (long m = 0; m < filter.nr(); ++m)
{ {
for (long n = 0; n < filter.nc(); ++n) for (long n = 0; n < filter.nc(); ++n)
...@@ -170,11 +170,11 @@ namespace dlib ...@@ -170,11 +170,11 @@ namespace dlib
const long last_row = in_img.nr() - col_filter.size()/2; const long last_row = in_img.nr() - col_filter.size()/2;
const long last_col = in_img.nc() - row_filter.size()/2; const long last_col = in_img.nc() - row_filter.size()/2;
typedef typename pixel_traits<typename in_image_type::type>::basic_pixel_type bp_type;
typedef typename out_image_type::mem_manager_type mem_manager_type; typedef typename out_image_type::mem_manager_type mem_manager_type;
typedef typename EXP1::type ptype;
array2d<typename promote<bp_type>::type,mem_manager_type> temp_img; array2d<ptype,mem_manager_type> temp_img;
temp_img.set_size(in_img.nr(), in_img.nc()); temp_img.set_size(in_img.nr(), in_img.nc());
// apply the row filter // apply the row filter
...@@ -182,8 +182,8 @@ namespace dlib ...@@ -182,8 +182,8 @@ namespace dlib
{ {
for (long c = first_col; c < last_col; ++c) for (long c = first_col; c < last_col; ++c)
{ {
typename promote<bp_type>::type p; ptype p;
typename promote<bp_type>::type temp = 0; ptype temp = 0;
for (long n = 0; n < row_filter.size(); ++n) for (long n = 0; n < row_filter.size(); ++n)
{ {
// pull out the current pixel and put it into p // pull out the current pixel and put it into p
...@@ -199,7 +199,7 @@ namespace dlib ...@@ -199,7 +199,7 @@ namespace dlib
{ {
for (long c = first_col; c < last_col; ++c) for (long c = first_col; c < last_col; ++c)
{ {
typename promote<bp_type>::type temp = 0; ptype temp = 0;
for (long m = 0; m < col_filter.size(); ++m) for (long m = 0; m < col_filter.size(); ++m)
{ {
temp += temp_img[r-col_filter.size()/2+m][c]*col_filter(m); temp += temp_img[r-col_filter.size()/2+m][c]*col_filter(m);
......
...@@ -38,6 +38,8 @@ namespace dlib ...@@ -38,6 +38,8 @@ namespace dlib
ensures ensures
- Applies the given spatial filter to in_img and stores the result in out_img. Also - Applies the given spatial filter to in_img and stores the result in out_img. Also
divides each resulting pixel by scale. divides each resulting pixel by scale.
- The intermediate filter computations will be carried out using variables of type EXP::type.
This is whatever scalar type is used inside the filter matrix.
- Pixel values are stored into out_img using the assign_pixel() function and therefore - Pixel values are stored into out_img using the assign_pixel() function and therefore
any applicable color space conversion or value saturation is performed. any applicable color space conversion or value saturation is performed.
- if (pixel_traits<typename in_image_type::type>::grayscale == false) then - if (pixel_traits<typename in_image_type::type>::grayscale == false) then
...@@ -87,6 +89,8 @@ namespace dlib ...@@ -87,6 +89,8 @@ namespace dlib
effect as calling the regular spatially_filter_image() routine with a filter, effect as calling the regular spatially_filter_image() routine with a filter,
FILT, defined as follows: FILT, defined as follows:
- FILT(r,c) == col_filter(r)*row_filter(c) - FILT(r,c) == col_filter(r)*row_filter(c)
- The intermediate filter computations will be carried out using variables of type EXP1::type.
This is whatever scalar type is used inside the row_filter matrix.
- Pixel values are stored into out_img using the assign_pixel() function and therefore - Pixel values are stored into out_img using the assign_pixel() function and therefore
any applicable color space conversion or value saturation is performed. any applicable color space conversion or value saturation is performed.
- if (pixel_traits<typename in_image_type::type>::grayscale == false) then - if (pixel_traits<typename in_image_type::type>::grayscale == false) then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment