comparison plugins/DWT.cpp @ 127:fb4688d2cca5

* make thresholding work (from TW)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 30 Jun 2009 10:15:01 +0000
parents 2416ef0e9319
children 1a24b134cd79
comparison
equal deleted inserted replaced
126:be19fa17042c 127:fb4688d2cca5
242 if ((1 << s) > b) b = 1 << s; // correct blocksize if smaller than 2^(max scale) 242 if ((1 << s) > b) b = 1 << s; // correct blocksize if smaller than 2^(max scale)
243 243
244 //-------------------------------------------------------------------------------------------------- 244 //--------------------------------------------------------------------------------------------------
245 245
246 float tempDet; 246 float tempDet;
247 float aTempDet;
247 int outloc; 248 int outloc;
248 int halfblocksize = int(.5 * b); 249 int halfblocksize = int(.5 * b);
249 int fbufloc; 250 int fbufloc;
250 int fbufloc2; 251 int fbufloc2;
251 252
278 fbufloc2 = fbufloc - m; 279 fbufloc2 = fbufloc - m;
279 tempAprx[n] += fbuf[fbufloc2] * m_lpd[m]; // approximation 280 tempAprx[n] += fbuf[fbufloc2] * m_lpd[m]; // approximation
280 tempDet += fbuf[fbufloc2] * m_hpd[m]; // detail 281 tempDet += fbuf[fbufloc2] * m_hpd[m]; // detail
281 } 282 }
282 283
283 if (m_absolute == 1) tempDet = fabs(tempDet); 284 aTempDet = fabs(tempDet);
285 if (m_absolute == 1) tempDet = aTempDet;
284 286
285 287
286 //if (tempDet < m_threshold) tempDet = 0; // simple hard thresholding, same for each scale 288 if (aTempDet < m_threshold) tempDet = 0; // simple hard thresholding, same for each scale
287 wCoefficients[scale].push_back(tempDet); 289 wCoefficients[scale].push_back(tempDet);
288 } 290 }
289 291
290 if (scale+1<m_scales) { // prepare variables for next scale 292 if (scale+1<m_scales) { // prepare variables for next scale
291 b = b >> 1; // the approximation in tmpfwd is stored as 293 b = b >> 1; // the approximation in tmpfwd is stored as
346 348
347 b = b_init; 349 b = b_init;
348 350
349 //------------------------------------------------------------------------------------------- 351 //-------------------------------------------------------------------------------------------
350 float tempDet; 352 float tempDet;
353 float aTempDet;
351 int outloc; 354 int outloc;
352 int halfblocksize = int(.5 * b); 355 int halfblocksize = int(.5 * b);
353 int fbufloc; 356 int fbufloc;
354 int fbufloc2; 357 int fbufloc2;
355 int len = m_flength; 358 int len = m_flength;
382 for (int m=0; m<len; ++m) { // Convolve the sample with filter coefficients 385 for (int m=0; m<len; ++m) { // Convolve the sample with filter coefficients
383 fbufloc2 = fbufloc - m; 386 fbufloc2 = fbufloc - m;
384 tempAprx[n] += fbuf[fbufloc2] * m_lpd[m]; // approximation 387 tempAprx[n] += fbuf[fbufloc2] * m_lpd[m]; // approximation
385 tempDet += fbuf[fbufloc2] * m_hpd[m]; // detail 388 tempDet += fbuf[fbufloc2] * m_hpd[m]; // detail
386 } 389 }
387 390
388 if (m_absolute == 1) tempDet = fabs(tempDet); 391 aTempDet = fabs(tempDet);
389 //if (tempDet < m_threshold) tempDet = 0; // simple hard thresholding, same for each scale 392 if (m_absolute == 1) tempDet = aTempDet;
393 if (aTempDet < m_threshold) tempDet = 0; // simple hard thresholding, same for each scale
390 wCoefficients[scale].push_back(tempDet); 394 wCoefficients[scale].push_back(tempDet);
391 } 395 }
392 396
393 if (scale+1<m_scales) { // prepare variables for next scale 397 if (scale+1<m_scales) { // prepare variables for next scale
394 b = b >> 1; // the approximation in tmpfwd is stored as 398 b = b >> 1; // the approximation in tmpfwd is stored as