Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ShapeOps.H File Reference


Detailed Description

Shape operations on Image

Definition in file ShapeOps.H.

#include "Util/Assert.H"
#include "Util/Types.H"
#include <string>

Include dependency graph for ShapeOps.H:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  RescaleType {
  RESCALE_SIMPLE_NOINTERP, RESCALE_SIMPLE_BILINEAR, RESCALE_FILTER_BOX, RESCALE_FILTER_TRIANGLE,
  RESCALE_FILTER_BELL, RESCALE_FILTER_BSPLINE, RESCALE_FILTER_HERMITE, RESCALE_FILTER_LANCZOS3,
  RESCALE_FILTER_MITCHELL
}
 Different types of image rescaling functions. More...

Functions

template<class T_or_RGB>
Image< T_or_RGB > quickLocalAvg (const Image< T_or_RGB > &array, const int scale)
 Compute quick and dirty scaling down of array.
template<class T_or_RGB>
Image< T_or_RGB > quickLocalAvg2x2 (const Image< T_or_RGB > &array)
 Compute local average of each 2x2 block and decimate by 2x2.
template<class T_or_RGB>
Image< T_or_RGB > quickLocalMax (const Image< T_or_RGB > &array, const int scale)
 Compute quick and dirty scaling down of array.
template<class T_or_RGB>
Image< T_or_RGB > quickLocalMin (const Image< T_or_RGB > &array, const int scale)
 Compute quick and dirty scaling down of array.
template<class T_or_RGB>
Image< T_or_RGB > quickInterpolate (const Image< T_or_RGB > &src, const int sfactor)
 Dumb interpolation.
template<class T_or_RGB>
Image< T_or_RGB > interpolate (const Image< T_or_RGB > &src)
 Double image size, using linear interpolation.
template<class T_or_RGB>
Image< T_or_RGB > rescaleBilinear (const Image< T_or_RGB > &src, const Dims &dims)
 Scale to new width & height using bilinear interpolation.
template<class T_or_RGB>
Image< T_or_RGB > rescaleBilinear (const Image< T_or_RGB > &src, int width, int height)
 Scale to new width & height using bilinear interpolation.
template<class T_or_RGB>
Image< T_or_RGB > rescaleNI (const Image< T_or_RGB > &src, const Dims &dims)
 Scale to new width & height with no interpolation.
template<class T_or_RGB>
Image< T_or_RGB > rescaleNI (const Image< T_or_RGB > &src, int width, int height)
 Scale to new width & height with no interpolation.
RescaleType getRescaleTypeFromChar (char ftype)
 Convert a character mnemonic into a RescaleType;.
std::string convertToString (RescaleType ftype)
 Convert RescaleType -> string.
void convertFromString (const std::string &str1, RescaleType &ftype)
 Convert string -> RescaleType.
template<class T_or_RGB>
Image< T_or_RGB > rescale (const Image< T_or_RGB > &src, const Dims &newdims, RescaleType ftype=RESCALE_SIMPLE_BILINEAR)
 Generic image rescaling function with runtime-selectable rescaling algorithm.
template<class T_or_RGB>
Image< T_or_RGB > rescale (const Image< T_or_RGB > &src, const int width, const int height, RescaleType ftype=RESCALE_SIMPLE_BILINEAR)
 Generic image rescaling function with runtime-selectable rescaling algorithm.
template<class T_or_RGB>
Image< T_or_RGB > rescaleOpt (const Image< T_or_RGB > &src, const Dims &dims, const bool interp)
 Scale to new width & height.
template<class T_or_RGB>
Image< T_or_RGB > rescaleOpt (const Image< T_or_RGB > &src, int width, int height, const bool interp)
 Scale to new width & height.
template<class T>
Image< PixRGB< T > > downscaleFancy (const Image< PixRGB< T > > &src, int width, int height, int weighting_slope, bool no_weight_black)
 downscale an image using fancy widgets like anti-aliasing, resampling
template<class T>
Image< T > downSize (const Image< T > &src, const Dims &dims, const int filterWidth=9)
 Downsize using alternating lowpass/decimate operations.
template<class T>
Image< T > downSize (const Image< T > &src, const int width, const int height, const int filterWidth=9)
 Downsize using alternating lowpass/decimate operations.
Image< float > downSizeClean (const Image< float > &src, const Dims &new_dims, const int filterWidth=9)
 Like downSize(), except image proportions don't have to match exactly.
template<class T_or_RGB>
Image< T_or_RGB > concatArray (const Image< T_or_RGB > arr[], const int nbarr, const int Nx, const int destX=-1, const int destY=-1)
 Concatenate all image arrays, Nx arrays per line.
template<class T_or_RGB>
Image< T_or_RGB > decXY (const Image< T_or_RGB > &src, const int xfactor=2, const int yfactor=-1)
 Decimate in X and Y (take one every 'factor' pixels).
template<class T_or_RGB>
Image< T_or_RGB > decX (const Image< T_or_RGB > &src, const int factor=2)
 Decimate in X (take one every 'factor' pixels).
template<class T_or_RGB>
Image< T_or_RGB > decY (const Image< T_or_RGB > &src, const int factor=2)
 Decimate in Y (take one every 'factor' pixels).
template<class T>
Image< T > blurAndDecY (const Image< T > &src, const int factor)
 Blur and then decimate in Y. Equivalent to decY(sepFilter(src)).
template<class T_or_RGB>
Image< T_or_RGB > intXY (const Image< T_or_RGB > &src, const bool dupli)
 Interpolate in X and Y (zero-pad if dupli == false, or duplicate).
template<class T_or_RGB>
Image< T_or_RGB > intX (const Image< T_or_RGB > &src, const bool dupli)
 Interpolate in X (zero-pad if dupli == false or duplicate).
template<class T_or_RGB>
Image< T_or_RGB > intY (const Image< T_or_RGB > &src, const bool dupli)
 Interpolate in Y (zero-pad if dupli == false or duplicate).
template<class T_or_RGB>
Image< T_or_RGB > zoomXY (const Image< T_or_RGB > &src, int xzoom=2, int yzoom=-1)
 Zoom up an image by duplicating pixels.
template<class T_or_RGB>
Image< T_or_RGB > rotate (const Image< T_or_RGB > &srcImg, const int x, const int y, const float ang)
 Rotate an image about (x,y) by ang(in Radians), without interpolation.
template<class T>
Image< T > zoomRational (const Image< T > &in, const uint numer, const uint denom)
 Zoom by a factor numer/denom if numer>denom, else decimate by a factor of denom/numer.


Enumeration Type Documentation

enum RescaleType
 

Different types of image rescaling functions.

Definition at line 119 of file ShapeOps.H.


Function Documentation

template<class T>
Image<T> blurAndDecY const Image< T > &  src,
const int  factor
 

Blur and then decimate in Y. Equivalent to decY(sepFilter(src)).

This is logically equivalent to constructing a boxcar filter of size factor, then doing decY(sepFilter(src, [], filter)). However, this implementation is optimized to be much faster, especially if factor is large, since we avoid computing the filter results that would just be thrown away by the subsequent decimation.

Definition at line 1390 of file ShapeOps.C.

References ASSERT, Image< T >::begin(), Image< T >::beginw(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, i, w, and ZEROS.

Referenced by Image_xx_blurAndDecY_xx_1(), and TrainingSet::load().

template<class T_or_RGB>
Image<T_or_RGB> concatArray const Image< T_or_RGB >  arr[],
const int  nbarr,
const int  Nx,
const int  destX = -1,
const int  destY = -1
 

Concatenate all image arrays, Nx arrays per line.

Also reshape each array to (destX, destY) if these are != -1.

void convertFromString const std::string str1,
RescaleType ftype
 

Convert string -> RescaleType.

Definition at line 585 of file ShapeOps.C.

References LFATAL, and toLowerCase().

std::string convertToString RescaleType  ftype  ) 
 

Convert RescaleType -> string.

Definition at line 566 of file ShapeOps.C.

References ASSERT, and LFATAL.

template<class T_or_RGB>
Image<T_or_RGB> decX const Image< T_or_RGB > &  src,
const int  factor = 2
 

Decimate in X (take one every 'factor' pixels).

template<class T_or_RGB>
Image<T_or_RGB> decXY const Image< T_or_RGB > &  src,
const int  xfactor = 2,
const int  yfactor = -1
 

Decimate in X and Y (take one every 'factor' pixels).

Parameters:
xfactor factor by which to decimate in the x direction
yfactor factor by which to decimate in the y direction; if this value is less than zero, then just take yfactor=xfactor

template<class T_or_RGB>
Image<T_or_RGB> decY const Image< T_or_RGB > &  src,
const int  factor = 2
 

Decimate in Y (take one every 'factor' pixels).

template<class T>
Image<PixRGB<T> > downscaleFancy const Image< PixRGB< T > > &  src,
int  width,
int  height,
int  weighting_slope,
bool  no_weight_black
 

downscale an image using fancy widgets like anti-aliasing, resampling

Adapted from PhotoPNMtools by Boris Van Schooten boris@13thmonkey.org

Definition at line 998 of file ShapeOps.C.

References ADD_RGB, Image< T >::beginw(), PixRGB< T >::blue(), lobot::cos(), Image< T >::getVal(), Image< T >::getWidth(), PixRGB< T >::green(), GVX_TRACE, LERROR, LINFO, out, pix, PixRGB< T >::red(), Image< T >::resize(), Image< T >::setVal(), src, and weight.

Referenced by featureClusterVision< FLOAT >::fCVgetImageComplexStats().

template<class T>
Image<T> downSize const Image< T > &  src,
const int  width,
const int  height,
const int  filterWidth = 9
 

Downsize using alternating lowpass/decimate operations.

The width used internally in the lowpass filters is given by filterWidth (default = 9).

Definition at line 1143 of file ShapeOps.C.

References ASSERT, decX(), decY(), Image< T >::getHeight(), Image< T >::getWidth(), GVX_TRACE, i, LFATAL, log(), lowPassX(), and lowPassY().

template<class T>
Image<T> downSize const Image< T > &  src,
const Dims dims,
const int  filterWidth = 9
 

Downsize using alternating lowpass/decimate operations.

The width used internally in the lowpass filters is given by filterWidth (default = 9).

Definition at line 1135 of file ShapeOps.C.

References downSize(), Dims::h(), and Dims::w().

Image<float> downSizeClean const Image< float > &  src,
const Dims new_dims,
const int  filterWidth = 9
 

Like downSize(), except image proportions don't have to match exactly.

This operation applies alternating lowpass/decimate as long as the result is larger than the desired size, and then finally does a bilinear interpolation to the final size. If the desired size is actually larger than the input size, then the image is simply upscaled with a bilinear interpolation. The advantage of using this operation over just using rescale() directly is that rescale() may introduce aliasing if an image is being downsized by several ocatves; successive lowpass/decimate operations ensure that total image energy is preserved.

RescaleType getRescaleTypeFromChar char  ftype  ) 
 

Convert a character mnemonic into a RescaleType;.

Definition at line 547 of file ShapeOps.C.

References ASSERT, and LFATAL.

template<class T_or_RGB>
Image<T_or_RGB> interpolate const Image< T_or_RGB > &  src  ) 
 

Double image size, using linear interpolation.

This function doubles the size of an image in the x and y directions. It differs from intXY() in that some interpolation will be made to create the new pixels, instead of duplication or insersion of zeros. It also differs slightly from using rescale() in the weights used for the interpolation. Specifically, we obtain:

  ORIGa  NEW1  ORIGb  ...
  NEW2   NEW3  NEW4   ...
  ORIGc  NEW5  ORIGd  ...
  ...    ...   ...    ...

  where ORIGx are the pixels from the original image, and

  NEW1 = (ORIGa + ORIGb) / 2
  NEW2 = (ORIGa + ORIGc) / 2
  NEW3 = (ORIGa + ORIGb + ORIGc + ORIGd) / 4
  NEW4 = (ORIGb + ORIGd) / 2
  NEW5 = (ORIGc + ORIGd) / 2
  

Note that for the last row and column we assume something that is half-way between a duplication and a black border.

template<class T_or_RGB>
Image<T_or_RGB> intX const Image< T_or_RGB > &  src,
const bool  dupli
 

Interpolate in X (zero-pad if dupli == false or duplicate).

template<class T_or_RGB>
Image<T_or_RGB> intXY const Image< T_or_RGB > &  src,
const bool  dupli
 

Interpolate in X and Y (zero-pad if dupli == false, or duplicate).

template<class T_or_RGB>
Image<T_or_RGB> intY const Image< T_or_RGB > &  src,
const bool  dupli
 

Interpolate in Y (zero-pad if dupli == false or duplicate).

template<class T_or_RGB>
Image<T_or_RGB> quickInterpolate const Image< T_or_RGB > &  src,
const int  sfactor
 

Dumb interpolation.

template<class T_or_RGB>
Image<T_or_RGB> quickLocalAvg const Image< T_or_RGB > &  array,
const int  scale
 

Compute quick and dirty scaling down of array.

template<class T_or_RGB>
Image<T_or_RGB> quickLocalAvg2x2 const Image< T_or_RGB > &  array  ) 
 

Compute local average of each 2x2 block and decimate by 2x2.

template<class T_or_RGB>
Image<T_or_RGB> quickLocalMax const Image< T_or_RGB > &  array,
const int  scale
 

Compute quick and dirty scaling down of array.

template<class T_or_RGB>
Image<T_or_RGB> quickLocalMin const Image< T_or_RGB > &  array,
const int  scale
 

Compute quick and dirty scaling down of array.

template<class T_or_RGB>
Image<T_or_RGB> rescale const Image< T_or_RGB > &  src,
const int  width,
const int  height,
RescaleType  ftype = RESCALE_SIMPLE_BILINEAR
 

Generic image rescaling function with runtime-selectable rescaling algorithm.

template<class T_or_RGB>
Image<T_or_RGB> rescale const Image< T_or_RGB > &  src,
const Dims newdims,
RescaleType  ftype = RESCALE_SIMPLE_BILINEAR
 

Generic image rescaling function with runtime-selectable rescaling algorithm.

template<class T_or_RGB>
Image<T_or_RGB> rescaleBilinear const Image< T_or_RGB > &  src,
int  width,
int  height
 

Scale to new width & height using bilinear interpolation.

template<class T_or_RGB>
Image<T_or_RGB> rescaleBilinear const Image< T_or_RGB > &  src,
const Dims dims
 

Scale to new width & height using bilinear interpolation.

template<class T_or_RGB>
Image<T_or_RGB> rescaleNI const Image< T_or_RGB > &  src,
int  width,
int  height
 

Scale to new width & height with no interpolation.

template<class T_or_RGB>
Image<T_or_RGB> rescaleNI const Image< T_or_RGB > &  src,
const Dims dims
 

Scale to new width & height with no interpolation.

template<class T_or_RGB>
Image<T_or_RGB> rescaleOpt const Image< T_or_RGB > &  src,
int  width,
int  height,
const bool  interp
 

Scale to new width & height.

Calls rescale() or rescaleNI() depending on value of interp

template<class T_or_RGB>
Image<T_or_RGB> rescaleOpt const Image< T_or_RGB > &  src,
const Dims dims,
const bool  interp
 

Scale to new width & height.

Calls rescale() or rescaleNI() depending on value of interp

template<class T_or_RGB>
Image<T_or_RGB> rotate const Image< T_or_RGB > &  srcImg,
const int  x,
const int  y,
const float  ang
 

Rotate an image about (x,y) by ang(in Radians), without interpolation.

template<class T>
Image<T> zoomRational const Image< T > &  in,
const uint  numer,
const uint  denom
[inline]
 

Zoom by a factor numer/denom if numer>denom, else decimate by a factor of denom/numer.

Definition at line 266 of file ShapeOps.H.

References ASSERT, decXY(), and zoomXY().

template<class T_or_RGB>
Image<T_or_RGB> zoomXY const Image< T_or_RGB > &  src,
int  xzoom = 2,
int  yzoom = -1
 

Zoom up an image by duplicating pixels.

Separate scaling factors can be given for the x and y dimensions.

Parameters:
src Input image.
xzoom Zoom factor for x dimension (default 2).
yzoom Zoom factor for y dimension. If negative (the default), then yzoom is taken to be the same as xzoom.


Generated on Sun Nov 22 13:44:12 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4