Basic Image AlgorithmS Library
2.8.0
|
Down-, Upsampling routines and Resize. More...
#include <Filter/Rescale.hh>
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 |
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.
Definition at line 71 of file Rescale.hh.
|
inherited |
enum for border calculation, same meanings as in matlab:
Enumerator | |
---|---|
TBH_full | |
TBH_same | |
TBH_valid |
Definition at line 98 of file FilterBase.hh.
BIAS::Rescale< InputImageType, OutputImageType >::Rescale | ( | ) |
Definition at line 45 of file Rescale.cpp.
References BIAS::Rescale< InputStorageType, OutputStorageType >::_LastPositionOffset, BIAS::Rescale< InputStorageType, OutputStorageType >::_lowpass, BIAS::Rescale< InputStorageType, OutputStorageType >::_RescaleFactor, BIAS::Rescale< InputStorageType, OutputStorageType >::_RescaleMeanSigmaFactor, and BIAS::Mean< InputStorageType, OutputStorageType >::GetSize().
BIAS::Rescale< InputImageType, OutputImageType >::Rescale | ( | const Rescale< InputImageType, OutputImageType > & | other | ) |
Definition at line 59 of file Rescale.cpp.
|
virtual |
Definition at line 82 of file Rescale.cpp.
|
protected |
updates _mean using _RescaleMeanType and calls _mean->Filter(src, dst)
Definition at line 2089 of file Rescale.cpp.
|
protected |
Definition at line 2335 of file Rescale.cpp.
References BIAS::Image< StorageType >::BilinearInterpolationRGBInterleaved(), BIAS::ImageBase::GetChannelCount(), BIAS::ROI::GetCorners(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::IsEmpty(), and BIAS::ImageBase::IsInterleaved().
|
protected |
Same as _FillInterpolatedGrey but for multi channel interleaved images.
Definition at line 2213 of file Rescale.cpp.
References BIAS::Image< StorageType >::BilinearInterpolationRGBInterleaved(), BIAS::ImageBase::GetChannelCount(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), BIAS::ImageBase::IsEmpty(), and BIAS::ImageBase::IsInterleaved().
|
protected |
Definition at line 2248 of file Rescale.cpp.
References BIAS::Image< StorageType >::BilinearInterpolationRGBInterleaved(), BIAS::ImageBase::GetChannelCount(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), BIAS::ImageBase::IsEmpty(), and BIAS::ImageBase::IsInterleaved().
|
protected |
Definition at line 2286 of file Rescale.cpp.
References BIAS::Image< StorageType >::BilinearInterpolationRGBInterleaved(), BIAS::ImageBase::GetChannelCount(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), BIAS::ImageBase::IsEmpty(), and BIAS::ImageBase::IsInterleaved().
|
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
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().
|
protected |
Definition at line 2147 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().
|
protected |
Definition at line 2181 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().
|
inlineinherited |
Definition at line 355 of file Debug.hh.
Referenced by BIAS::GLProjectionParametersBase::AddDebugLevel(), BIAS::Triangulation::CorrectCorrespondences(), BIAS::FilterBase< InputStorageType, OutputStorageType >::FilterBase(), BIAS::ShowCamWxVideoSourceFactory::OpenDevice(), and BIAS::SceneOpenSceneGraph::SceneOpenSceneGraph().
|
inlineinherited |
|
inlineprotectedinherited |
|
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.
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.
|
inlineinherited |
Definition at line 341 of file Debug.hh.
Referenced by BIAS::GenSynthMatches::_AddUniformDistributedOutliers(), BIAS::GenSynthMatches::_CreateCamMovement(), BIAS::GenSynthMatches::_CreateStatic2DPoints(), BIAS::UnscentedTransform::ComputeSigmaPoints_(), BIAS::Triangulation::CorrectCorrespondences(), BIAS::GenSynthMatches::GetGTNormalizedF(), BIAS::MonteCarloTransform::GetSamples_(), and BIAS::MonteCarloTransform::Transform().
|
inlineinherited |
int BIAS::Rescale< InputImageType, OutputImageType >::Downsample | ( | const Image< InputImageType > & | src, |
Image< OutputImageType > & | dst | ||
) |
generic downsample function.
Definition at line 111 of file Rescale.cpp.
References BIAS::ImageBase::GetChannelCount(), 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::VideoSink_FFmpeg::AddFrame(), BIAS::FitCircleFrame::OnRescaleImage(), BIAS::ExampleMixtureOfGaussiansFrame::OnTimer(), and BIAS::ShowCamWxFrame::SelectAndShowCameraImage_().
int BIAS::Rescale< InputImageType, OutputImageType >::Downsample | ( | const Image< InputImageType > & | src, |
Image< OutputImageType > & | dst, | ||
const unsigned | newwidth, | ||
const unsigned | newheight | ||
) |
downsamples src to dst of size newwidth x newheight
Definition at line 181 of file Rescale.cpp.
References BIAS::ImageBase::CM_Grey, BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetColorModel(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetROI(), BIAS::Mean< InputStorageType, OutputStorageType >::GetSize(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::IsInterleaved(), BIAS::Image< StorageType >::Release(), and BIAS::ROI::SetCorners().
int BIAS::Rescale< InputImageType, OutputImageType >::Downsample | ( | const Image< InputImageType > & | src, |
Image< OutputImageType > & | dst, | ||
const double | factor | ||
) |
Definition at line 148 of file Rescale.cpp.
References BIAS::ImageBase::GetChannelCount(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), BIAS::ImageBase::IsInterleaved(), and BIAS::ROI::SetCorners().
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.
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().
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.
Source | Image with a defined ROI |
Destination | Image where the rescaled image will be stored. Will initialized if required. |
newwidth | Desired width of the target image |
newheight | Desired height of the target image |
(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.
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().
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
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().
int BIAS::Rescale< unsigned char, unsigned char >::DownsampleBy2Color | ( | const Image< unsigned char > & | Source, |
Image< unsigned char > & | Destination | ||
) |
Definition at line 603 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().
int BIAS::Rescale< unsigned short, unsigned short >::DownsampleBy2Color | ( | const Image< unsigned short > & | Source, |
Image< unsigned short > & | Destination | ||
) |
Definition at line 677 of file Rescale.cpp.
References BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetPixelCount(), BIAS::ImageBase::GetROI(), and BIAS::ImageBase::GetWidth().
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.
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().
int BIAS::Rescale< unsigned char, unsigned char >::DownsampleBy2Grey | ( | const Image< unsigned char > & | Source, |
Image< unsigned char > & | Destination | ||
) |
Definition at line 414 of file Rescale.cpp.
References BIAS::ROI::GetCorners(), BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), and BIAS::ROI::SetCorners().
int BIAS::Rescale< unsigned short, unsigned short >::DownsampleBy2Grey | ( | const Image< unsigned short > & | Source, |
Image< unsigned short > & | Destination | ||
) |
Definition at line 476 of file Rescale.cpp.
References BIAS::ROI::GetCorners(), BIAS::Image< StorageType >::GetImageData(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), and BIAS::ROI::SetCorners().
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.
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().
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 :-)) )
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().
int BIAS::Rescale< unsigned char, unsigned char >::DownsampleBy4Grey | ( | const Image< unsigned char > & | Source, |
Image< unsigned char > & | Destination | ||
) |
Definition at line 871 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().
int BIAS::Rescale< unsigned short, unsigned short >::DownsampleBy4Grey | ( | const Image< unsigned short > & | Source, |
Image< unsigned short > & | Destination | ||
) |
Definition at line 961 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().
|
virtual |
scales the src to dst using the downsampling factor from SetFactor()
Definition at line 89 of file Rescale.cpp.
Referenced by BIAS::CylindricDepthTrackingPanorama::GetTriangleMesh(), BIAS::SphericalDepthPanorama::GetTriangleMesh(), BIAS::CylindricDepthPanorama::GetTriangleMesh(), and BIAS::CannyEdge< InputStorageType, OutputStorageType >::SmoothImage_().
|
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 >.
|
inlineinherited |
Definition at line 129 of file FilterBase.hh.
|
inherited |
Definition at line 61 of file FilterBase.cpp.
Referenced by BIAS::Rescale< InputStorageType, OutputStorageType >::GetBordersValid_().
|
protectedvirtual |
Implements BIAS::FilterBase< InputStorageType, OutputStorageType >.
Definition at line 2323 of file Rescale.cpp.
References BIAS::FilterBase< InputStorageType, OutputStorageType >::GetBorders().
|
inlineinherited |
Definition at line 332 of file Debug.hh.
Referenced by BIAS::listenthread(), BIAS::Image< StorageType >::operator=(), and BIAS::ImageBase::operator=().
|
inlineinherited |
|
inlineinherited |
|
inline |
Definition at line 363 of file Rescale.hh.
|
inlinestaticinherited |
|
inline |
Definition at line 374 of file Rescale.hh.
|
inline |
see DownsampleBy2 for explanation
Definition at line 372 of file Rescale.hh.
|
inlineinherited |
|
inlineinherited |
creates a new debuglevel
Definition at line 474 of file Debug.hh.
Referenced by BIAS::COSAC< SolutionType >::COSAC(), BIAS::ProjectionParametersPerspectiveDepth::Init(), BIAS::MonteCarloTransform::MonteCarloTransform(), BIAS::PMatrixEstimation::PMatrixEstimation(), BIAS::PreemptiveRANSAC< SolutionType >::PreemptiveRANSAC(), BIAS::RANSACPreKnowledge< SolutionType >::RANSACPreKnowledge(), BIAS::ROI::ROI(), BIAS::RotationAveraging::RotationAveraging(), BIAS::SceneOpenSceneGraph::SceneOpenSceneGraph(), BIAS::ThreeDOutOpenSceneGraph::ThreeDOutOpenSceneGraph(), BIAS::Triangulation::Triangulation(), and BIAS::UnscentedTransform::UnscentedTransform().
Rescale< InputStorageType, OutputStorageType > & BIAS::Rescale< InputStorageType, OutputStorageType >::operator= | ( | const Rescale< InputStorageType, OutputStorageType > & | other | ) |
Definition at line 68 of file Rescale.cpp.
References BIAS::Rescale< InputStorageType, OutputStorageType >::_LastPositionOffset, BIAS::Rescale< InputStorageType, OutputStorageType >::_lowpass, BIAS::Rescale< InputStorageType, OutputStorageType >::_RescaleFactor, and BIAS::Rescale< InputStorageType, OutputStorageType >::_RescaleMeanSigmaFactor.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Definition at line 127 of file FilterBase.hh.
Referenced by BIAS::PMDImageProc::DenoiseDepthImage(), BIAS::CalibratedPyramid< StorageType >::Downsample_(), BIAS::PMDImageProc::FitDepthTo2DImage(), and BIAS::PMDImageProc::FitDepthTo2DImageFree_().
|
inlineinherited |
Definition at line 318 of file Debug.hh.
Referenced by BIAS::ShowCamWxVideoSourceFactory::CreateBumbleBee(), BIAS::ShowCamWxVideoSourceFactory::CreateDCAM(), BIAS::VideoSource_MDcam::ScanBus(), BIAS::GLProjectionParametersBase::SetDebugLevel(), BIAS::VideoSource_Disk::VideoSource_Disk(), BIAS::VideoSource_DV2::VideoSource_DV2(), BIAS::VideoSource_DV::VideoSource_DV_Internal_Init_(), and BIAS::VideoSource_V4L::VideoSource_V4L().
|
inlineinherited |
|
inlineinherited |
|
inline |
the downsampling factor
Definition at line 361 of file Rescale.hh.
Referenced by BIAS::CylindricDepthTrackingPanorama::GetTriangleMesh(), BIAS::SphericalDepthPanorama::GetTriangleMesh(), BIAS::CylindricDepthPanorama::GetTriangleMesh(), and BIAS::CannyEdge< InputStorageType, OutputStorageType >::SmoothImage_().
|
inlinestaticinherited |
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().
void BIAS::Rescale< InputImageType, OutputImageType >::SetLowPassType | ( | int | lpt | ) |
Sets the lowpass filter by a lowpass filter type.
Definition at line 2060 of file Rescale.cpp.
References BIAS::LPT_Binomial, BIAS::LPT_Gauss, BIAS::LPT_GaussThreshold, and BIAS::LPT_Mean.
Referenced by BIAS::FitCircleFrame::FitCircleFrame(), BIAS::CylindricDepthTrackingPanorama::GetTriangleMesh(), BIAS::SphericalDepthPanorama::GetTriangleMesh(), and BIAS::CylindricDepthPanorama::GetTriangleMesh().
|
inherited |
run over all pixel which do not belong to the roi and set them to some value (typically black)
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.
|
inlineinherited |
void BIAS::Rescale< InputImageType, OutputImageType >::UpdateLowpass | ( | double | factor | ) |
updates _lowpass using _RescaleMeanType
Definition at line 2024 of file Rescale.cpp.
References BIAS::Binomial< InputStorageType, OutputStorageType >::SetHalfWinSize(), BIAS::Gauss< InputStorageType, OutputStorageType >::SetSigma(), and BIAS::Mean< InputStorageType, OutputStorageType >::SetSize().
int BIAS::Rescale< InputImageType, OutputImageType >::Upsample | ( | const Image< InputImageType > & | src, |
Image< OutputImageType > & | dst | ||
) |
generic upsample function
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().
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.
exactfactor | this 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. |
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().
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
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().
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()
InterpolationType | which interpolation to use for off-grid pixel |
valmin/valmax | if bicubic, limit range to these values only for one channel images |
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.
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()
InterpolationType | which interpolation to use for off-grid pixel |
valmin/valmax | if bicubic, limit range to these values only for three channel images |
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.
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.
src | [in], source image |
dst | [out], destination image |
newwidth | [in], new image width after upsample |
newheight | [in], new image height after upsample |
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().
|
protectedinherited |
Definition at line 132 of file FilterBase.hh.
Referenced by BIAS::FilterBase< InputStorageType, OutputStorageType >::FilterBase().
|
protected |
see DownsampleBy2 for explanation
Definition at line 388 of file Rescale.hh.
Referenced by BIAS::Rescale< InputStorageType, OutputStorageType >::operator=(), and BIAS::Rescale< InputStorageType, OutputStorageType >::Rescale().
|
protectedinherited |
Definition at line 510 of file Debug.hh.
Referenced by BIAS::Debug::operator=(), and BIAS::ImageBase::operator=().
|
protectedinherited |
new concept, debuglevel are managed here in the debug class
Definition at line 516 of file Debug.hh.
Referenced by BIAS::Debug::operator=().
|
protected |
Definition at line 379 of file Rescale.hh.
Referenced by BIAS::Rescale< InputStorageType, OutputStorageType >::operator=(), and BIAS::Rescale< InputStorageType, OutputStorageType >::Rescale().
|
protected |
Definition at line 384 of file Rescale.hh.
Referenced by BIAS::Rescale< InputStorageType, OutputStorageType >::operator=(), and BIAS::Rescale< InputStorageType, OutputStorageType >::Rescale().
|
protected |
Definition at line 385 of file Rescale.hh.
Referenced by BIAS::Rescale< InputStorageType, OutputStorageType >::operator=(), and BIAS::Rescale< InputStorageType, OutputStorageType >::Rescale().
|
protectedinherited |
Definition at line 517 of file Debug.hh.
Referenced by BIAS::Debug::operator=().
|
staticprotectedinherited |
Definition at line 511 of file Debug.hh.
Referenced by BIAS::Debug::operator=().
|
staticprotectedinherited |