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 |
void | IncBuffRow (UINT32 pos) |
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 |
UINT32 | BufferWidth () const |
void | TilePosition (UINT32 tileX, UINT32 tileY, UINT32 &left, UINT32 &top, UINT32 &w, UINT32 &h) const |
const PGFRect & | GetROI () const |
void | SetNTiles (UINT32 nTiles) |
void | SetROI (const PGFRect &roi) |
void | InitBuffPos (UINT32 left=0, UINT32 top=0) |
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
|
PGFRect | m_ROI |
| region of interest
|
UINT32 | m_nTiles |
| number of tiles in one dimension in this subband
|
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
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.
UINT32 CSubband::BufferWidth |
( |
|
) |
const [inline, private] |
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.
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::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.
00177 {
00178 #ifdef __PGFROISUPPORT__
00179 if (tile) {
00180
00181 UINT32 xPos, yPos, w, h;
00182 TilePosition(tileX, tileY, xPos, yPos, w, h);
00183
00184
00185 encoder.Partition(this, w, h, xPos + yPos*m_width, m_width);
00186 } else
00187 #endif
00188 {
00189
00190 encoder.Partition(this, m_width, m_height, 0, m_width);
00191 }
00192 }
void CSubband::FreeMemory |
( |
|
) |
|
Delete the memory buffer of this subband.
Definition at line 101 of file Subband.cpp.
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.
UINT32 CSubband::GetBuffPos |
( |
|
) |
const [inline, private] |
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.
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.
int CSubband::GetLevel |
( |
|
) |
const [inline] |
Return level of this subband.
- Returns:
- Level of this subband
Definition at line 117 of file Subband.h.
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.
const PGFRect& CSubband::GetROI |
( |
|
) |
const [inline, private] |
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.
void CSubband::IncBuffRow |
( |
UINT32 |
pos |
) |
[inline] |
Set data buffer position to given position + one row.
- Parameters:
-
Definition at line 140 of file Subband.h.
void CSubband::InitBuffPos |
( |
UINT32 |
left = 0 , |
|
|
UINT32 |
top = 0 | |
|
) |
| | [inline, private] |
void CSubband::Initialize |
( |
UINT32 |
width, |
|
|
UINT32 |
height, |
|
|
int |
level, |
|
|
Orientation |
orient | |
|
) |
| | [private] |
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.
00202 {
00203
00204 if (!AllocMemory()) ReturnWithError(InsufficientMemory);
00205
00206
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
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
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
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
00133 if (quantParam > 0) {
00134 int threshold = ((1 << quantParam) * 7)/5;
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 }
DataT CSubband::ReadBuffer |
( |
|
) |
[inline, private] |
void CSubband::SetBuffer |
( |
DataT * |
b |
) |
[inline, private] |
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.
void CSubband::SetNTiles |
( |
UINT32 |
nTiles |
) |
[inline, private] |
void CSubband::SetROI |
( |
const PGFRect & |
roi |
) |
[inline, private] |
void CSubband::TilePosition |
( |
UINT32 |
tileX, |
|
|
UINT32 |
tileY, |
|
|
UINT32 & |
xPos, |
|
|
UINT32 & |
yPos, |
|
|
UINT32 & |
w, |
|
|
UINT32 & |
h | |
|
) |
| | const [private] |
Compute tile position and size.
- Parameters:
-
| tileX | Tile index in x-direction |
| tileY | Tile index in y-direction |
| xPos | [out] Offset to left |
| yPos | [out] Offset to top |
| w | [out] Tile width |
| h | [out] Tile height |
Definition at line 244 of file Subband.cpp.
00244 {
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256 UINT32 nTiles = m_nTiles;
00257 ASSERT(tileX < nTiles); ASSERT(tileY < nTiles);
00258 UINT32 m;
00259 UINT32 left = 0, right = nTiles;
00260 UINT32 top = 0, bottom = nTiles;
00261
00262 xPos = 0;
00263 yPos = 0;
00264 w = m_width;
00265 h = m_height;
00266
00267 while (nTiles > 1) {
00268
00269 m = left + ((right - left) >> 1);
00270 if (tileX >= m) {
00271 xPos += (w + 1) >> 1;
00272 w >>= 1;
00273 left = m;
00274 } else {
00275 w = (w + 1) >> 1;
00276 right = m;
00277 }
00278
00279 m = top + ((bottom - top) >> 1);
00280 if (tileY >= m) {
00281 yPos += (h + 1) >> 1;
00282 h >>= 1;
00283 top = m;
00284 } else {
00285 h = (h + 1) >> 1;
00286 bottom = m;
00287 }
00288 nTiles >>= 1;
00289 }
00290 ASSERT(xPos < m_width && (xPos + w <= m_width));
00291 ASSERT(yPos < m_height && (yPos + h <= m_height));
00292 }
void CSubband::WriteBuffer |
( |
DataT |
val |
) |
[inline, private] |
Friends And Related Function Documentation
Member Data Documentation
current position in m_data
Definition at line 169 of file Subband.h.
number of tiles in one dimension in this subband
Definition at line 174 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.
region of interest
Definition at line 173 of file Subband.h.
size of data buffer m_data
Definition at line 166 of file Subband.h.
The documentation for this class was generated from the following files: