CSubband Class Reference

Wavelet channel class. More...

#include <Subband.h>

List of all members.

Public Member Functions

 CSubband ()
 ~CSubband ()
bool AllocMemory ()
void FreeMemory ()
void ExtractTile (CEncoder &encoder, bool tile=false, UINT32 tileX=0, UINT32 tileY=0) THROW_
void PlaceTile (CDecoder &decoder, int quantParam, bool tile=false, UINT32 tileX=0, UINT32 tileY=0) THROW_
void Quantize (int quantParam)
void Dequantize (int quantParam)
void SetData (UINT32 pos, DataT v)
DataT * GetBuffer ()
DataT GetData (UINT32 pos) const
int GetLevel () const
int GetHeight () const
int GetWidth () const
Orientation GetOrientation () const

Private Member Functions

void Initialize (UINT32 width, UINT32 height, int level, Orientation orient)
void WriteBuffer (DataT val)
void SetBuffer (DataT *b)
DataT ReadBuffer ()
UINT32 GetBuffPos () const
void InitBuffPos ()

Private Attributes

UINT32 m_width
 width in pixels
UINT32 m_height
 height in pixels
UINT32 m_size
 size of data buffer m_data
int m_level
 recursion level
Orientation m_orientation
 0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd
UINT32 m_dataPos
 current position in m_data
DataT * m_data
 buffer

Friends

class CWaveletTransform


Detailed Description

Wavelet channel class.

PGF wavelet channel subband class.

Author:
C. Stamm, R. Spuler

Definition at line 42 of file Subband.h.


Constructor & Destructor Documentation

CSubband::CSubband (  ) 

Standard constructor.

Definition at line 35 of file Subband.cpp.

00036 : m_width(0)
00037 , m_height(0)
00038 , m_size(0)
00039 , m_level(0)
00040 , m_orientation(LL)
00041 , m_data(0)
00042 , m_dataPos(0)
00043 #ifdef __PGFROISUPPORT__
00044 , m_nTiles(0)
00045 #endif
00046 {
00047 }

CSubband::~CSubband (  ) 

Destructor.

Definition at line 51 of file Subband.cpp.

00051                     {
00052         FreeMemory();
00053 }


Member Function Documentation

bool CSubband::AllocMemory (  ) 

Allocate a memory buffer to store all wavelet coefficients of this subband.

Returns:
True if the allocation did work without any problems

Definition at line 77 of file Subband.cpp.

00077                            {
00078         UINT32 oldSize = m_size;
00079 
00080 #ifdef __PGFROISUPPORT__
00081         m_size = BufferWidth()*m_ROI.Height();
00082 #endif
00083         ASSERT(m_size > 0);
00084 
00085         if (m_data) {
00086                 if (oldSize >= m_size) {
00087                         return true;
00088                 } else {
00089                         delete[] m_data;
00090                         m_data = new(std::nothrow) DataT[m_size];
00091                         return (m_data != 0);
00092                 }
00093         } else {
00094                 m_data = new(std::nothrow) DataT[m_size];
00095                 return (m_data != 0);
00096         }
00097 }

void CSubband::FreeMemory (  ) 

Delete the memory buffer of this subband.

Definition at line 101 of file Subband.cpp.

00101                           {
00102         if (m_data) {
00103                 delete[] m_data; m_data = 0;
00104         }
00105 }

void CSubband::ExtractTile ( CEncoder &  encoder,
bool  tile = false,
UINT32  tileX = 0,
UINT32  tileY = 0 
)

Extracts a rectangular subregion of this subband. Write wavelet coefficients into buffer. It might throw an IOException.

Parameters:
encoder An encoder instance
tile True if just a rectangular region is extracted, false if the entire subband is extracted.
tileX Tile index in x-direction
tileY Tile index in y-direction
Extracts a rectangular subregion of this subband. Write wavelet coefficients into buffer. It might throw an IOException.
Parameters:
encoder An encoder instance
tile True if just a rectangular region is extracted, false if the entire subband is extracted.
tileX Tile index in x-direction
tileY Tile index in y-direction

Definition at line 177 of file Subband.cpp.

00177                                                                                                                       {
00178 #ifdef __PGFROISUPPORT__
00179         if (tile) {
00180                 // compute tile position and size
00181                 UINT32 xPos, yPos, w, h;
00182                 TilePosition(tileX, tileY, xPos, yPos, w, h);
00183 
00184                 // write values into buffer using partitiong scheme
00185                 encoder.Partition(this, w, h, xPos + yPos*m_width, m_width);
00186         } else 
00187 #endif
00188         {
00189                 // write values into buffer using partitiong scheme
00190                 encoder.Partition(this, m_width, m_height, 0, m_width);
00191         }
00192 }

void CSubband::PlaceTile ( CDecoder &  decoder,
int  quantParam,
bool  tile = false,
UINT32  tileX = 0,
UINT32  tileY = 0 
)

Decoding and dequantization of this subband. It might throw an IOException.

Parameters:
decoder A decoder instance
quantParam Dequantization value
tile True if just a rectangular region is placed, false if the entire subband is placed.
tileX Tile index in x-direction
tileY Tile index in y-direction
Decoding and dequantization of this subband. It might throw an IOException.
Parameters:
decoder A decoder instance
quantParam Dequantization value
tile True if just a rectangular region is placed, false if the entire subband is placed.
tileX Tile index in x-direction
tileY Tile index in y-direction

Definition at line 202 of file Subband.cpp.

00202                                                                                                                                     {
00203         // allocate memory
00204         if (!AllocMemory()) ReturnWithError(InsufficientMemory);
00205 
00206         // correct quantParam with normalization factor
00207         if (m_orientation == LL) {
00208                 quantParam -= m_level + 1;
00209         } else if (m_orientation == HH) {
00210                 quantParam -= m_level - 1;
00211         } else {
00212                 quantParam -= m_level;
00213         }
00214         if (quantParam < 0) quantParam = 0;
00215 
00216 #ifdef __PGFROISUPPORT__
00217         if (tile) {
00218                 UINT32 xPos, yPos, w, h;
00219 
00220                 // compute tile position and size
00221                 TilePosition(tileX, tileY, xPos, yPos, w, h);
00222                 
00223                 ASSERT(xPos >= m_ROI.left && yPos >= m_ROI.top);
00224                 decoder.Partition(this, quantParam, w, h, (xPos - m_ROI.left) + (yPos - m_ROI.top)*BufferWidth(), BufferWidth());
00225         } else 
00226 #endif
00227         {
00228                 // read values into buffer using partitiong scheme
00229                 decoder.Partition(this, quantParam, m_width, m_height, 0, m_width);
00230         }
00231 }

void CSubband::Quantize ( int  quantParam  ) 

Perform subband quantization with given quantization parameter. A scalar quantization (with dead-zone) is used. A large quantization value results in strong quantization and therefore in big quality loss.

Parameters:
quantParam A quantization parameter (larger or equal to 0)

Definition at line 112 of file Subband.cpp.

00112                                       {
00113         if (m_orientation == LL) {
00114                 quantParam -= (m_level + 1);
00115                 // uniform rounding quantization
00116                 if (quantParam > 0) {
00117                         quantParam--;
00118                         for (UINT32 i=0; i < m_size; i++) {
00119                                 if (m_data[i] < 0) {
00120                                         m_data[i] = -(((-m_data[i] >> quantParam) + 1) >> 1);
00121                                 } else {
00122                                         m_data[i] = ((m_data[i] >> quantParam) + 1) >> 1;
00123                                 }
00124                         }
00125                 }
00126         } else {
00127                 if (m_orientation == HH) {
00128                         quantParam -= (m_level - 1);
00129                 } else {
00130                         quantParam -= m_level;
00131                 }
00132                 // uniform deadzone quantization
00133                 if (quantParam > 0) {
00134                         int threshold = ((1 << quantParam) * 7)/5;      // good value
00135                         quantParam--;
00136                         for (UINT32 i=0; i < m_size; i++) {
00137                                 if (m_data[i] < -threshold) {
00138                                         m_data[i] = -(((-m_data[i] >> quantParam) + 1) >> 1);
00139                                 } else if (m_data[i] > threshold) {
00140                                         m_data[i] = ((m_data[i] >> quantParam) + 1) >> 1;
00141                                 } else {
00142                                         m_data[i] = 0;
00143                                 }
00144                         }
00145                 }
00146         }
00147 }

void CSubband::Dequantize ( int  quantParam  ) 

Perform subband dequantization with given quantization parameter. A scalar quantization (with dead-zone) is used. A large quantization value results in strong quantization and therefore in big quality loss.

Parameters:
quantParam A quantization parameter (larger or equal to 0)
Perform subband dequantization with given quantization parameter. A scalar quantization (with dead-zone) is used. A large quantization value results in strong quantization and therefore in big quality loss.
Parameters:
quantParam A quantization parameter (larger or equal to 0)

Definition at line 154 of file Subband.cpp.

00154                                         {
00155         if (m_orientation == LL) {
00156                 quantParam -= m_level + 1;
00157         } else if (m_orientation == HH) {
00158                 quantParam -= m_level - 1;
00159         } else {
00160                 quantParam -= m_level;
00161         }
00162         if (quantParam > 0) {
00163                 for (UINT32 i=0; i < m_size; i++) {
00164                         m_data[i] <<= quantParam;
00165                 }
00166         }
00167 }

void CSubband::SetData ( UINT32  pos,
DataT  v 
) [inline]

Store wavelet coefficient in subband at given position.

Parameters:
pos A subband position (>= 0)
v A wavelet coefficient

Definition at line 101 of file Subband.h.

00101 { ASSERT(pos < m_size); m_data[pos] = v; }

DataT* CSubband::GetBuffer (  )  [inline]

Get a pointer to an array of all wavelet coefficients of this subband.

Returns:
Pointer to array of wavelet coefficients

Definition at line 106 of file Subband.h.

00106 { return m_data; }

DataT CSubband::GetData ( UINT32  pos  )  const [inline]

Return wavelet coefficient at given position.

Parameters:
pos A subband position (>= 0)
Returns:
Wavelet coefficient

Definition at line 112 of file Subband.h.

00112 { ASSERT(pos < m_size); return m_data[pos]; }

int CSubband::GetLevel (  )  const [inline]

Return level of this subband.

Returns:
Level of this subband

Definition at line 117 of file Subband.h.

00117 { return m_level; }

int CSubband::GetHeight (  )  const [inline]

Return height of this subband.

Returns:
Height of this subband (in pixels)

Definition at line 122 of file Subband.h.

00122 { return m_height; }

int CSubband::GetWidth (  )  const [inline]

Return width of this subband.

Returns:
Width of this subband (in pixels)

Definition at line 127 of file Subband.h.

00127 { return m_width; }

Orientation CSubband::GetOrientation (  )  const [inline]

Return orientation of this subband. LL LH HL HH

Returns:
Orientation of this subband (LL, HL, LH, HH)

Definition at line 134 of file Subband.h.

00134 { return m_orientation; }

void CSubband::Initialize ( UINT32  width,
UINT32  height,
int  level,
Orientation  orient 
) [private]

Definition at line 57 of file Subband.cpp.

00057                                                                                     {
00058         m_width = width;
00059         m_height = height;
00060         m_size = m_width*m_height;
00061         m_level = level;
00062         m_orientation = orient;
00063         m_data = 0;
00064         m_dataPos = 0;
00065 #ifdef __PGFROISUPPORT__
00066         m_ROI.left = 0;
00067         m_ROI.top = 0;
00068         m_ROI.right = m_width;
00069         m_ROI.bottom = m_height;
00070         m_nTiles = 0;
00071 #endif
00072 }

void CSubband::WriteBuffer ( DataT  val  )  [inline, private]

Definition at line 146 of file Subband.h.

00146 { ASSERT(m_dataPos < m_size); m_data[m_dataPos++] = val; }

void CSubband::SetBuffer ( DataT *  b  )  [inline, private]

Definition at line 147 of file Subband.h.

00147 { ASSERT(b); m_data = b; }

DataT CSubband::ReadBuffer (  )  [inline, private]

Definition at line 148 of file Subband.h.

00148 { ASSERT(m_dataPos < m_size); return m_data[m_dataPos++]; }

UINT32 CSubband::GetBuffPos (  )  const [inline, private]

Definition at line 150 of file Subband.h.

00150 { return m_dataPos; }

void CSubband::InitBuffPos (  )  [inline, private]

Definition at line 160 of file Subband.h.

00160 { m_dataPos = 0; }


Friends And Related Function Documentation

friend class CWaveletTransform [friend]

Definition at line 43 of file Subband.h.


Member Data Documentation

UINT32 CSubband::m_width [private]

width in pixels

Definition at line 164 of file Subband.h.

UINT32 CSubband::m_height [private]

height in pixels

Definition at line 165 of file Subband.h.

UINT32 CSubband::m_size [private]

size of data buffer m_data

Definition at line 166 of file Subband.h.

int CSubband::m_level [private]

recursion level

Definition at line 167 of file Subband.h.

0=LL, 1=HL, 2=LH, 3=HH L=lowpass filtered, H=highpass filterd

Definition at line 168 of file Subband.h.

UINT32 CSubband::m_dataPos [private]

current position in m_data

Definition at line 169 of file Subband.h.

DataT* CSubband::m_data [private]

buffer

Definition at line 170 of file Subband.h.


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

Generated on Wed Sep 21 12:21:50 2016 for libpgf by  doxygen 1.5.6