laserlib::walz Class Reference

Implements WALZ. WAvelet Laser Zipper. More...

Inheritance diagram for laserlib::walz:

laserlib::io

List of all members.

Public Member Functions

 walz ()
 Ctor.
 walz (int const &log2Chunks, double const &truncateThreshold, int const &overviewFactor)
 Constructor.
virtual ~walz ()
 Dtor.
bool InitRead (std::string const &filename, ParametersWalz &param)
 Initialize reading points from file.
virtual bool Read (bool &bEOF)
 Read points from file.
virtual bool ReadHeader (bool &bEOF)
virtual bool ReadLevel (int &level, bool bEOF, bool bSkip)
bool Compress ()
 Compress.
bool Uncompress ()
 Uncompress.
bool InitWrite (std::string const &filename, ParametersWalz &param)
 Write to file.
virtual bool Write ()
 Write a chunk of data to file.
virtual bool GetPoints (BoundingBox const &bb, Container &aContainer)
 Get the points that fall inside a rectangle.
virtual bool GetOverview (int const &level, Container &aContainer)
 Get a lower resolution overview.

Private Member Functions

int _GetIndex (double value, int interval)
 Get index to Huffman histogram.
bool _AnalyzeHistogram (Vec_ULNG &hX, std::list< int > &breakPointList)
void haar (Vec_IO_DP &a, const int n, const int isign)
 Haar transform.
void wtInt (Vec_IO_INT &a, const int n, const int isign)
 Integer "fake" wavelet (for thematic data).
bool _DoHuffman ()
 Huffman encode.
bool _CompressHuffman ()
 Encode one level with Huffman.
bool _CompressPackBits ()
 Donīt do wavelets, just compress the coordinates by packing the bits.
bool _CompressPackBitsNoWavelet ()
 Called from walz::_CompressPackBits iff wavelet type is laserlib::EWT_NONE.
bool _CompressPackBitsWavelet ()
 Called from walz::_CompressPackBits iff wavelet type differs from laserlib::EWT_NONE.
bool _CompressPackBits (int nStart, int nEnd, BoundingBox &bb, Point3D &Center, unsigned int &DLX, unsigned int &DLY, unsigned int &DLZ, double &stddev, unsigned char *pBuffer)
 Pack bits within an interval.
bool _UncompressPackBits ()
 Donīt do wavelets, just uncompress the coordinates by unpacking the bits.
bool _UncompressPackBitsWavelet ()
 Uncompress a PackBit level with wavelets.
bool _UncompressPackBitsNoWavelet ()
 Uncompress a PackBit level without wavelets.
bool _UncompressHuffman ()
 Uncompress a Huffman level.
bool _PackBitsEncode (unsigned long const &iVal, unsigned char *pBuf, unsigned long &nb, int const &DL)
 A helper to pack integer bits to a buffer.
bool _PackBitsDecode (unsigned long &iVal, unsigned char *pBuf, unsigned long &nb, int const &DL)
 A helper to unpack integer bits from a buffer.
bool _WriteXYZ ()
 Write in ASCII XYZ format.
bool _GetBoundingBox (BoundingBox &bb, int const &nStart, int const &nEnd)
 Get bounding box of coordinates within interval.
bool _GetDescriptionLength (BoundingBox const &bb, double &stddev, Point3D &DL, unsigned int *iDL)
 Get bit length for each coordinate.

Private Attributes

std::vector< LevelcvLevel
LevelcpCurrentLevel
bool cbWriteXYZ
 See _WriteXYZ().

Classes

struct  HuffmanData
 Data to (re)store huffman coded data. More...
struct  Level
 Compressed, wavelet transformed level. More...


Detailed Description

Implements WALZ. WAvelet Laser Zipper.

A wavelet based compression format. Uses Numerical Recipes. Associated with the EFileType::EFT_WALZ type.


Constructor & Destructor Documentation

walz::walz (  ) 

Ctor.

Defaults chunksize to 2**16

walz::walz ( int const &  log2Chunks,
double const &  truncateThreshold,
int const &  overviewFactor 
)

Constructor.

Parameters:
log2Chunks log2(N) where N is the number of desired point to be kept as one unit
truncateThreshold Wavelet coefficients below this value will be truncated when compressing. Already a vlue of 0.3 seems to compress a lot.
overviewFactor Only N/overviewFactor points will be saved when compressing, using the top levels of the wavelet vectors. Must be multiple of 2.

walz::~walz (  )  [virtual]

Dtor.


Member Function Documentation

bool walz::InitRead ( std::string const &  filename,
ParametersWalz param 
) [virtual]

Initialize reading points from file.

  • Opens the file (ascii if cbWriteXYZ==true, binary otherwise)
  • Reads the first 4 bytes and asserts that they read 'W','A','L','Z'.
  • Reads file version (major, minor, and laserlib::EWaveletType)
    Todo:
    Reads an XYZ file with six entries per point. This reading should be done in laserlib::xyz
    Todo:
    Only reads one chunk. Should read all chunks.
    See also:
    Read( bool& )

Implements laserlib::io.

bool walz::Read ( bool &  bEOF  )  [virtual]

Read points from file.

Reads a block of points from file. Note that the entire file is not read at once. Must be called after walz::InitRead. Reads:

  • Bounding box
  • Point accuracy
  • Bit length for X, Y, and Z respectively (fixed for PACKBITS, see todo below)
  • Number of points in block
  • Size of the compressed block in bytes (walz::cpBuffer is allocated accordingly)
  • The compressed data block

Parameters:
bEOF True if end-of-file was reached
Returns:
true on success, false on failure
Todo:
Only implemented for EWT_PACKBITS and binary walz (cbWriteXYZ==false)
See also:
InitRead, Write

Implements laserlib::io.

bool walz::ReadHeader ( bool &  bEOF  )  [virtual]

bool walz::ReadLevel ( int &  level,
bool  bEOF,
bool  bSkip 
) [virtual]

bool walz::Compress (  )  [virtual]

Compress.

Calls walz::_CompressPackBits and returns if EWaveletType is EWT_PACKBITS. Otherwise:

  • Check if we should truncate data and if we should store only a low resolution area
  • Do the wavelet transform according to the defined wavelet type.
  • Truncate data if desired
  • Save only low-res if desired
  • Call walz::_DoHuffman to encode the detail coefficients with Huffman encoding

Implements laserlib::io.

bool walz::Uncompress (  )  [virtual]

Uncompress.

Performs inverse wavelet transform on the possibly compressed coordiante vectors.

Implements laserlib::io.

bool walz::InitWrite ( std::string const &  filename,
ParametersWalz param 
) [virtual]

Write to file.

  • Open the file for writing (binary if cbWriteXYZ==false, ascii otherwise)
  • Write 'W','A','L','Z' in the first 4 bytes
  • Write version (major=0, minor=1) and wavelet type in the following 3 unsigned shorts

Parameters:
filename Output file name
param File save options

Implements laserlib::io.

bool walz::Write (  )  [virtual]

Write a chunk of data to file.

Implements laserlib::io.

bool walz::GetPoints ( BoundingBox const &  bb,
Container aContainer 
) [virtual]

Get the points that fall inside a rectangle.

Parameters:
bb Bounding box of area to get all points in
aContainer Container to fill with the points
Todo:
Not implemented

Reimplemented from laserlib::io.

bool walz::GetOverview ( int const &  level,
Container aContainer 
) [virtual]

Get a lower resolution overview.

Parameters:
level Overview level
aContainer Container to fill with the points
Todo:
Not implemented

Reimplemented from laserlib::io.

int walz::_GetIndex ( double  value,
int  interval 
) [private]

Get index to Huffman histogram.

bool walz::_AnalyzeHistogram ( Vec_ULNG &  hX,
std::list< int > &  breakPointList 
) [private]

void walz::haar ( Vec_IO_DP &  a,
const int  n,
const int  isign 
) [private]

Haar transform.

Actually unsymmetric Haar: Forward: s0 = 0.5*(v0+v1); d0 = 0.5*(v1-v0); Backward: v0 = s0-d0; v1=s0+d0;

void walz::wtInt ( Vec_IO_INT &  a,
const int  n,
const int  isign 
) [private]

Integer "fake" wavelet (for thematic data).

Can be used on thematic data? Works like nearest neighbor. Forward s0 = v0; d0 = v1-v0; Backward: v0 = s0; v1 = s0+d0;

bool walz::_DoHuffman (  )  [private]

Huffman encode.

For each level 1-4:

  • Create histograms in X, Y and Z, using the Parameters::cAccuracy and a fixed maximum value (+/- 5.12). (nEntries-1) is reserved for all values that do not fit in the interval.
  • Find max in each histogram
  • Create smaller histograms (+/- 0.64) centered around the maxima
  • Create Huffman lookup tables from the histograms
  • Encode each vector with the bit code defined bu the Huffman table
  • Decode the buffer to check that encoding was correct
    Todo:
    Remove the decoding
    Todo:
    Initialize histograms to 0:s, not 1:s before fill. Map non-zero entries after fill and encode those
    Todo:
    Copy the buffer to cpBuffer so that it can be saved
    Todo:
    Copy the Huffman tables to the buffer
    Todo:
    Write larger detail coefficients explicitly to buffer
    Todo:
    Save the translations that center the histograms to zero
    Todo:
    Remove the hardcoded file write to "c:\checkout\gnuplot.txt"

bool walz::_CompressHuffman (  )  [private]

Encode one level with Huffman.

bool walz::_CompressPackBits (  )  [private]

Donīt do wavelets, just compress the coordinates by packing the bits.

Relates to the EWT_PACKBITS wavelet type.

See also:
_UncompressPackBits

bool walz::_CompressPackBitsNoWavelet (  )  [private]

Called from walz::_CompressPackBits iff wavelet type is laserlib::EWT_NONE.

See also:
_CompressPackBitsWavelet

bool walz::_CompressPackBitsWavelet (  )  [private]

Called from walz::_CompressPackBits iff wavelet type differs from laserlib::EWT_NONE.

See also:
_CompressPackBitsNoWavelet

bool walz::_CompressPackBits ( int  nStart,
int  nEnd,
BoundingBox bb,
Point3D Center,
unsigned int &  DLX,
unsigned int &  DLY,
unsigned int &  DLZ,
double &  stddev,
unsigned char *  pBuffer 
) [private]

Pack bits within an interval.

Parameters:
nStart Start index to pack bits from
nEnd EEnd index to stop pack bits at
bb Bounding box inside the given interval
Center Center point of this interval
DLX Bit lengths for x inside the given interval
DLY Bit lengths for y inside the given interval
DLZ Bit lengths for z inside the given interval
stddev Accuracy of points within given interval
pBuffer Buffer to add compressed pack bits to

bool walz::_UncompressPackBits (  )  [private]

Donīt do wavelets, just uncompress the coordinates by unpacking the bits.

Relates to the EWT_PACKBITS wavelet type.

See also:
_CompressPackBits

bool walz::_UncompressPackBitsWavelet (  )  [private]

Uncompress a PackBit level with wavelets.

The cpCurrentLevel is uncompressed

bool walz::_UncompressPackBitsNoWavelet (  )  [private]

Uncompress a PackBit level without wavelets.

The cpCurrentLevel is uncompressed

bool walz::_UncompressHuffman (  )  [private]

Uncompress a Huffman level.

The cpCurrentLevel is uncompressed

bool walz::_PackBitsEncode ( unsigned long const &  iVal,
unsigned char *  pBuf,
unsigned long &  nb,
int const &  DL 
) [private]

A helper to pack integer bits to a buffer.

bool walz::_PackBitsDecode ( unsigned long &  iVal,
unsigned char *  pBuf,
unsigned long &  nb,
int const &  DL 
) [private]

A helper to unpack integer bits from a buffer.

bool walz::_WriteXYZ (  )  [private]

Write in ASCII XYZ format.

Todo:
Has nothing with walz to do. Used for debugging. Remove.

bool walz::_GetBoundingBox ( BoundingBox bb,
int const &  nStart,
int const &  nEnd 
) [private]

Get bounding box of coordinates within interval.

Parameters:
bb Bounding box within interval (output)
nStart Start of interval
nEnd End of interval, non-inclusive

bool walz::_GetDescriptionLength ( BoundingBox const &  bb,
double &  stddev,
Point3D DL,
unsigned int *  iDL 
) [private]

Get bit length for each coordinate.

Takes width, height, dZ and precision into account and assumes rectangular distribution.

Parameters:
bb Bounding box
stddev Precision of data
DL Description lengths
iDL Closest larger integer, vector of [3] elements


Member Data Documentation

std::vector< Level > laserlib::walz::cvLevel [private]


Generated on Fri Feb 20 22:49:52 2009 for WALZ WAvelet Lidar Zipper by  doxygen 1.5.6