You could use the (fast :) ) discrete **wavelet transform**. The package wavethresh under R will do all the work. 
Anyway, I like the solution of @James because it is simple and seems to go straigh to the point.