libpgf  6.11.42
PGF - Progressive Graphics File
WaveletTransform.h
Go to the documentation of this file.
00001 /*
00002  * The Progressive Graphics File; http://www.libpgf.org
00003  * 
00004  * $Date: 2006-05-18 16:03:32 +0200 (Do, 18 Mai 2006) $
00005  * $Revision: 194 $
00006  * 
00007  * This file Copyright (C) 2006 xeraina GmbH, Switzerland
00008  * 
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
00011  * as published by the Free Software Foundation; either version 2.1
00012  * of the License, or (at your option) any later version.
00013  * 
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022  */
00023 
00028 
00029 #ifndef PGF_WAVELETTRANSFORM_H
00030 #define PGF_WAVELETTRANSFORM_H
00031 
00032 #include "PGFtypes.h"
00033 #include "Subband.h"
00034 
00036 // Constants
00037 #define FilterWidth                     5                                       ///< number of coefficients of the row wavelet filter
00038 #define FilterHeight            3                                       ///< number of coefficients of the column wavelet filter
00039 
00040 #ifdef __PGFROISUPPORT__
00041 
00042 
00043 
00044 
00045 class CROIs {
00046         friend class CWaveletTransform;
00047 
00051         CROIs(int levels) : m_nLevels(levels), m_ROIs(0), m_indices(0) { ASSERT(levels > 0); }
00052 
00055         ~CROIs() { Destroy(); }
00056 
00057         void Destroy()                                                          { delete[] m_ROIs; m_ROIs = 0; delete[] m_indices; m_indices = 0; }
00058         void CreateROIs();
00059         void CreateIndices();
00060         void ComputeIndices(UINT32 width, UINT32 height, const PGFRect& rect);
00061         void SetROI(int level, const PGFRect& rect)     { ASSERT(m_ROIs); ASSERT(level >= 0 && level < m_nLevels); m_ROIs[level] = rect; }
00062         const PGFRect& GetIndices(int level) const      { ASSERT(m_indices); ASSERT(level >= 0 && level < m_nLevels); return m_indices[level]; }
00063         UINT32 Left(int level) const                            { ASSERT(m_ROIs); ASSERT(level >= 0 && level < m_nLevels); return m_ROIs[level].left; }
00064         UINT32 Top(int level) const                                     { ASSERT(m_ROIs); ASSERT(level >= 0 && level < m_nLevels); return m_ROIs[level].top; }
00065         bool ROIisSupported() const                                     { return m_ROIs != 0; }
00066         void ComputeTileIndex(UINT32 width, UINT32 height, UINT32 pos, bool horizontal, bool isMin);
00067 
00068 public:
00072         UINT32 GetNofTiles(int level) const                     { ASSERT(level >= 0 && level < m_nLevels); return 1 << (m_nLevels - level - 1); }
00073 
00077         const PGFRect& GetROI(int level) const          { ASSERT(m_ROIs); ASSERT(level >= 0 && level < m_nLevels); return m_ROIs[level]; }
00078 
00079 private:
00080         int      m_nLevels;                     
00081         PGFRect *m_ROIs;                        
00082         PGFRect *m_indices;                     
00083 
00084 };
00085 #endif //__PGFROISUPPORT__
00086 
00087 
00092 class CWaveletTransform {
00093         friend class CSubband;
00094 
00095 public:
00102         CWaveletTransform(UINT32 width, UINT32 height, int levels, DataT* data = NULL);
00103 
00106         ~CWaveletTransform() { Destroy(); }
00107         
00114         OSError ForwardTransform(int level, int quant);
00115 
00124         OSError InverseTransform(int level, UINT32* width, UINT32* height, DataT** data);
00125 
00130         CSubband* GetSubband(int level, Orientation orientation) {
00131                 ASSERT(level >= 0 && level < m_nLevels);
00132                 return &m_subband[level][orientation];
00133         }
00134         
00135 #ifdef __PGFROISUPPORT__
00136 
00137 
00138 
00139         void SetROI(const PGFRect& rect);
00140 
00143         void SetROI();
00144 
00148         const PGFRect& GetTileIndices(int level) const  { return m_ROIs.GetIndices(level); }
00149 
00153         UINT32 GetNofTiles(int level) const                             { return m_ROIs.GetNofTiles(level); }
00154 
00158         const PGFRect& GetROI(int level) const                  { return m_ROIs.GetROI(level); }
00159 
00160 #endif // __PGFROISUPPORT__
00161 
00162 private:
00163         void Destroy() { delete[] m_subband; m_subband = 0; 
00164                 #ifdef __PGFROISUPPORT__
00165                 m_ROIs.Destroy(); 
00166                 #endif
00167         }
00168         void InitSubbands(UINT32 width, UINT32 height, DataT* data);
00169         void ForwardRow(DataT* buff, UINT32 width);
00170         void InverseRow(DataT* buff, UINT32 width);
00171         void LinearToMallat(int destLevel,DataT* loRow, DataT* hiRow, UINT32 width);
00172         void MallatToLinear(int srcLevel, DataT* loRow, DataT* hiRow, UINT32 width);
00173 
00174 #ifdef __PGFROISUPPORT__
00175         CROIs           m_ROIs;                                                 
00176 #endif //__PGFROISUPPORT__
00177 
00178         int                     m_nLevels;                                              
00179         CSubband        (*m_subband)[NSubbands];                
00180 };
00181 
00182 #endif //PGF_WAVELETTRANSFORM_H
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines