ShapeOps.H File Reference

#include "Util/Assert.H"
#include "Util/Types.H"
#include <string>
Include dependency graph for ShapeOps.H:

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.

Detailed Description

Shape operations on Image

Definition in file ShapeOps.H.


Enumeration Type Documentation

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 
) [inline]

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 1391 of file ShapeOps.C.

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

Referenced by 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 
) [inline]

Concatenate all image arrays, Nx arrays per line.

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

Referenced by main(), and makeImageArray().

void convertFromString ( const std::string str1,
RescaleType ftype 
)

Convert string -> RescaleType.

Definition at line 586 of file ShapeOps.C.

References toLowerCase().

std::string convertToString ( RescaleType  ftype  ) 

Convert RescaleType -> string.

Definition at line 567 of file ShapeOps.C.

References ASSERT.

template<class T_or_RGB >
Image<T_or_RGB> decX ( const Image< T_or_RGB > &  src,
const int  factor = 2 
) [inline]
template<class T_or_RGB >
Image<T_or_RGB> decXY ( const Image< T_or_RGB > &  src,
const int  xfactor = 2,
const int  yfactor = -1 
) [inline]

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

Referenced by VisualObject::computeKeypoints(), SimulationViewerCompress::getTraj(), infoMeasure(), main(), multiScaleBatchFilter(), reduce(), segmentImageMerge2::SIMclusterColor(), segmentImageMerge2::SIMtrackImage(), segmentImageMerge2::SIMtrackImageMulti(), segmentImageTrackMC::SITtrackImage(), segmentImageTrackMC::SITtrackImageAny(), segmentImageMerge::trackImage(), segmentImageMerge::trackImageMulti(), and zoomRational().

template<class T_or_RGB >
Image<T_or_RGB> decY ( const Image< T_or_RGB > &  src,
const int  factor = 2 
) [inline]
template<class T >
Image<PixRGB<T> > downscaleFancy ( const Image< PixRGB< T > > &  src,
int  width,
int  height,
int  weighting_slope,
bool  no_weight_black 
) [inline]

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

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

Definition at line 999 of file ShapeOps.C.

References Image< T >::beginw(), PixRGB< T >::blue(), Image< T >::getHeight(), Image< T >::getVal(), Image< T >::getWidth(), PixRGB< T >::green(), pix, PixRGB< T >::red(), Image< T >::resize(), and Image< T >::setVal().

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 
) [inline]

Downsize using alternating lowpass/decimate operations.

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

Definition at line 1144 of file ShapeOps.C.

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

template<class T >
Image<T> downSize ( const Image< T > &  src,
const Dims dims,
const int  filterWidth = 9 
) [inline]
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.

Definition at line 1171 of file ShapeOps.C.

References ASSERT, decX(), decY(), Image< T >::getDims(), Image< T >::getHeight(), Image< T >::getWidth(), Dims::h(), Dims::isNonEmpty(), lowPassX(), lowPassY(), quickLocalAvg2x2(), and Dims::w().

Referenced by RawVisualCortex::combineOutputs().

RescaleType getRescaleTypeFromChar ( char  ftype  ) 

Convert a character mnemonic into a RescaleType;.

Definition at line 548 of file ShapeOps.C.

References ASSERT.

template<class T_or_RGB >
Image<T_or_RGB> interpolate ( const Image< T_or_RGB > &  src  )  [inline]

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.

Referenced by VisualObject::computeKeypoints().

template<class T_or_RGB >
Image<T_or_RGB> intX ( const Image< T_or_RGB > &  src,
const bool  dupli 
) [inline]

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 
) [inline]

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

Referenced by buildPyrRetinexLog().

template<class T_or_RGB >
Image<T_or_RGB> intY ( const Image< T_or_RGB > &  src,
const bool  dupli 
) [inline]

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 
) [inline]
template<class T_or_RGB >
Image<T_or_RGB> quickLocalAvg ( const Image< T_or_RGB > &  array,
const int  scale 
) [inline]

Compute quick and dirty scaling down of array.

template<class T_or_RGB >
Image<T_or_RGB> quickLocalAvg2x2 ( const Image< T_or_RGB > &  array  )  [inline]

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

Referenced by downSizeClean(), and SpectralResidualChannel::getOutput().

template<class T_or_RGB >
Image<T_or_RGB> quickLocalMax ( const Image< T_or_RGB > &  array,
const int  scale 
) [inline]

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 
) [inline]

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 
) [inline]

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 
) [inline]

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 
) [inline]

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 
) [inline]

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 
) [inline]

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 
) [inline]

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 
) [inline]

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 
) [inline]

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 
) [inline]

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

Referenced by VectorField::rotateField().

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 
) [inline]

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.

Referenced by makeImageArray(), submain(), and zoomRational().

Generated on Sun May 8 08:42:42 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3