CSubband man page

CSubband — Wavelet channel class.

Synopsis

#include <Subband.h>

Public Member Functions

CSubband ()
Standard constructor.
~CSubband ()
Destructor.
bool AllocMemory ()

void FreeMemory ()
Delete the memory buffer of this subband.
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.

36 : m_width(0)
37 , m_height(0)
38 , m_size(0)
39 , m_level(0)
40 , m_orientation(LL)
41 , m_data(0)
42 , m_dataPos(0)
43 #ifdef __PGFROISUPPORT__
44 , m_nTiles(0)
45 #endif
46 {
47 }

CSubband::~CSubband ()

Destructor.

Definition at line 51 of file Subband.cpp.

51                     {
52         FreeMemory();
53 }

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.

77                            {
78         UINT32 oldSize = m_size;
79 
80 #ifdef __PGFROISUPPORT__
81         m_size = BufferWidth()*m_ROI.Height();
82 #endif
83         ASSERT(m_size > 0);
84 
85         if (m_data) {
86                 if (oldSize >= m_size) {
87                         return true;
88                 } else {
89                         delete[] m_data;
90                         m_data = new(std::nothrow) DataT[m_size];
91                         return (m_data != 0);
92                 }
93         } else {
94                 m_data = new(std::nothrow) DataT[m_size];
95                 return (m_data != 0);
96         }
97 }

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)

Definition at line 154 of file Subband.cpp.

154                                         {
155         if (m_orientation == LL) {
156                 quantParam -= m_level + 1;
157         } else if (m_orientation == HH) {
158                 quantParam -= m_level - 1;
159         } else {
160                 quantParam -= m_level;
161         }
162         if (quantParam > 0) {
163                 for (UINT32 i=0; i < m_size; i++) {
164                         m_data[i] <<= quantParam;
165                 }
166         }
167 }

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

Definition at line 177 of file Subband.cpp.

177                                                                                                 {
178 #ifdef __PGFROISUPPORT__
179         if (tile) {
180                 // compute tile position and size
181                 UINT32 xPos, yPos, w, h;
182                 TilePosition(tileX, tileY, xPos, yPos, w, h);
183 
184                 // write values into buffer using partitiong scheme
185                 encoder.Partition(this, w, h, xPos + yPos*m_width, m_width);
186         } else 
187 #endif
188         {
189                 // write values into buffer using partitiong scheme
190                 encoder.Partition(this, m_width, m_height, 0, m_width);
191         }
192 }

void CSubband::FreeMemory ()

Delete the memory buffer of this subband.

Definition at line 101 of file Subband.cpp.

101                           {
102         if (m_data) {
103                 delete[] m_data; m_data = 0;
104         }
105 }

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.

106 { return m_data; }

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

Definition at line 150 of file Subband.h.

150 { return m_dataPos; }

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.

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

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.

122 { return m_height; }

int CSubband::GetLevel () const [inline]

Return level of this subband.

Returns:

Level of this subband

Definition at line 117 of file Subband.h.

117 { return m_level; }

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.

134 { return m_orientation; }

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.

127 { return m_width; }

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

Definition at line 160 of file Subband.h.

160 { m_dataPos = 0; }

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

Definition at line 57 of file Subband.cpp.

57                                                                                     {
58         m_width = width;
59         m_height = height;
60         m_size = m_width*m_height;
61         m_level = level;
62         m_orientation = orient;
63         m_data = 0;
64         m_dataPos = 0;
65 #ifdef __PGFROISUPPORT__
66         m_ROI.left = 0;
67         m_ROI.top = 0;
68         m_ROI.right = m_width;
69         m_ROI.bottom = m_height;
70         m_nTiles = 0;
71 #endif
72 }

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

Definition at line 202 of file Subband.cpp.

202                                                                                                               {
203         // allocate memory
204         if (!AllocMemory()) ReturnWithError(InsufficientMemory);
205 
206         // correct quantParam with normalization factor
207         if (m_orientation == LL) {
208                 quantParam -= m_level + 1;
209         } else if (m_orientation == HH) {
210                 quantParam -= m_level - 1;
211         } else {
212                 quantParam -= m_level;
213         }
214         if (quantParam < 0) quantParam = 0;
215 
216 #ifdef __PGFROISUPPORT__
217         if (tile) {
218                 UINT32 xPos, yPos, w, h;
219 
220                 // compute tile position and size
221                 TilePosition(tileX, tileY, xPos, yPos, w, h);
222                 
223                 ASSERT(xPos >= m_ROI.left && yPos >= m_ROI.top);
224                 decoder.Partition(this, quantParam, w, h, (xPos - m_ROI.left) + (yPos - m_ROI.top)*BufferWidth(), BufferWidth());
225         } else 
226 #endif
227         {
228                 // read values into buffer using partitiong scheme
229                 decoder.Partition(this, quantParam, m_width, m_height, 0, m_width);
230         }
231 }

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.

112                                       {
113         if (m_orientation == LL) {
114                 quantParam -= (m_level + 1);
115                 // uniform rounding quantization
116                 if (quantParam > 0) {
117                         quantParam--;
118                         for (UINT32 i=0; i < m_size; i++) {
119                                 if (m_data[i] < 0) {
120                                         m_data[i] = -(((-m_data[i] >> quantParam) + 1) >> 1);
121                                 } else {
122                                         m_data[i] = ((m_data[i] >> quantParam) + 1) >> 1;
123                                 }
124                         }
125                 }
126         } else {
127                 if (m_orientation == HH) {
128                         quantParam -= (m_level - 1);
129                 } else {
130                         quantParam -= m_level;
131                 }
132                 // uniform deadzone quantization
133                 if (quantParam > 0) {
134                         int threshold = ((1 << quantParam) * 7)/5;      // good value
135                         quantParam--;
136                         for (UINT32 i=0; i < m_size; i++) {
137                                 if (m_data[i] < -threshold) {
138                                         m_data[i] = -(((-m_data[i] >> quantParam) + 1) >> 1);
139                                 } else if (m_data[i] > threshold) {
140                                         m_data[i] = ((m_data[i] >> quantParam) + 1) >> 1;
141                                 } else {
142                                         m_data[i] = 0;
143                                 }
144                         }
145                 }
146         }
147 }

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

Definition at line 148 of file Subband.h.

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

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

Definition at line 147 of file Subband.h.

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

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.

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

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

Definition at line 146 of file Subband.h.

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

Member Data Documentation

DataT* CSubband::m_data [private]

buffer

Definition at line 170 of file Subband.h.

UINT32 CSubband::m_dataPos [private]

current position in m_data

Definition at line 169 of file Subband.h.

UINT32 CSubband::m_height [private]

height in pixels

Definition at line 165 of file Subband.h.

int CSubband::m_level [private]

recursion level

Definition at line 167 of file Subband.h.

Orientation CSubband::m_orientation [private]

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_size [private]

size of data buffer m_data

Definition at line 166 of file Subband.h.

UINT32 CSubband::m_width [private]

width in pixels

Definition at line 164 of file Subband.h.

Author

Generated automatically by Doxygen for libpgf from the source code.

Info

Thu Feb 4 2016 Version 6.14.12 libpgf