00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028
00029 #ifndef PGF_WAVELETTRANSFORM_H
00030 #define PGF_WAVELETTRANSFORM_H
00031
00032 #include "PGFtypes.h"
00033 #include "Subband.h"
00034
00036
00037 #define FilterWidth 5
00038 #define FilterHeight 3
00039
00040 #ifdef __PGFROISUPPORT__
00045 class CRoiIndices {
00046 friend class CWaveletTransform;
00047
00050 CRoiIndices()
00051 : m_nLevels(0)
00052 , m_indices(0)
00053 {}
00054
00057 ~CRoiIndices() { Destroy(); }
00058
00059 void Destroy() { delete[] m_indices; m_indices = 0; }
00060 void CreateIndices();
00061 void ComputeIndices(UINT32 width, UINT32 height, const PGFRect& rect);
00062 const PGFRect& GetIndices(int level) const { ASSERT(m_indices); ASSERT(level >= 0 && level < m_nLevels); return m_indices[level]; }
00063 void SetLevels(int levels) { ASSERT(levels > 0); m_nLevels = levels; }
00064 void ComputeTileIndex(UINT32 width, UINT32 height, UINT32 pos, bool horizontal, bool isMin);
00065
00066 public:
00070 UINT32 GetNofTiles(int level) const { ASSERT(level >= 0 && level < m_nLevels); return 1 << (m_nLevels - level - 1); }
00071
00072 private:
00073 int m_nLevels;
00074 PGFRect *m_indices;
00075
00076 };
00077 #endif //__PGFROISUPPORT__
00078
00079
00084 class CWaveletTransform {
00085 friend class CSubband;
00086
00087 public:
00094 CWaveletTransform(UINT32 width, UINT32 height, int levels, DataT* data = NULL);
00095
00098 ~CWaveletTransform() { Destroy(); }
00099
00106 OSError ForwardTransform(int level, int quant);
00107
00116 OSError InverseTransform(int level, UINT32* width, UINT32* height, DataT** data);
00117
00122 CSubband* GetSubband(int level, Orientation orientation) {
00123 ASSERT(level >= 0 && level < m_nLevels);
00124 return &m_subband[level][orientation];
00125 }
00126
00127 #ifdef __PGFROISUPPORT__
00131 void SetROI(const PGFRect& rect);
00132
00136 const PGFRect& GetTileIndices(int level) const { return m_ROIindices.GetIndices(level); }
00137
00141 UINT32 GetNofTiles(int level) const { return m_ROIindices.GetNofTiles(level); }
00142
00146 const PGFRect& GetROI(int level) const { return m_subband[level][LL].GetROI(); }
00147
00148 #endif // __PGFROISUPPORT__
00149
00150 private:
00151 void Destroy() {
00152 delete[] m_subband; m_subband = 0;
00153 #ifdef __PGFROISUPPORT__
00154 m_ROIindices.Destroy();
00155 #endif
00156 }
00157 void InitSubbands(UINT32 width, UINT32 height, DataT* data);
00158 void ForwardRow(DataT* buff, UINT32 width);
00159 void InverseRow(DataT* buff, UINT32 width);
00160 void LinearToMallat(int destLevel,DataT* loRow, DataT* hiRow, UINT32 width);
00161 void MallatToLinear(int srcLevel, DataT* loRow, DataT* hiRow, UINT32 width);
00162
00163 #ifdef __PGFROISUPPORT__
00164 CRoiIndices m_ROIindices;
00165 #endif //__PGFROISUPPORT__
00166
00167 int m_nLevels;
00168 CSubband (*m_subband)[NSubbands];
00169 };
00170
00171 #endif //PGF_WAVELETTRANSFORM_H