[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd/cvd haar.h
From: |
Gerhard Reitmayr |
Subject: |
[libcvd-members] libcvd/cvd haar.h |
Date: |
Wed, 25 Feb 2009 16:06:00 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Gerhard Reitmayr <gerhard> 09/02/25 16:06:00
Modified files:
cvd : haar.h
Log message:
haar refactored
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/haar.h?cvsroot=libcvd&r1=1.1&r2=1.2
Patches:
Index: haar.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/haar.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- haar.h 3 Dec 2008 23:33:04 -0000 1.1
+++ haar.h 25 Feb 2009 16:05:59 -0000 1.2
@@ -36,6 +36,15 @@
}
std::copy(store, store+2*w, from);
}
+
+ template<class It, class TempIt>
+ inline void inv_haar1D(It from, int w, TempIt store){
+ for(int i = 0; i < w; ++i){
+ store[2*i] = (from[i] + from[w+i]) * M_SQRT1_2;
+ store[2*i+1] = (from[i] - from[w+i]) * M_SQRT1_2;
+ }
+ std::copy(store, store+2*w, from);
+ }
}
@@ -48,11 +57,21 @@
template<class It>
inline void haar1D(It from, It to){
std::vector<typename std::iterator_traits<It>::value_type>
store(std::distance(from,to), typename std::iterator_traits<It>::value_type());
- int w = std::distance(from,to);
- while(w>1){
- w /= 2;
+ for(int w = std::distance(from,to)/2; w > 0; w /= 2)
Internal::haar1D(from, w, store.begin());
- }
+}
+
+/// computes the inverse 1D Haar transform of a signal in place. This version
takes
+/// two iterators, and the data between them will be transformed. Will only
work
+/// correctly on 2^N data points.
+/// @param from iterator pointing to the beginning of the data
+/// @param to iterator pointing to the end (after the last element)
+/// @ingroup gVision
+template<class It>
+inline void inv_haar1D(It from, It to){
+ std::vector<typename std::iterator_traits<It>::value_type>
store(std::distance(from,to), typename std::iterator_traits<It>::value_type());
+ for(int w = 1; w < std::distance(from,to); w *= 2)
+ Internal::inv_haar1D(from, w, store.begin());
}
/// computes the 1D Haar transform of a signal in place. Will only work
@@ -65,6 +84,16 @@
haar1D(from, from + size);
}
+/// computes the inverse 1D Haar transform of a signal in place. Will only work
+/// correctly on 2^N data points.
+/// @param from iterator pointing to the beginning of the data
+/// @param size number of data points, should be 2^N
+/// @ingroup gVision
+template<class It>
+inline void inv_haar1D(It from, int size){
+ inv_haar1D(from, from + size);
+}
+
/// computes the 2D Haar transform of a signal in place. Works only with
/// data with power of two dimensions, 2^N x 2^ M.
/// @param from iterator pointing to the beginning of the data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libcvd-members] libcvd/cvd haar.h,
Gerhard Reitmayr <=