Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BIAS::ImageBlenderIncremental Class Reference

maps several images into a common mosaic and blends them seamlessly More...

#include <Image/ImageBlenderIncremental.hh>

+ Inheritance diagram for BIAS::ImageBlenderIncremental:
+ Collaboration diagram for BIAS::ImageBlenderIncremental:

Public Member Functions

int AddCamera (const BIAS::Camera< unsigned char > &camera, unsigned int weightType=WEIGHT_TYPE_CIRCULAR_FIT)
 In incremental mode, the mosaic is updated using the image and the contained projection, in batch mode the image is simply added to the database and must contain a valid projection and a valid UUID. More...
 
void AddDebugLevel (const long int lv)
 
void AddDebugLevel (const std::string &name)
 
bool BlendImages (BIAS::Camera< unsigned char > &destination, double gaussSigma=1.2)
 compute cylindrical geometry from added images and blend all added images More...
 
bool BlendImages (BIAS::Camera< unsigned char > &destination, const ProjectionParametersBase &ppOut, const BIAS::Image< float > *depthmap=NULL, double gaussSigma=1.2)
 Blends all added images into destination with ppOut projection. More...
 
bool DebugLevelIsSet (const long int lv) const
 
bool DebugLevelIsSet (const std::string &name) const
 
int GetDebugLevel () const
 
std::ostream & GetDebugStream () const
 
void GetDebugStream (std::ostream &os) const
 
const Image< float > * GetLowPassPointer ()
 for interadctive visualization, show current buffer (read only) More...
 
void GetMosaicRGB (Image< unsigned char > &mosaic)
 returns (current) mosaic image in incremental mode More...
 
void GetMosaicRGB (Image< float > &mosaic)
 returns (current) mosaic image in incremental mode More...
 
void GetMosaicRGBA (Image< unsigned char > &mosaic)
 returns (current) mosaic image in incremental mode More...
 
void GetMosaicRGBA (Image< float > &mosaic)
 returns (current) mosaic image in incremental mode More...
 
unsigned int GetOuputImageSize ()
 
 ImageBlenderIncremental (bool blendIncremental=false)
 constructor 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...
 
void PrintDebugLevel (std::ostream &os=std::cout) const
 
void RemoveDebugLevel (const long int lv)
 
void RemoveDebugLevel (const std::string &name)
 
void SetDebugLevel (const long int lv)
 
void SetDebugLevel (const std::string &name)
 
void SetDebugStream (const std::ostream &os)
 
void SetDepthMap (const BIAS::Image< float > &depthmap)
 
void SetDrawImageBorders (bool flag)
 
void SetHorizonAlignment (unsigned int val)
 determines the alignment of the horizon possible values are: HORIZON_ALIGNMENT_X - horizon is in x direction (default value) HORIZON_ALIGNMENT_X - horizon is in y direction HORIZON_ALIGNMENT_UNKNOWN - horizon alignment is unknown or mixed More...
 
void SetOuputImageSize (const unsigned int &newSize)
 
void SetOutputParameters (const BIAS::ProjectionParametersBase &imagegeometry, const BIAS::RGBAuc bgcolor=RGBAuc(0, 0, 0, 0))
 resets internal mosaic More...
 
void SetPlane (const HomgPlane3D &theplane)
 
void SetUserWeightImage (const BIAS::Image< float > &weights)
 set a weight image (e.g. More...
 
void SetWriteVrml (bool flag)
 
void ShowDebugLevel (std::ostream &os=std::cout) const
 prints all internally known debuglevels More...
 

Static Public Member Functions

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

Protected Member Functions

void AddLowPassAndHighPassImage_ (Image< float > &destLow, Image< float > &destHigh, Image< unsigned char > &destination)
 helper function for extracting mosaic from laplacian pyramid More...
 
void AddLowPassAndHighPassImage_ (Image< float > &destLow, Image< float > &destHigh, Image< float > &destination)
 helper function for extracting mosaic from laplacian pyramid More...
 
double CalcAngleToXAxis_ (const BIAS::Vector2< double > &v, bool wantDegrees=false)
 
double CalcAngleToYAxis_ (const BIAS::Vector2< double > &v, bool wantDegrees=false)
 
void CheckFov_ (BIAS::ProjectionParametersCylindric &ppc)
 Checks FOV of each cam and computes the cylinder's FOV If mapper tries to access pixel outside of image, nasty distortion effects occur. More...
 
void ComputeAlphaChannelWeight_ (BIAS::Image< float > &image, unsigned int weightType=WEIGHT_TYPE_RECTANGULAR)
 adds an alpha channel to RGB image, alpha can be e.g. More...
 
void ComputeCylCamGeometry_ (BIAS::ProjectionParametersCylindric &ppc)
 
long ConsumeNextFreeDebuglevel_ ()
 returns the next available debuglevel More...
 
void ConvertImageToRGBA_ (BIAS::Image< float > &image)
 
void CopyAlphaChannel_ (const Image< float > &camCyl, Image< float > &lowPassCam)
 copies alpha channel from first RGBA image into second More...
 
void FillBGImage_ (Image< float > &BGImage, const RGBAuc &color)
 helper for filling an image with rgba data More...
 
void GetLowPassAndHighPassImage_ (const Image< float > &camCyl, Image< float > &lowPassCam, Image< float > &highPassCam)
 helper function for simple laplacian pyramid More...
 
void LowPassFusiondAndHighPassMax_ (Image< float > &destLow, Image< float > &destHigh, Image< float > &lowPassCam, Image< float > &highPassCam)
 helper function for incremental fusion More...
 

Protected Attributes

long int _liDebugLevel
 
long int _liNextDebugLevel
 new concept, debuglevel are managed here in the debug class More...
 
std::map< std::string, long int > _String2Debuglevel
 
bool blendIncremental_
 incremental or batchmode More...
 
double cylinderHeight_
 
BIAS::Image< float > Depth_
 output depth More...
 
bool drawImageBorders_
 
BIAS::Gauss< float, float > gaussFilter_
 
unsigned int horizonAlignment_
 
std::vector< BIAS::UUIDimageIDs_
 
std::map< BIAS::UUID,
BIAS::Camera< float > > 
inputImages_
 
BIAS::Image< float > latestMosaicHigh_
 output image in incremental mode More...
 
BIAS::Image< float > latestMosaicLow_
 
unsigned int outputImageHeight_
 
unsigned int outputImageWidth_
 
BIAS::HomgPlane3D plane_
 plane (alternative to depth) More...
 
BIAS::ProjectionMapping< float,
float > 
pm_
 the actual worker: More...
 
BIAS::ProjectionParametersBaseppOutput_
 output projection More...
 
BIAS::Image< float > weightimage_
 weight image for user specified weighting More...
 
bool writeVrml_
 

Static Protected Attributes

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

Detailed Description

maps several images into a common mosaic and blends them seamlessly

Blends a bunch of images seamlessly either in incremental or batch mode (in any case 64 byte RAM per output pixel are required, plus some constant, i.e. for a 10000x10000 pano you will need 6.4GB RAM). If you dont have enough RAM, tile your output image and run multiple times.

General usage of this class: First, specify the output parameters. For a rectilinear panorama this is a simple ProjectionParametersPerspective with wide field of view or for cylindrical panorama use BIAS::ProjectionParametersCylindric. However, you can also blend multiple textures for surfaces by providing the depth map of the output image.

When you specify the output parameters by SetOutputParameters(), a compatible output image will be generated internally. Then, for each input image (the photos you want to stitch), call Blend(image). Internally, the output image will be updated (a Kalman filter on the low frequency intensity plus the most reliable (winner-takes-all) laplacian of all images). Finally, call GetImage to obtain the resulting image.

Originally this class was written for panoramic image stitiching and computes a cylindrical geometry automatically from the different images. However, you can specify any projection you want as an output. In case your input images do not have the same camera center as your output image and you want this to be considered, you have to provide an output depth map, which can be used for the mapping in 3D.

Blending is done by separating the image into high-pass and low-pass parts, where each part is blended over one wavelength, i.e. sharp edges are blended within 2 pixels, while the image mean is blended over the whole image size.

Author
Robert Wulff, kkoeser
Date
07/2007, 06/2014

Definition at line 80 of file ImageBlenderIncremental.hh.

Constructor & Destructor Documentation

ImageBlenderIncremental::ImageBlenderIncremental ( bool  blendIncremental = false)

constructor

Parameters
blendIncrementalset to true if you want to blend each added camera right away, rather than in (traditional) batch mode
Author
Robert Wulff
Date
07/2007

Definition at line 19 of file ImageBlenderIncremental.cpp.

Member Function Documentation

int ImageBlenderIncremental::AddCamera ( const BIAS::Camera< unsigned char > &  camera,
unsigned int  weightType = WEIGHT_TYPE_CIRCULAR_FIT 
)

In incremental mode, the mosaic is updated using the image and the contained projection, in batch mode the image is simply added to the database and must contain a valid projection and a valid UUID.

Returns
0 = OK, -1 = error

Definition at line 122 of file ImageBlenderIncremental.cpp.

References BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::Camera< StorageType >::GetProj(), BIAS::ImageBase::GetUID(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), BIAS::Camera< StorageType >::IsProjValid(), BIAS::UUID::IsValid(), and BIAS::Camera< StorageType >::SetProj().

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.

void ImageBlenderIncremental::AddLowPassAndHighPassImage_ ( Image< float > &  destLow,
Image< float > &  destHigh,
Image< unsigned char > &  destination 
)
protected

helper function for extracting mosaic from laplacian pyramid

Definition at line 408 of file ImageBlenderIncremental.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), and BIAS::ImageBase::GetWidth().

void ImageBlenderIncremental::AddLowPassAndHighPassImage_ ( Image< float > &  destLow,
Image< float > &  destHigh,
Image< float > &  destination 
)
protected

helper function for extracting mosaic from laplacian pyramid

Definition at line 486 of file ImageBlenderIncremental.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), and BIAS::ImageBase::GetWidth().

bool BIAS::ImageBlenderIncremental::BlendImages ( BIAS::Camera< unsigned char > &  destination,
double  gaussSigma = 1.2 
)
inline

compute cylindrical geometry from added images and blend all added images

This function is only available in batch mode. wrapper function only, calls other BlendImages

Parameters
destinationresult image
Returns
true iff blending succeeded or false otherwise
Author
Robert Wulff
Date
07/2007

Definition at line 146 of file ImageBlenderIncremental.hh.

bool ImageBlenderIncremental::BlendImages ( BIAS::Camera< unsigned char > &  destination,
const ProjectionParametersBase ppOut,
const BIAS::Image< float > *  depthmap = NULL,
double  gaussSigma = 1.2 
)
double ImageBlenderIncremental::CalcAngleToXAxis_ ( const BIAS::Vector2< double > &  v,
bool  wantDegrees = false 
)
inlineprotected
double ImageBlenderIncremental::CalcAngleToYAxis_ ( const BIAS::Vector2< double > &  v,
bool  wantDegrees = false 
)
inlineprotected
void ImageBlenderIncremental::CheckFov_ ( BIAS::ProjectionParametersCylindric ppc)
inlineprotected

Checks FOV of each cam and computes the cylinder's FOV If mapper tries to access pixel outside of image, nasty distortion effects occur.

This method checks the FOV of each cam and blocks access to pixels that are out of scope.

Author
Robert Wulff
Date
11/07

Definition at line 1168 of file ImageBlenderIncremental.cpp.

References BIAS::ProjectionParametersBase::DoesPointProjectIntoImage(), BIAS::Equal(), BIAS::ProjectionParametersBase::GetFirstBorderPixel(), BIAS::ProjectionParametersBase::GetNextBorderPixel(), BIAS::Projection::GetParameters(), BIAS::Vector3< T >::NormL2(), BIAS::ProjectionParametersPerspective::SetMinZLocal(), BIAS::ProjectionParametersPerspective::UnProjectLocal(), BIAS::ProjectionParametersBase::UnProjectToRay(), BIAS::PixelIterator::x, and BIAS::PixelIterator::y.

void ImageBlenderIncremental::ComputeAlphaChannelWeight_ ( BIAS::Image< float > &  image,
unsigned int  weightType = WEIGHT_TYPE_RECTANGULAR 
)
protected

adds an alpha channel to RGB image, alpha can be e.g.

radial symmetric from image center

Definition at line 1349 of file ImageBlenderIncremental.cpp.

References BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), BIAS::Image< StorageType >::GetImageDataArray(), and BIAS::ImageBase::GetWidth().

void ImageBlenderIncremental::ComputeCylCamGeometry_ ( BIAS::ProjectionParametersCylindric ppc)
protected
long BIAS::Debug::ConsumeNextFreeDebuglevel_ ( )
inlineprotectedinherited

returns the next available debuglevel

Author
woelk 09/2006

Definition at line 521 of file Debug.hh.

void ImageBlenderIncremental::ConvertImageToRGBA_ ( BIAS::Image< float > &  image)
protected
void ImageBlenderIncremental::CopyAlphaChannel_ ( const Image< float > &  camCyl,
Image< float > &  lowPassCam 
)
protected

copies alpha channel from first RGBA image into second

Definition at line 281 of file ImageBlenderIncremental.cpp.

References BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), and BIAS::ImageBase::GetWidth().

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.

void ImageBlenderIncremental::FillBGImage_ ( Image< float > &  BGImage,
const RGBAuc color 
)
protected

helper for filling an image with rgba data

Definition at line 87 of file ImageBlenderIncremental.cpp.

References BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), and BIAS::ImageBase::GetWidth().

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.

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

Definition at line 431 of file Debug.hh.

void ImageBlenderIncremental::GetLowPassAndHighPassImage_ ( const Image< float > &  camCyl,
Image< float > &  lowPassCam,
Image< float > &  highPassCam 
)
protected
const Image<float>* BIAS::ImageBlenderIncremental::GetLowPassPointer ( )
inline

for interadctive visualization, show current buffer (read only)

Definition at line 131 of file ImageBlenderIncremental.hh.

void ImageBlenderIncremental::GetMosaicRGB ( Image< unsigned char > &  mosaic)
void ImageBlenderIncremental::GetMosaicRGB ( Image< float > &  mosaic)
void ImageBlenderIncremental::GetMosaicRGBA ( Image< unsigned char > &  mosaic)
void ImageBlenderIncremental::GetMosaicRGBA ( Image< float > &  mosaic)
unsigned int BIAS::ImageBlenderIncremental::GetOuputImageSize ( )
inline
Author
Robert Wulff
Date
10/2007

Definition at line 198 of file ImageBlenderIncremental.hh.

void ImageBlenderIncremental::LowPassFusiondAndHighPassMax_ ( Image< float > &  destLow,
Image< float > &  destHigh,
Image< float > &  lowPassCam,
Image< float > &  highPassCam 
)
protected
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
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.

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.

void BIAS::ImageBlenderIncremental::SetDepthMap ( const BIAS::Image< float > &  depthmap)
inline

Definition at line 174 of file ImageBlenderIncremental.hh.

References BIAS::ImageBase::SetZero().

void BIAS::ImageBlenderIncremental::SetDrawImageBorders ( bool  flag)
inline

Definition at line 205 of file ImageBlenderIncremental.hh.

static void BIAS::Debug::SetGlobalDebugLevel ( long int  lev)
inlinestaticinherited

Definition at line 424 of file Debug.hh.

void BIAS::ImageBlenderIncremental::SetHorizonAlignment ( unsigned int  val)
inline

determines the alignment of the horizon possible values are: HORIZON_ALIGNMENT_X - horizon is in x direction (default value) HORIZON_ALIGNMENT_X - horizon is in y direction HORIZON_ALIGNMENT_UNKNOWN - horizon alignment is unknown or mixed

Date
12/07

Definition at line 217 of file ImageBlenderIncremental.hh.

void BIAS::ImageBlenderIncremental::SetOuputImageSize ( const unsigned int &  newSize)
inline
Author
Robert Wulff
Date
10/2007

Definition at line 188 of file ImageBlenderIncremental.hh.

void ImageBlenderIncremental::SetOutputParameters ( const BIAS::ProjectionParametersBase imagegeometry,
const BIAS::RGBAuc  bgcolor = RGBAuc(0,0,0,0) 
)

resets internal mosaic

Parameters
imagegeometryprojectionparameters of output mosaic
bgcolorinitial background color of empty mosaic (e.g. black)
pDepthmapif != NULL, this enables 3D stitching mode and the camera centers of the image and the final mosaic will be considered

Definition at line 33 of file ImageBlenderIncremental.cpp.

References BIAS::ProjectionParametersBase::Clone(), BIAS::ProjectionParametersBase::GetImageSize(), and BIAS::Projection::IsEmpty().

void BIAS::ImageBlenderIncremental::SetPlane ( const HomgPlane3D theplane)
inline

Definition at line 178 of file ImageBlenderIncremental.hh.

void ImageBlenderIncremental::SetUserWeightImage ( const BIAS::Image< float > &  weights)

set a weight image (e.g.

to ignore certain pixels or to account for funny illumination and confidence in pixel color

specify WEIGHT_TYPE_USERIMAGE to use this in AddCamera

Parameters
weightsmust be of same size as next user input image

Definition at line 112 of file ImageBlenderIncremental.cpp.

void BIAS::ImageBlenderIncremental::SetWriteVrml ( bool  flag)
inline

Definition at line 203 of file ImageBlenderIncremental.hh.

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.

Member Data Documentation

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=().

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=().

bool BIAS::ImageBlenderIncremental::blendIncremental_
protected

incremental or batchmode

Definition at line 282 of file ImageBlenderIncremental.hh.

double BIAS::ImageBlenderIncremental::cylinderHeight_
protected

Definition at line 270 of file ImageBlenderIncremental.hh.

BIAS::Image<float> BIAS::ImageBlenderIncremental::Depth_
protected

output depth

Definition at line 291 of file ImageBlenderIncremental.hh.

bool BIAS::ImageBlenderIncremental::drawImageBorders_
protected

Definition at line 281 of file ImageBlenderIncremental.hh.

BIAS::Gauss<float, float> BIAS::ImageBlenderIncremental::gaussFilter_
protected

Definition at line 278 of file ImageBlenderIncremental.hh.

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

Definition at line 513 of file Debug.hh.

unsigned int BIAS::ImageBlenderIncremental::horizonAlignment_
protected

Definition at line 273 of file ImageBlenderIncremental.hh.

std::vector<BIAS::UUID> BIAS::ImageBlenderIncremental::imageIDs_
protected

Definition at line 275 of file ImageBlenderIncremental.hh.

std::map<BIAS::UUID, BIAS::Camera<float> > BIAS::ImageBlenderIncremental::inputImages_
protected

Definition at line 276 of file ImageBlenderIncremental.hh.

BIAS::Image<float> BIAS::ImageBlenderIncremental::latestMosaicHigh_
protected

output image in incremental mode

Definition at line 287 of file ImageBlenderIncremental.hh.

BIAS::Image<float> BIAS::ImageBlenderIncremental::latestMosaicLow_
protected

Definition at line 287 of file ImageBlenderIncremental.hh.

unsigned int BIAS::ImageBlenderIncremental::outputImageHeight_
protected

Definition at line 272 of file ImageBlenderIncremental.hh.

unsigned int BIAS::ImageBlenderIncremental::outputImageWidth_
protected

Definition at line 271 of file ImageBlenderIncremental.hh.

BIAS::HomgPlane3D BIAS::ImageBlenderIncremental::plane_
protected

plane (alternative to depth)

Definition at line 293 of file ImageBlenderIncremental.hh.

BIAS::ProjectionMapping<float, float> BIAS::ImageBlenderIncremental::pm_
protected

the actual worker:

Definition at line 295 of file ImageBlenderIncremental.hh.

BIAS::ProjectionParametersBase* BIAS::ImageBlenderIncremental::ppOutput_
protected

output projection

Definition at line 289 of file ImageBlenderIncremental.hh.

BIAS::Image<float> BIAS::ImageBlenderIncremental::weightimage_
protected

weight image for user specified weighting

Definition at line 285 of file ImageBlenderIncremental.hh.

bool BIAS::ImageBlenderIncremental::writeVrml_
protected

Definition at line 280 of file ImageBlenderIncremental.hh.


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