libeblearn
|
#include <ebl_preprocessing.h>
Public Member Functions | |
resizepp_module (idxdim &size, uint mode=MEAN_RESIZE, module_1_1< T, Tstate > *pp=NULL, bool own_pp=true, idxdim *zpad=NULL, bool preserve_ratio=true) | |
resizepp_module (uint mode=MEAN_RESIZE, module_1_1< T, Tstate > *pp=NULL, bool own_pp=true, idxdim *zpad=NULL, bool preserve_ratio=true) | |
resizepp_module (double hratio, double wratio, uint mode=MEAN_RESIZE, module_1_1< T, Tstate > *pp=NULL, bool own_pp=true, idxdim *zpad=NULL, bool preserve_ratio=true) | |
virtual | ~resizepp_module () |
destructor | |
void | set_dimensions (intg height_, intg width_) |
sets the desired output dimensions. | |
void | set_input_region (const rect< int > &inr) |
void | set_output_region (const rect< int > &outr) |
void | set_jitter (int h, int w, float s, float r) |
void | set_scale_factor (double s) |
Scale input region by factor s. | |
void | set_scale_factor (double sh, double sw) |
Scale input region hxw by factors shxsw. | |
void | set_zpads (intg hpad, intg wpad) |
Set zero padding on each side for each dimension. | |
void | set_zpad (idxdim &kernel) |
Set zero padding based on 'kernel'. | |
void | set_zpad (midxdim &kernels) |
Set zero padding based on 'kernel'. | |
rect< int > | get_original_bbox () |
Returns the input box in output space. | |
rect< int > | get_input_bbox () |
Returns the input box in input image space. | |
const vector< rect< int > > & | get_input_bboxes () |
Returns all bounding boxes extracted in input space. | |
const vector< rect< int > > & | get_original_bboxes () |
Returns all bounding boxes extracted in the output space. | |
virtual rect< int > | compute_regions (Tstate &in) |
Compute the input and output regions given 'in' and return input region. | |
virtual void | remember_regions (intg outh, intg outw, rect< int > &r) |
Set the input_bbox given output height and width. | |
virtual void | set_display_range (T min, T max) |
Set the displayable range of values for outputs of this module. | |
virtual void | get_display_range (T &min, T &max) |
Set 'min' and 'max' to the displayable range of this module's outputs. | |
virtual void | fprop (Tstate &in, Tstate &out) |
forward propagation from in to out | |
virtual void | fprop (Tstate &in, idx< T > &out) |
forward propagation from in to out | |
virtual void | fprop (Tstate &in, midx< T > &out) |
virtual resizepp_module< T, Tstate > * | copy () |
Returns a deep copy of this module. | |
virtual std::string | describe () |
Returns a string describing this module and its parameters. | |
virtual mstate< Tstate > * | last_output () |
Returns a reference to the last output state set by fprop. | |
virtual void | set_output_copy (mstate< Tstate > &out) |
virtual fidxdim | bprop_size (const fidxdim &osize) |
virtual mfidxdim | bprop_size (mfidxdim &osize) |
virtual mfidxdim | get_msize () |
virtual uint | nlayers () |
Returns the number of layers produced by this resizing module. | |
virtual void | copy_outputs (mstate< Tstate > &out) |
Copy outputs 'out' into internal buffers. | |
Protected Attributes | |
module_1_1< T, Tstate > * | pp |
preprocessing module | |
bool | own_pp |
responsible for pp's deletion | |
idxdim | size |
target sizes | |
intg | height |
target height | |
intg | width |
target width | |
Tstate | inpp |
Tstate | outpp |
input/output buffers for pp | |
idx< T > | tmp |
temporary buffer | |
idx< T > | tmp2 |
temporary buffer | |
Tstate | tmp3 |
temporary buffer | |
rect< int > | input_bbox |
bbox of last extracted box in input | |
uint | mode |
resizing mode. | |
int | input_mode |
mode parameter to resize function. | |
rect< int > | inrect |
input region of image | |
rect< int > | outrect |
input region in output image | |
bool | inrect_set |
use input region or not. | |
bool | outrect_set |
use output region or not. | |
idxdim * | dzpad |
zero-padding for each side | |
zpad_module< T, Tstate > * | zpad |
Zero padding module. | |
int | hjitter |
Shift output by this many pixels. | |
int | wjitter |
Shift output by this many pixels. | |
float | sjitter |
Multiply scale by this. | |
float | rjitter |
Rotate by this degrees. | |
double | scale_hfactor |
Input region scale h factor. | |
double | scale_wfactor |
Input region scale w factor. | |
bool | preserve_ratio |
Preserve aspect ratio or not. | |
double | hratio |
Resizing ratio in height dim. | |
double | wratio |
Resizing ratio in width dim. | |
mstate< Tstate > * | lastout |
Pointer to last out set by fprop. | |
mstate< Tstate > | lout |
Container for last out of fprop. | |
mfidxdim | msize |
Resulting dims of bprop_size. | |
mstate< Tstate > * | out_copy |
A copy of last fprop output. | |
T | display_min |
Lower bound of displayable range. | |
T | display_max |
Higher bound of displayable range. | |
vector< rect< int > > | input_bboxes |
Vector of input bboxes. | |
vector< rect< int > > | original_bboxes |
bbox of original inputs in outputs |
Resize the input to the desired output (while preserving aspect ratio) and apply a preprocessing module. This is useful because in some situations preprocessing needs to be done within the resizing operation. e.g. when resizing while preserving aspect ratio, the output must eventually be copied into the true desired output dimensions, but preprocessing must be done before copying it to avoid edge detection between the empty parts of the image.
ebl::resizepp_module< T, Tstate >::resizepp_module | ( | idxdim & | size, |
uint | mode = MEAN_RESIZE , |
||
module_1_1< T, Tstate > * | pp = NULL , |
||
bool | own_pp = true , |
||
idxdim * | zpad = NULL , |
||
bool | preserve_ratio = true |
||
) |
Constructor. Preprocessing module pp will be deleted upon destruction.
size | The target dimensions (heightxwidth) |
pp | An optional pointer to a preprocessing module. If NULL, no preprocessing is performed. This module is responsible for destroying the preprocessing module. |
mode | The type of resizing (MEAN_RESIZE, BILINEAR_RESIZE, GAUSSIAN_RESIZE). |
zpad | Optional zero-padding is added on each side |
preserve_ratio | If true, fit the image into target size while keeping aspect ratio, potential empty areas are filled with zeros. |
ebl::resizepp_module< T, Tstate >::resizepp_module | ( | uint | mode = MEAN_RESIZE , |
module_1_1< T, Tstate > * | pp = NULL , |
||
bool | own_pp = true , |
||
idxdim * | zpad = NULL , |
||
bool | preserve_ratio = true |
||
) |
Constructor without target dimensions. set_dimensions should be called later. Preprocessing module pp will be deleted upon destruction.
pp | An optional pointer to a preprocessing module. If NULL, no preprocessing is performed. This module is responsible for destroying the preprocessing module. |
mode | The type of resizing (MEAN_RESIZE, BILINEAR_RESIZE, GAUSSIAN_RESIZE). |
size | The target dimensions (heightxwidth) |
zpad | Optional zero-padding is added on each side |
preserve_ratio | If true, fit the image into target size while keeping aspect ratio, potential empty areas are filled with zeros. |
ebl::resizepp_module< T, Tstate >::resizepp_module | ( | double | hratio, |
double | wratio, | ||
uint | mode = MEAN_RESIZE , |
||
module_1_1< T, Tstate > * | pp = NULL , |
||
bool | own_pp = true , |
||
idxdim * | zpad = NULL , |
||
bool | preserve_ratio = true |
||
) |
This constructor specifies resizing ratio for each dimension instead of fixed target sizes. The default resizing method is bilinear, as as other methods do not currently implement ratio inputs.
pp | An optional pointer to a preprocessing module. If NULL, no preprocessing is performed. This module is responsible for destroying the preprocessing module. |
mode | The type of resizing (MEAN_RESIZE, BILINEAR_RESIZE, GAUSSIAN_RESIZE). |
size | The target dimensions (heightxwidth) |
zpad | Optional zero-padding is added on each side |
preserve_ratio | If true, fit the image into target size while keeping aspect ratio, potential empty areas are filled with zeros. |
fidxdim ebl::resizepp_module< T, Tstate >::bprop_size | ( | const fidxdim & | osize | ) | [virtual] |
Returns input dimensions corresponding to output dimensions 'osize'. Implementation of this method helps automatic scaling of input data but is optional.
Reimplemented from ebl::module_1_1< T, Tstate >.
mfidxdim ebl::resizepp_module< T, Tstate >::bprop_size | ( | mfidxdim & | osize | ) | [virtual] |
Returns input dimensions corresponding to output dimensions 'osize'. Implementation of this method helps automatic scaling of input data but is optional.
Reimplemented from ebl::module_1_1< T, Tstate >.
Reimplemented in ebl::pyramid_module< T, Tstate >, ebl::fovea_module< T, Tstate >, and ebl::laplacian_pyramid_module< T, Tstate >.
void ebl::resizepp_module< T, Tstate >::fprop | ( | Tstate & | in, |
midx< T > & | out | ||
) | [virtual] |
Process 'in' into 'out' which will contain an array of idx, where each idx has different scale with different dimensions.
Reimplemented in ebl::pyramid_module< T, Tstate >, ebl::fovea_module< T, Tstate >, and ebl::laplacian_pyramid_module< T, Tstate >.
mfidxdim ebl::resizepp_module< T, Tstate >::get_msize | ( | ) | [virtual] |
Returns a vector of idxdim stored after a call to fprop_size() or bprop_size() on this module. If containing multiple elements, they correspond to each state size contained in last_output().
void ebl::resizepp_module< T, Tstate >::set_input_region | ( | const rect< int > & | inr | ) |
set the region to use in the input image. by default, the input region is the entire image.
void ebl::resizepp_module< T, Tstate >::set_jitter | ( | int | h, |
int | w, | ||
float | s, | ||
float | r | ||
) |
Shift input region by h and w pixels, multiply scale by s and rotate by r.
void ebl::resizepp_module< T, Tstate >::set_output_copy | ( | mstate< Tstate > & | out | ) | [virtual] |
Set a buffer in which to copy the output of future fprop() calls. This is useful to keep the preprocessed input around when discarding intermediate buffers for memory optimization.
void ebl::resizepp_module< T, Tstate >::set_output_region | ( | const rect< int > & | outr | ) |
set the region to use in the output image. by default, the output region is the entire size defined by set_dimensions().