Scribus
Open source desktop publishing at your fingertips
WaveletTransform.h
Go to the documentation of this file.
1 /*
2  * The Progressive Graphics File; http://www.libpgf.org
3  *
4  * $Date: 2006-05-18 16:03:32 +0200 (Do, 18 Mai 2006) $
5  * $Revision: 194 $
6  *
7  * This file Copyright (C) 2006 xeraina GmbH, Switzerland
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  */
23 
28 
29 #ifndef PGF_WAVELETTRANSFORM_H
30 #define PGF_WAVELETTRANSFORM_H
31 
32 #include "PGFtypes.h"
33 #include "Subband.h"
34 
36 // Constants
37 #define FilterWidth 5
38 #define FilterHeight 3
39 
40 #ifdef __PGFROISUPPORT__
41 class CRoiIndices {
46  friend class CWaveletTransform;
47 
50  CRoiIndices()
51  : m_nLevels(0)
52  , m_indices(0)
53  {}
54 
57  ~CRoiIndices() { Destroy(); }
58 
59  void Destroy() { delete[] m_indices; m_indices = 0; }
60  void CreateIndices();
61  void ComputeIndices(UINT32 width, UINT32 height, const PGFRect& rect);
62  const PGFRect& GetIndices(int level) const { ASSERT(m_indices); ASSERT(level >= 0 && level < m_nLevels); return m_indices[level]; }
63  void SetLevels(int levels) { ASSERT(levels > 0); m_nLevels = levels; }
64  void ComputeTileIndex(UINT32 width, UINT32 height, UINT32 pos, bool horizontal, bool isMin);
65 
66 public:
70  UINT32 GetNofTiles(int level) const { ASSERT(level >= 0 && level < m_nLevels); return 1 << (m_nLevels - level - 1); }
71 
72 private:
73  int m_nLevels;
74  PGFRect *m_indices;
75 
76 };
77 #endif //__PGFROISUPPORT__
78 
79 
85  friend class CSubband;
86 
87 public:
94  CWaveletTransform(UINT32 width, UINT32 height, int levels, DataT* data = NULL);
95 
98  ~CWaveletTransform() { Destroy(); }
99 
106  OSError ForwardTransform(int level, int quant);
107 
116  OSError InverseTransform(int level, UINT32* width, UINT32* height, DataT** data);
117 
122  CSubband* GetSubband(int level, Orientation orientation) {
123  ASSERT(level >= 0 && level < m_nLevels);
124  return &m_subband[level][orientation];
125  }
126 
127 #ifdef __PGFROISUPPORT__
128  void SetROI(const PGFRect& rect);
132 
136  const PGFRect& GetTileIndices(int level) const { return m_ROIindices.GetIndices(level); }
137 
141  UINT32 GetNofTiles(int level) const { return m_ROIindices.GetNofTiles(level); }
142 
146  const PGFRect& GetROI(int level) const { return m_subband[level][LL].GetROI(); }
147 
148 #endif // __PGFROISUPPORT__
149 
150 private:
151  void Destroy() {
152  delete[] m_subband; m_subband = 0;
153  #ifdef __PGFROISUPPORT__
154  m_ROIindices.Destroy();
155  #endif
156  }
157  void InitSubbands(UINT32 width, UINT32 height, DataT* data);
158  void ForwardRow(DataT* buff, UINT32 width);
159  void InverseRow(DataT* buff, UINT32 width);
160  void LinearToMallat(int destLevel,DataT* loRow, DataT* hiRow, UINT32 width);
161  void MallatToLinear(int srcLevel, DataT* loRow, DataT* hiRow, UINT32 width);
162 
163 #ifdef __PGFROISUPPORT__
164  CRoiIndices m_ROIindices;
165 #endif //__PGFROISUPPORT__
166 
167  int m_nLevels;
168  CSubband (*m_subband)[NSubbands];
169 };
170 
171 #endif //PGF_WAVELETTRANSFORM_H
PGF wavelet transform.
Definition: WaveletTransform.h:84
CWaveletTransform(UINT32 width, UINT32 height, int levels, DataT *data=NULL)
Definition: WaveletTransform.cpp:40
CSubband * GetSubband(int level, Orientation orientation)
Definition: WaveletTransform.h:122
const PGFRect & GetTileIndices(int level) const
Definition: WaveletTransform.h:136
UINT32 GetNofTiles(int level) const
Definition: WaveletTransform.h:141
const PGFRect & GetROI(int level) const
Definition: WaveletTransform.h:146
Wavelet channel class.
Definition: Subband.h:42
OSError InverseTransform(int level, UINT32 *width, UINT32 *height, DataT **data)
Definition: WaveletTransform.cpp:245
PGF wavelet subband class.
PGF definitions.
CSubband()
Standard constructor.
Definition: Subband.cpp:35
#define NSubbands
number of subbands per level
Definition: PGFtypes.h:57
OSError ForwardTransform(int level, int quant)
Definition: WaveletTransform.cpp:88
UINT32 GetNofTiles(int level) const
Definition: WaveletTransform.h:70
void SetROI(const PGFRect &rect)
Definition: WaveletTransform.cpp:517
ROI indices.
Definition: WaveletTransform.h:45
~CWaveletTransform()
Destructor.
Definition: WaveletTransform.h:98
Rectangle.
Definition: PGFtypes.h:194