#include "Image/ShapeOps.H"
#include "Image/CutPaste.H"
#include "Image/FilterOps.H"
#include "Image/Image.H"
#include "Image/Pixels.H"
#include "Image/vec2.h"
#include "Util/Assert.H"
#include "Util/StringUtil.H"
#include "Util/log.H"
#include "Util/safecopy.H"
#include "rutz/trace.h"
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include "inst/Image/ShapeOps.I"
Go to the source code of this file.
Defines | |
#define | ADD_RGB(buf, Weight, bWeight, in) |
#define | RGB_BILINEAR_INTERP(EL) |
#define | B (1.0 / 3.0) |
#define | C (1.0 / 3.0) |
Functions | |
template<class T > | |
Image< T > | quickLocalAvg (const Image< T > &array, const int scale) |
template<class T > | |
Image< T > | quickLocalAvg2x2 (const Image< T > &src) |
template<class T > | |
Image< T > | quickLocalMax (const Image< T > &array, const int scale) |
template<class T > | |
Image< T > | quickLocalMin (const Image< T > &array, const int scale) |
template<class T > | |
Image< T > | quickInterpolate (const Image< T > &src, const int sfactor) |
template<class T > | |
Image< T > | interpolate (const Image< T > &src) |
template<class T > | |
Image< T > | rescaleBilinear (const Image< T > &src, const Dims &dims) |
template<class T > | |
Image< T > | rescaleBilinear (const Image< T > &src, const int new_w, const int new_h) |
template<> | |
Image< PixRGB< byte > > | rescaleBilinear (const Image< PixRGB< byte > > &src, const int new_w, const int new_h) |
template<class T > | |
Image< T > | rescaleNI (const Image< T > &src, const Dims &dims) |
template<class T > | |
Image< T > | rescaleNI (const Image< T > &src, const int new_w, const int new_h) |
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 > | |
Image< T > | rescale (const Image< T > &src, const Dims &newdims, RescaleType ftype) |
template<class T > | |
Image< T > | rescale (const Image< T > &src, const int width, const int height, RescaleType ftype) |
template<class T > | |
Image< T > | rescaleOpt (const Image< T > &src, const Dims &dims, const bool interp) |
template<class T > | |
Image< T > | rescaleOpt (const Image< T > &src, const int new_w, const int new_h, const bool interp) |
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) |
Downsize using alternating lowpass/decimate operations. | |
template<class T > | |
Image< T > | downSize (const Image< T > &src, const int new_w, const int new_h, const int filterWidth) |
Downsize using alternating lowpass/decimate operations. | |
Image< float > | downSizeClean (const Image< float > &src, const Dims &new_dims, const int filterWidth) |
Like downSize(), except image proportions don't have to match exactly. | |
template<class T > | |
Image< T > | concatArray (const Image< T > arr[], const int nbarr, const int Nx, const int destX, const int destY) |
template<class T > | |
Image< T > | decXY (const Image< T > &src, const int xfactor, const int yfactor_raw) |
template<class T > | |
Image< T > | decX (const Image< T > &src, const int factor) |
template<class T > | |
Image< T > | decY (const Image< T > &src, const int factor) |
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 > | |
Image< T > | intXY (const Image< T > &src, const bool dupli) |
template<class T > | |
Image< T > | intX (const Image< T > &src, const bool dupli) |
template<class T > | |
Image< T > | intY (const Image< T > &src, const bool dupli) |
template<class T > | |
Image< T > | zoomXY (const Image< T > &src, int xzoom, int yzoom) |
template<class T > | |
Image< T > | rotate (const Image< T > &srcImg, const int x, const int y, const float ang) |
template Image< double > | quickLocalAvg2x2 (const Image< double > &) |
template Image< int > | decX (const Image< int > &, int) |
template Image< int > | decY (const Image< int > &, int) |
template Image< int > | decXY (const Image< int > &, int, int) |
template Image< double > | intXY (const Image< double > &, bool) |
template Image< PixH2SV2< float > > | decXY (const Image< PixH2SV2< float > > &, int, int) |
template Image< PixH2SV2< float > > | rescaleBilinear (const Image< PixH2SV2< float > > &src, int, int) |
template Image< geom::vec2f > | rotate (const Image< geom::vec2f > &, int, int, float) |
template Image< uint16 > | zoomXY (const Image< uint16 > &, int, int) |
template Image< uint16 > | rescale (const Image< uint16 > &, const Dims &, RescaleType) |
Shape operations on Image
Definition in file ShapeOps.C.
#define ADD_RGB | ( | buf, | |||
Weight, | |||||
bWeight, | |||||
in | ) |
do { \ *buf += *in * (Weight); \ *bWeight += Weight; } while (0);
Definition at line 64 of file ShapeOps.C.
#define RGB_BILINEAR_INTERP | ( | EL | ) |
do { \ const float \ d00( sptr[x0 + wy0].p[EL] ), d10( sptr[x1 + wy0].p[EL] ), \ d01( sptr[x0 + wy1].p[EL] ), d11( sptr[x1 + wy1].p[EL] ); \ \ const float \ dx0( d00 + (d10 - d00) * fx ), \ dx1( d01 + (d11 - d01) * fx ); \ \ dptr->p[EL] = byte( dx0 + (dx1 - dx0) * fy ); \ } while(0)
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().
void convertFromString | ( | const std::string & | str1, | |
RescaleType & | ftype | |||
) |
std::string convertToString | ( | RescaleType | ftype | ) |
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().
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().
Image<T> downSize | ( | const Image< T > & | src, | |
const Dims & | dims, | |||
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 1136 of file ShapeOps.C.
References downSize(), Dims::h(), and Dims::w().
Referenced by DescriptorVec::buildRawDV(), SubmapAlgorithmBiased::compute(), SaliencyMT::computeCMAP(), BeoSubSaliency::computeCMAP(), computeCMAP(), downSize(), DirectionSpatioTemporalChannel::getRawCSmap(), GetSaliency::getSubMaps(), TaskRelevanceMapKillStatic::inputFrame(), TaskRelevanceMapKillN::integrate(), maxNormalizeFancy(), normalizMAP(), and SingleChannel::postProcessMap().
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.