Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BIAS::Rescale< InputStorageType, OutputStorageType > Class Template Referenceabstract

Down-, Upsampling routines and Resize. More...

#include <Filter/Rescale.hh>

+ Inheritance diagram for BIAS::Rescale< InputStorageType, OutputStorageType >:
+ Collaboration diagram for BIAS::Rescale< InputStorageType, OutputStorageType >:

Public Types

enum  TBorderHandling { TBH_full, TBH_same, TBH_valid }
 enum for border calculation, same meanings as in matlab: More...
 

Public Member Functions

void AddDebugLevel (const long int lv)
 
void AddDebugLevel (const std::string &name)
 
void CopyNonROIFromSource (const Image< InputStorageType > &src, Image< OutputStorageType > &dst) const
 run over all pixel which do not belong to the roi and set them to the value in the source image regardless of the roi of the source. More...
 
bool DebugLevelIsSet (const long int lv) const
 
bool DebugLevelIsSet (const std::string &name) const
 
int Downsample (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 generic downsample function. More...
 
int Downsample (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, const unsigned newwidth, const unsigned newheight)
 downsamples src to dst of size newwidth x newheight More...
 
int Downsample (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, const double factor)
 
int DownsampleBPoT (const Image< InputStorageType > &Source, Image< OutputStorageType > &Destination)
 The mean low pass filter is used implicitly, resulting in the coordinate conversion equation: More...
 
int DownsampleBy2 (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 Takes the source image that has to have a defined ROI. More...
 
int DownsampleBy2Color (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 assumes that destination is initialized. More...
 
template<>
int DownsampleBy2Color (const Image< unsigned char > &Source, Image< unsigned char > &Destination)
 
template<>
int DownsampleBy2Color (const Image< unsigned short > &Source, Image< unsigned short > &Destination)
 
int DownsampleBy2Grey (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 assumes that destination is initialized. More...
 
template<>
int DownsampleBy2Grey (const Image< unsigned char > &Source, Image< unsigned char > &Destination)
 
template<>
int DownsampleBy2Grey (const Image< unsigned short > &Source, Image< unsigned short > &Destination)
 
int DownsampleBy4 (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 calls the appropriate function for the color model mean low pass filter is usedimplicitly, resulting in the coordinate conversion equation: More...
 
int DownsampleBy4Grey (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 Assumes that destination is initialized. More...
 
template<>
int DownsampleBy4Grey (const Image< unsigned char > &Source, Image< unsigned char > &Destination)
 
template<>
int DownsampleBy4Grey (const Image< unsigned short > &Source, Image< unsigned short > &Destination)
 
virtual int Filter (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 scales the src to dst using the downsampling factor from SetFactor() More...
 
virtual int Filter (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)=0
 prototyp for filter computation function More...
 
int GetBorderHandling () const
 
void GetBorders (int &border_x, int &border_y) const
 
int GetDebugLevel () const
 
std::ostream & GetDebugStream () const
 
void GetDebugStream (std::ostream &os) const
 
double GetFactor () const
 
FilterNToN< InputStorageType,
OutputStorageType > * 
GetLowpass ()
 
double GetPositionOffset () const
 see DownsampleBy2 for explanation More...
 
long int Name2DebugLevel (const std::string &name) const
 looks up a debuglevel in the internal map, returns 0 if not found More...
 
long int NewDebugLevel (const std::string &name)
 creates a new debuglevel More...
 
Rescale< InputStorageType,
OutputStorageType > & 
operator= (const Rescale< InputStorageType, OutputStorageType > &other)
 
void PrintDebugLevel (std::ostream &os=std::cout) const
 
void RemoveDebugLevel (const long int lv)
 
void RemoveDebugLevel (const std::string &name)
 
 Rescale ()
 
 Rescale (const Rescale< InputStorageType, OutputStorageType > &other)
 
void SetBorderHandling (const int bh)
 
void SetDebugLevel (const long int lv)
 
void SetDebugLevel (const std::string &name)
 
void SetDebugStream (const std::ostream &os)
 
void SetFactor (double factor)
 the downsampling factor More...
 
void SetLowPassFilter (const FilterNToN< InputStorageType, OutputStorageType > &lowpass)
 Sets the lowpass filter. Creates a copy of the given filter. More...
 
void SetLowPassType (int lpt)
 Sets the lowpass filter by a lowpass filter type. More...
 
void SetNonROIToValue (Image< OutputStorageType > &dst, const std::vector< OutputStorageType > &t) const
 run over all pixel which do not belong to the roi and set them to some value (typically black) More...
 
void ShowDebugLevel (std::ostream &os=std::cout) const
 prints all internally known debuglevels More...
 
void UpdateLowpass (double factor)
 updates _lowpass using _RescaleMeanType More...
 
int Upsample (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 generic upsample function More...
 
int Upsample (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, const unsigned newwidth, const unsigned newheight)
 Upsamples src to dst of size width by height. More...
 
int UpsampleBy2 (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 assumes that destination is initialized dst width = 2*src.GetWidth() dst height = 2*src.GetHeight() only for interleaved images for images with arbitrary channel count More...
 
int UpsampleBy2Grey (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, InterpolationType i=NearestNeighbour, const double &valmin=0.0, const double &valmax=255.0)
 assumes that destination is initialized dst width = 2*src.GetWidth() dst height = 2*src.GetHeight() More...
 
int UpsampleBy2RGBInterleaved (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, InterpolationType i=NearestNeighbour, const double &valmin=0.0, const double &valmax=255.0)
 assumes that destination is initialized dst width = 2*src.GetWidth() dst height = 2*src.GetHeight() More...
 
int UpsampleGrey (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, const unsigned newwidth, const unsigned newheight)
 Upsamples src to dst of size width by height. More...
 
virtual ~Rescale ()
 

Static Public Member Functions

static long int GetGlobalDebugLevel ()
 
static void SetGlobalDebugLevel (long int lev)
 

Protected Member Functions

int _ApplyMeanFilter (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, const double factor)
 updates _mean using _RescaleMeanType and calls _mean->Filter(src, dst) More...
 
int _FillInterpolated (const Image< OutputStorageType > &src, const double &factor, Image< OutputStorageType > &dst)
 
int _FillInterpolatedColor (const Image< OutputStorageType > &src, Image< OutputStorageType > &dst)
 Same as _FillInterpolatedGrey but for multi channel interleaved images. More...
 
template<>
int _FillInterpolatedColor (const Image< unsigned char > &src, Image< unsigned char > &dst)
 
template<>
int _FillInterpolatedColor (const Image< unsigned short > &src, Image< unsigned short > &dst)
 
int _FillInterpolatedGrey (const Image< OutputStorageType > &src, Image< OutputStorageType > &dst)
 Assumes dst is initialized and ROI is set. More...
 
template<>
int _FillInterpolatedGrey (const Image< unsigned char > &src, Image< unsigned char > &dst)
 
template<>
int _FillInterpolatedGrey (const Image< unsigned short > &src, Image< unsigned short > &dst)
 
long ConsumeNextFreeDebuglevel_ ()
 returns the next available debuglevel More...
 
virtual void GetBordersValid_ (int &border_x, int &border_y) const
 

Protected Attributes

int _FilterBorderHandling
 
double _LastPositionOffset
 see DownsampleBy2 for explanation More...
 
long int _liDebugLevel
 
long int _liNextDebugLevel
 new concept, debuglevel are managed here in the debug class More...
 
FilterNToN< InputStorageType,
OutputStorageType > * 
_lowpass
 
double _RescaleFactor
 
double _RescaleMeanSigmaFactor
 
std::map< std::string, long int > _String2Debuglevel
 

Static Protected Attributes

static std::ostream _zDebugStream
 
static long int GlobalDebugLevel = 0
 

Detailed Description

template<class InputStorageType, class OutputStorageType>
class BIAS::Rescale< InputStorageType, OutputStorageType >

Down-, Upsampling routines and Resize.

This class is primarily a loose collection of several functions to rescale images while avoiding aliasing. If the rescale factor is smaller than 1 (magnification), then the upsample functions are used. Otherwise the image is first smoothed using the active low pass filter and then subsampled. There are several specializations for colors or for power of 2 rescales.

Most functions are designed to run fast and not all of these are consistent with the general parameters. Special attention must be paid to a) the exact rescale factor, because it is sometimes rounded such that the new image has exact integer dimensions, this can even lead to non-isotropic rescale in x and y direction. b) the offsets between the image coordinate systems: sometimes a 2x2 patch of pixels is averaged, which implies an offset of 0.5,0.5 compared to smoothing the image and sampling. See GetPositionOffset() c) the side effects caused by efficiency: if your sampling factor varies from 1.9 to 2.1 then for instance 2.0 is handled differently because it can be implemented more efficiently. Also grey values are filtered in a different way than rgba and so on. If you are not primarily interested in speed you might want to have a look at BIAS::ProjectionMapping or BIAS::AffineMapping to have full control.

Author
woelk 09/2004
Examples:
ExampleMixtureOfGaussians.cpp, and ExampleRescale.cpp.

Definition at line 71 of file Rescale.hh.

Member Enumeration Documentation

template<class InputStorageType, class OutputStorageType>
enum BIAS::FilterBase::TBorderHandling
inherited

enum for border calculation, same meanings as in matlab:

  • TBH_valid: returns only the pixels whose values can be computed without using zero padding of the input image. The resulting output image is smaller than the input image. The ROI of the output image is set accordingly.
  • TBH_same: returns the set of pixels that can be computed by applying the filter to all pixels that are actually part of the input image. Border pixels are computed using zero padding, but the center pixel of the computational kernel is applied only to pixels in the image. This results in an output image that is the same size as the input image.
  • TBH_full: returns the full convolution. This means conv2 returns all pixels for which any of the pixels in the computational molecule overlap pixels in the image, even when the center pixel is outside the input image. The resulting output image is larger than the input image. This is not implemented at the moment.
Enumerator
TBH_full 
TBH_same 
TBH_valid 

Definition at line 98 of file FilterBase.hh.

Constructor & Destructor Documentation

template<class InputImageType , class OutputImageType >
BIAS::Rescale< InputImageType, OutputImageType >::Rescale ( )
template<class InputImageType, class OutputImageType>
BIAS::Rescale< InputImageType, OutputImageType >::Rescale ( const Rescale< InputImageType, OutputImageType > &  other)

Definition at line 59 of file Rescale.cpp.

template<class InputImageType , class OutputImageType >
BIAS::Rescale< InputImageType, OutputImageType >::~Rescale ( )
virtual

Definition at line 82 of file Rescale.cpp.

Member Function Documentation

template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::_ApplyMeanFilter ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst,
const double  factor 
)
protected

updates _mean using _RescaleMeanType and calls _mean->Filter(src, dst)

Author
woelk 09/2004

Definition at line 2089 of file Rescale.cpp.

template<class InputImageType , class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::_FillInterpolated ( const Image< OutputImageType > &  src,
const double &  factor,
Image< OutputImageType > &  dst 
)
protected
template<class InputImageType , class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::_FillInterpolatedColor ( const Image< OutputImageType > &  src,
Image< OutputImageType > &  dst 
)
protected
template<>
int BIAS::Rescale< unsigned char, unsigned char >::_FillInterpolatedColor ( const Image< unsigned char > &  src,
Image< unsigned char > &  dst 
)
protected
template<>
int BIAS::Rescale< unsigned short, unsigned short >::_FillInterpolatedColor ( const Image< unsigned short > &  src,
Image< unsigned short > &  dst 
)
protected
template<class InputImageType , class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::_FillInterpolatedGrey ( const Image< OutputImageType > &  src,
Image< OutputImageType > &  dst 
)
protected

Assumes dst is initialized and ROI is set.

For every pixel (x, y) in ROI of dst, a bilinear lookup at the coordinates (x*src.Width/dst.Width, y*src.Height/dst.GetHeight) is performed. Only for one channel grey images

Author
woelk 09/2004

Definition at line 2112 of file Rescale.cpp.

References BIAS::Image< StorageType >::FastBilinearInterpolationGrey(), BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetColorModel(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), and BIAS::ImageBase::IsEmpty().

template<>
int BIAS::Rescale< unsigned char, unsigned char >::_FillInterpolatedGrey ( const Image< unsigned char > &  src,
Image< unsigned char > &  dst 
)
protected
template<>
int BIAS::Rescale< unsigned short, unsigned short >::_FillInterpolatedGrey ( const Image< unsigned short > &  src,
Image< unsigned short > &  dst 
)
protected
void BIAS::Debug::AddDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::AddDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 362 of file Debug.hh.

long BIAS::Debug::ConsumeNextFreeDebuglevel_ ( )
inlineprotectedinherited

returns the next available debuglevel

Author
woelk 09/2006

Definition at line 521 of file Debug.hh.

template<class InputStorageType, class OutputStorageType>
void FilterBase::CopyNonROIFromSource ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst 
) const
inherited

run over all pixel which do not belong to the roi and set them to the value in the source image regardless of the roi of the source.

Both images must have same size.

Author
koeser 12/2008

Definition at line 135 of file FilterBase.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), and BIAS::ROI_Corners.

bool BIAS::Debug::DebugLevelIsSet ( const long int  lv) const
inlineinherited
bool BIAS::Debug::DebugLevelIsSet ( const std::string &  name) const
inlineinherited

Definition at line 350 of file Debug.hh.

template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::Downsample ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst 
)
template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::Downsample ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst,
const unsigned  newwidth,
const unsigned  newheight 
)
template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::Downsample ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst,
const double  factor 
)
template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::DownsampleBPoT ( const Image< InputImageType > &  Source,
Image< OutputImageType > &  Destination 
)

The mean low pass filter is used implicitly, resulting in the coordinate conversion equation:

(2^n*xs+2^(n-1)-0.5, 2^n*ys+2^(n-1)-0.5) = (xb, yb) or (xs, ys) = ((xb-2^(n-1)+0.5)/2^n, (yb-2^(n-1)+0.5)/2^n)

where (xs, ys) is the pixel position in pixel coo. the smaller destination image and (xb, yb) is the position in pixel coo. in the bigger source image and the image is downsample by a facteo 2^n in width and in height. E.g. the ray through position (0,0) in the small image intercepts the bigger image at position (2^(n-1)-0.5, 2^(n-1)-0.5).

This must be taken into account when calculating the corrsponding K matrix of the smaller image. I.e. the principal point in the smaller image cannot be calculated by simply dividing by 2, but instead using the formula above.

Author
evers

Definition at line 1055 of file Rescale.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::IsInterleaved(), BIAS::ImageBase::RedirectImageDataPointer(), BIAS::Image< StorageType >::Release(), and BIAS::ImageBase::ReleaseImageDataPointer().

template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::DownsampleBy2 ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst 
)

Takes the source image that has to have a defined ROI.

Based on this ROI it will store a downsampled version in the destination image. The pixel values surounding the ROI will be taken into account while executing the mean filter. Therefore it is not possible to downsample the whole image.

Parameters
SourceImage with a defined ROI
DestinationImage where the rescaled image will be stored. Will initialized if required.
newwidthDesired width of the target image
newheightDesired height of the target image
Returns
-1 In any case of error (e.g. no ROI defined, ROI to close to the edge or desired width/height does no work)
Date
26.09.2003
Author
Ingo Thomsen Calls the appropriate function for the color model. Mean low pass filter of size 2x2 is used implicitly, resulting in the coordinate conversion equation:

(2*xs+0.5, 2*ys+0.5) = (xb, yb) or (xs, ys) = ((xb-0.5)/2.0, (yb-0.5)/2.0)

where (xs, ys) is the pixel position in pixel coo. the smaller destination image and (xb, yb) is the position in pixel coo. in the bigger source image E.g. the ray through position (0,0) in the small image intercepts the bigger image at position (0.5, 0.5).

This must be taken into account when calculating the corrsponding K matrix of the smaller image. I.e. the principal point in the smaller image cannot be calculated by simply dividing by 2, but instead using the formula above.

Author
woelk 09/2004

Definition at line 322 of file Rescale.cpp.

References BIAS::ImageBase::CM_Grey, BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetColorModel(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::IsInterleaved(), and BIAS::Image< StorageType >::Release().

Referenced by BIAS::OpenSceneGraphHelper::AdjustImageSizeToGPULimit(), and BIAS::SceneBGImage::SetImage().

template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::DownsampleBy2Color ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst 
)

assumes that destination is initialized.

mean low pass filter is used implicitly, resulting in the coordinate conversion equation:

(2*xs+0.5, 2*ys+0.5) = (xb, yb) or (xs, ys) = ((xb-0.5)/2.0, (yb-0.5)/2.0)

where (xs, ys) is the pixel position in pixel coo. the smaller destination image and (xb, yb) is the position in pixel coo. in the bigger source image E.g. the ray through position (0,0) in the small image intercepts the bigger image at position (0.5, 0.5).

This must be taken into account when calculating the corrsponding K matrix of the smaller image. I.e. the principal point in the smaller image cannot be calculated by simply dividing by 2, but instead using the formula above.

Destination width = floor(source.GetWidth()/2) Destination height = floor(source.GetHeight()/2) only for three channel interleaved images not tested with odd size images

Author
woelk 01/2003

Definition at line 538 of file Rescale.cpp.

References BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetPixelCount(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), and BIAS::ImageBase::IsPlanar().

template<>
int BIAS::Rescale< unsigned char, unsigned char >::DownsampleBy2Color ( const Image< unsigned char > &  Source,
Image< unsigned char > &  Destination 
)
template<>
int BIAS::Rescale< unsigned short, unsigned short >::DownsampleBy2Color ( const Image< unsigned short > &  Source,
Image< unsigned short > &  Destination 
)
template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::DownsampleBy2Grey ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst 
)

assumes that destination is initialized.

mean low pass filter is used implicitly, resulting in the coordinate conversion equation:

(2*xs+0.5, 2*ys+0.5) = (xb, yb) or (xs, ys) = ((xb-0.5)/2.0, (yb-0.5)/2.0)

where (xs, ys) is the pixel position in pixel coo. the smaller destination image and (xb, yb) is the position in pixel coo. in the bigger source image E.g. the ray through position (0,0) in the small image intercepts the bigger image at position (0.5, 0.5).

This must be taken into account when calculating the corrsponding K matrix of the smaller image. I.e. the principal point in the smaller image cannot be calculated by simply dividing by 2, but instead using the formula above.

Destination width = floor(source.GetWidth()/2) Destination height = floor(source.GetHeight()/2) Only for one channel images. Also make use of ROI in Source image (fast :-)) ).

Not tested with odd size images.

Author
woelk 01/2003

Definition at line 352 of file Rescale.cpp.

References BIAS::ROI::GetCorners(), BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), and BIAS::ROI::SetCorners().

template<>
int BIAS::Rescale< unsigned char, unsigned char >::DownsampleBy2Grey ( const Image< unsigned char > &  Source,
Image< unsigned char > &  Destination 
)
template<>
int BIAS::Rescale< unsigned short, unsigned short >::DownsampleBy2Grey ( const Image< unsigned short > &  Source,
Image< unsigned short > &  Destination 
)
template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::DownsampleBy4 ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst 
)

calls the appropriate function for the color model mean low pass filter is usedimplicitly, resulting in the coordinate conversion equation:

(4*xs+1.5, 4*ys+1.5) = (xb, yb) or (xs, ys) = ((xb-1.5)/4.0, (yb-1.5)/4.0)

where (xs, ys) is the pixel position in pixel coo. the smaller destination image and (xb, yb) is the position in pixel coo. in the bigger source image E.g. the ray through position (0,0) in the small image intercepts the bigger image at position (1.5, 1.5).

This must be taken into account when calculating the corrsponding K matrix of the smaller image. I.e. the principal point in the smaller image cannot be calculated by simply dividing by 2, but instead using the formula above.

Author
woelk 09/2004

Definition at line 741 of file Rescale.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetColorModel(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::IsInterleaved(), and BIAS::Image< StorageType >::Release().

template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::DownsampleBy4Grey ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst 
)

Assumes that destination is initialized.

The mean low pass filter is used implicitly, resulting in the coordinate conversion equation:

(4*xs+1.5, 4*ys+1.5) = (xb, yb) or (xs, ys) = ((xb-1.5)/4.0, (yb-1.5)/4.0)

where (xs, ys) is the pixel position in pixel coo. the smaller destination image and (xb, yb) is the position in pixel coo. in the bigger source image E.g. the ray through position (0,0) in the small image intercepts the bigger image at position (1.5, 1.5).

This must be taken into account when calculating the corrsponding K matrix of the smaller image. I.e. the principal point in the smaller image cannot be calculated by simply dividing by 2, but instead using the formula above.

Destination width = floor(source.GetWidth()/4) Destination height = floor(source.GetHeight()/4) only for one channel grey images also make use of ROI in Source image (fast :-)) )

Author
woelk 09/2004
Todo:
warning kerneltype sum needed here
Todo:
warning kerneltype div needed here

Definition at line 774 of file Rescale.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetColorModel(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), and BIAS::ROI::SetCorners().

template<>
int BIAS::Rescale< unsigned char, unsigned char >::DownsampleBy4Grey ( const Image< unsigned char > &  Source,
Image< unsigned char > &  Destination 
)
template<>
int BIAS::Rescale< unsigned short, unsigned short >::DownsampleBy4Grey ( const Image< unsigned short > &  Source,
Image< unsigned short > &  Destination 
)
template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::Filter ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst 
)
virtual
template<class InputStorageType, class OutputStorageType>
virtual int BIAS::FilterBase< InputStorageType, OutputStorageType >::Filter ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst 
)
pure virtualinherited

prototyp for filter computation function

Implemented in BIAS::Label, BIAS::Rescale< InputST, OutputST >, BIAS::Rescale< unsigned char, unsigned char >, BIAS::Rescale< StorageType, StorageType >, BIAS::DensityFilter< InputStorageType, OutputStorageType >, BIAS::Convolution< InputStorageType, OutputStorageType >, BIAS::Convolution< float, float >, BIAS::Convolution< InputST, OutputST >, BIAS::Convolution< OutputStorageType, OutputStorageType >, BIAS::Convolution< OutputST, OutputST >, BIAS::Convolution< StorageType, StorageType >, BIAS::Convolution< unsigned char, unsigned char >, BIAS::DistTransform< InputStorageType, OutputStorageType >, BIAS::DeInterlace< InputStorageType, OutputStorageType >, BIAS::CannyEdge< InputStorageType, OutputStorageType >, BIAS::CannyEdge< InputST, OutputST >, BIAS::GradientSobel3x3< InputStorageType, OutputStorageType >, BIAS::StructureTensor< InputStorageType, OutputStorageType >, BIAS::GradientSobel3x3< InputST, OutputST >, BIAS::StructureTensor< CalculationType, CalculationType >, BIAS::GradientSimple< InputStorageType, OutputStorageType >, BIAS::HistogramEqualization< InputStorageType, OutputStorageType >, BIAS::Gauss< InputStorageType, OutputStorageType >, BIAS::Gauss< float, float >, BIAS::Gauss< InputST, OutputST >, BIAS::Gauss< OutputStorageType, OutputStorageType >, BIAS::Gauss< StorageType, StorageType >, BIAS::Gauss< unsigned char, unsigned char >, BIAS::FilterNTo2N< InputStorageType, OutputStorageType >, BIAS::FilterNTo2N< InputST, OutputST >, BIAS::FilterNTo2N< CalculationType, CalculationType >, BIAS::TukeyWindow< InputStorageType, OutputStorageType >, BIAS::GradientGaussAsymmetric< InputStorageType, OutputStorageType >, BIAS::GradientGauss< InputStorageType, OutputStorageType >, BIAS::Binomial< InputStorageType, OutputStorageType >, BIAS::Dilation< InputStorageType, OutputStorageType >, BIAS::FilterNTo3N< InputStorageType, OutputStorageType >, BIAS::FilterNToN< InputStorageType, OutputStorageType >, BIAS::GaussThreshold< InputStorageType, OutputStorageType >, BIAS::Median< InputStorageType, OutputStorageType >, BIAS::FilterNTo3N< CalculationType, CalculationType >, BIAS::FilterNToN< float, float >, BIAS::FilterNToN< StorageType, CalculationType >, BIAS::FilterNToN< InputST, OutputST >, BIAS::FilterNToN< OutputStorageType, OutputStorageType >, BIAS::FilterNToN< OutputST, OutputST >, BIAS::FilterNToN< unsigned char, unsigned char >, BIAS::FilterNToN< StorageType, StorageType >, BIAS::Median< InputST, OutputST >, BIAS::Erosion< InputStorageType, OutputStorageType >, BIAS::Mean< InputStorageType, OutputStorageType >, BIAS::Thinning< InputStorageType, OutputStorageType >, BIAS::Mean< InputST, OutputST >, BIAS::CensusTransform< InputStorageType, OutputStorageType >, and BIAS::Bilateral< InputStorageType, OutputStorageType >.

template<class InputStorageType, class OutputStorageType>
int BIAS::FilterBase< InputStorageType, OutputStorageType >::GetBorderHandling ( ) const
inlineinherited

Definition at line 129 of file FilterBase.hh.

template<class InputStorageType , class OutputStorageType >
void FilterBase::GetBorders ( int &  border_x,
int &  border_y 
) const
inherited
template<class InputImageType , class OutputImageType >
void BIAS::Rescale< InputImageType, OutputImageType >::GetBordersValid_ ( int &  border_x,
int &  border_y 
) const
protectedvirtual
int BIAS::Debug::GetDebugLevel ( ) const
inlineinherited
std::ostream& BIAS::Debug::GetDebugStream ( ) const
inlineinherited

Definition at line 405 of file Debug.hh.

void BIAS::Debug::GetDebugStream ( std::ostream &  os) const
inlineinherited

Definition at line 414 of file Debug.hh.

template<class InputStorageType, class OutputStorageType>
double BIAS::Rescale< InputStorageType, OutputStorageType >::GetFactor ( ) const
inline

Definition at line 363 of file Rescale.hh.

static long int BIAS::Debug::GetGlobalDebugLevel ( )
inlinestaticinherited

Definition at line 431 of file Debug.hh.

template<class InputStorageType, class OutputStorageType>
FilterNToN<InputStorageType, OutputStorageType>* BIAS::Rescale< InputStorageType, OutputStorageType >::GetLowpass ( )
inline

Definition at line 374 of file Rescale.hh.

template<class InputStorageType, class OutputStorageType>
double BIAS::Rescale< InputStorageType, OutputStorageType >::GetPositionOffset ( ) const
inline

see DownsampleBy2 for explanation

Definition at line 372 of file Rescale.hh.

long int BIAS::Debug::Name2DebugLevel ( const std::string &  name) const
inlineinherited

looks up a debuglevel in the internal map, returns 0 if not found

Author
woelk 09/2006

Definition at line 454 of file Debug.hh.

long int BIAS::Debug::NewDebugLevel ( const std::string &  name)
inlineinherited
template<class InputStorageType, class OutputStorageType>
Rescale< InputStorageType, OutputStorageType > & BIAS::Rescale< InputStorageType, OutputStorageType >::operator= ( const Rescale< InputStorageType, OutputStorageType > &  other)
void BIAS::Debug::PrintDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

Definition at line 383 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const long int  lv)
inlineinherited

Definition at line 369 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 376 of file Debug.hh.

template<class InputStorageType, class OutputStorageType>
void BIAS::FilterBase< InputStorageType, OutputStorageType >::SetBorderHandling ( const int  bh)
inlineinherited
void BIAS::Debug::SetDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::SetDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 325 of file Debug.hh.

void BIAS::Debug::SetDebugStream ( const std::ostream &  os)
inlineinherited

Definition at line 398 of file Debug.hh.

template<class InputStorageType, class OutputStorageType>
void BIAS::Rescale< InputStorageType, OutputStorageType >::SetFactor ( double  factor)
inline
static void BIAS::Debug::SetGlobalDebugLevel ( long int  lev)
inlinestaticinherited

Definition at line 424 of file Debug.hh.

template<class InputImageType, class OutputImageType>
void BIAS::Rescale< InputImageType, OutputImageType >::SetLowPassFilter ( const FilterNToN< InputImageType, OutputImageType > &  lowpass)

Sets the lowpass filter. Creates a copy of the given filter.

Definition at line 2050 of file Rescale.cpp.

References BIAS::FilterNToN< InputStorageType, OutputStorageType >::Clone().

template<class InputImageType , class OutputImageType >
void BIAS::Rescale< InputImageType, OutputImageType >::SetLowPassType ( int  lpt)
template<class InputStorageType , class OutputStorageType>
void FilterBase::SetNonROIToValue ( Image< OutputStorageType > &  dst,
const std::vector< OutputStorageType > &  t 
) const
inherited

run over all pixel which do not belong to the roi and set them to some value (typically black)

Author
koeser 12/2008

Definition at line 84 of file FilterBase.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), and BIAS::ROI_Corners.

void BIAS::Debug::ShowDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

prints all internally known debuglevels

Author
woelk 09/2006

Definition at line 496 of file Debug.hh.

template<class InputImageType , class OutputImageType >
void BIAS::Rescale< InputImageType, OutputImageType >::UpdateLowpass ( double  factor)
template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::Upsample ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst 
)

generic upsample function

Author
woelk 09/2004

Definition at line 1157 of file Rescale.cpp.

References BIAS::ImageBase::GetHeight(), and BIAS::ImageBase::GetWidth().

Referenced by BIAS::VideoSink_FFmpeg::AddFrame(), and BIAS::FitCircleFrame::OnRescaleImage().

template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::Upsample ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst,
const unsigned  newwidth,
const unsigned  newheight 
)

Upsamples src to dst of size width by height.

width > src.GetWidth() && height > src.GetHeight() is asserted. ROI not supported.

Parameters
exactfactorthis is the rescale factor, while new width and newheight just determine the dimensions of the image. If exactfactor=0, then it is determined from the width ratio.
Author
?

Definition at line 1170 of file Rescale.cpp.

References BIAS::Image< StorageType >::BilinearInterpolation(), BIAS::ImageBase::GetChannelCount(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::IsInterleaved(), BIAS::ImageBase::RedirectImageDataPointer(), BIAS::Image< StorageType >::Release(), BIAS::ImageBase::ReleaseImageDataPointer(), and BIAS::ImageBase::SamePixelAndChannelCount().

template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::UpsampleBy2 ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst 
)

assumes that destination is initialized dst width = 2*src.GetWidth() dst height = 2*src.GetHeight() only for interleaved images for images with arbitrary channel count

Author
woelk 04/2004

Definition at line 1979 of file Rescale.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetPixelCount(), BIAS::ImageBase::GetWidthStep(), and BIAS::ImageBase::IsInterleaved().

template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::UpsampleBy2Grey ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst,
InterpolationType  i = NearestNeighbour,
const double &  valmin = 0.0,
const double &  valmax = 255.0 
)

assumes that destination is initialized dst width = 2*src.GetWidth() dst height = 2*src.GetHeight()

Parameters
InterpolationTypewhich interpolation to use for off-grid pixel
valmin/valmaxif bicubic, limit range to these values only for one channel images
Author
woelk/koeser

Definition at line 1325 of file Rescale.cpp.

References BIAS::Bicubic, BIAS::Bilinear, BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetPixelCount(), BIAS::ImageBase::GetWidth(), and BIAS::NearestNeighbour.

template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::UpsampleBy2RGBInterleaved ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst,
InterpolationType  i = NearestNeighbour,
const double &  valmin = 0.0,
const double &  valmax = 255.0 
)

assumes that destination is initialized dst width = 2*src.GetWidth() dst height = 2*src.GetHeight()

Parameters
InterpolationTypewhich interpolation to use for off-grid pixel
valmin/valmaxif bicubic, limit range to these values only for three channel images
Author
koeser 06/2005

Definition at line 1549 of file Rescale.cpp.

References BIAS::Bicubic, BIAS::Bilinear, BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetPixelCount(), BIAS::ImageBase::GetWidth(), BIAS::ImageBase::IsPlanar(), and BIAS::NearestNeighbour.

template<class InputImageType, class OutputImageType>
int BIAS::Rescale< InputImageType, OutputImageType >::UpsampleGrey ( const Image< InputImageType > &  src,
Image< OutputImageType > &  dst,
const unsigned  newwidth,
const unsigned  newheight 
)

Upsamples src to dst of size width by height.

Only for one channel grey images. ROI not supported. width > src.GetWidth() && height > src.GetHeight() is asserted.

Parameters
src[in], source image
dst[out], destination image
newwidth[in], new image width after upsample
newheight[in], new image height after upsample
Returns
0 on success, < 0 otherwise
Author
MIP

Definition at line 1242 of file Rescale.cpp.

References BIAS::Image< StorageType >::FastBilinearInterpolationGrey(), BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetColorModel(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::IsInterleaved(), BIAS::ImageBase::RedirectImageDataPointer(), BIAS::Image< StorageType >::Release(), BIAS::ImageBase::ReleaseImageDataPointer(), and BIAS::ImageBase::SamePixelAndChannelCount().

Member Data Documentation

template<class InputStorageType, class OutputStorageType>
int BIAS::FilterBase< InputStorageType, OutputStorageType >::_FilterBorderHandling
protectedinherited
template<class InputStorageType, class OutputStorageType>
double BIAS::Rescale< InputStorageType, OutputStorageType >::_LastPositionOffset
protected
long int BIAS::Debug::_liDebugLevel
protectedinherited

Definition at line 510 of file Debug.hh.

Referenced by BIAS::Debug::operator=(), and BIAS::ImageBase::operator=().

long int BIAS::Debug::_liNextDebugLevel
protectedinherited

new concept, debuglevel are managed here in the debug class

Definition at line 516 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

template<class InputStorageType, class OutputStorageType>
FilterNToN<InputStorageType, OutputStorageType>* BIAS::Rescale< InputStorageType, OutputStorageType >::_lowpass
protected
template<class InputStorageType, class OutputStorageType>
double BIAS::Rescale< InputStorageType, OutputStorageType >::_RescaleFactor
protected
template<class InputStorageType, class OutputStorageType>
double BIAS::Rescale< InputStorageType, OutputStorageType >::_RescaleMeanSigmaFactor
protected
std::map<std::string, long int> BIAS::Debug::_String2Debuglevel
protectedinherited

Definition at line 517 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

std::ostream BIAS::Debug::_zDebugStream
staticprotectedinherited

Definition at line 511 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

long int BIAS::Debug::GlobalDebugLevel = 0
staticprotectedinherited

Definition at line 513 of file Debug.hh.


The documentation for this class was generated from the following files: