Hit the send button too soon:
Just FYI; the level value here is completely arbitrary; the 4 is not
associated in any way with the fact that I picked the 'db4' mother
wavelet; 1,2,3,5,6, etc, are equally valid. Or you could use (4;'db6').
wavelets =. (4;'db4')dwtL yvals
-SL
On 10/27/2014 08:45 PM, Scott Locklin wrote:
My apologies guys: I should have included the other bits, but I
thought something might pop out immediately, and I didn't want to spam
up the list with lots of code. Adverbs and conjunctions, I am still a
bit intimidated by; wouldn't have thought of that. FWIIW, I have to
think about higher dimensions: I think you'd need different verbs for
images. For images, you'll almost certainly want to use "max overlap
DWT" which takes arbitrary size inputs.
Interesting, small use case (the output may or may not be informative,
but it is correct):
yvals =. ((0 1 2 _1 #~ 4 %~ ]) + (1 o. i.) + 1 o. (o. 1) %~ i.) 256
NB. this number must be 2^N
wavelets =. (4;'db4')dwtL yvals
dwtL=: 4 : 0
'lev k'=.x
'yn wn'=. k&dwt y
wn; (((<:lev);k)&dwtL^:(lev>1) yn)
)
Here is what I have for dwt:
oddx=: ] {~ ([: (] #~ 0 1 $~ #) [: i. [: # ]) -/ [: i. [: # [
dwt=: 4 : 0
'hpf lpf'=.wdict x
yvals=. hpf&oddx y
(yvals +/ . * lpf);(yvals +/ . * hpf)
)
wdict is a bunch of constants for the different kinds of wavelets,
which I will abbreviate to just the Daubechies wavelets:
NB. get the high pass from the low pass, return a box list of both
HpLp =: ] ;~ |. * _1 ^ [: i. #
wdict=: 3 : 0
select. y
case. 'db4' do.
HpLp 0.482962913144534, 0.836516303737808, 0.224143868042013,
_0.12940952255126
case. 'db6' do.
HpLp 0.332670552950083, 0.806891509311093, 0.459877502118491,
_0.135011020010255, _0.0854412738820267, 0.0352262918857096
case. 'db8' do.
HpLp 0.230377813307443, 0.714846570548406, 0.630880767935879,
_0.0279837694166834, _0.187034811717913, 0.0308413818353661,
0.0328830116666778, _0.0105974017850021
case. 'db16' do.
HpLp 0.0544158422431049, 0.312871590914303, 0.67563073629729,
0.585354683654191, _0.0158291052563816, _0.28401554296157,
0.0004724845739124, 0.128747426620484, _0.0173693010018083,
_0.0440882539307952, 0.0139810279173995, 0.0087460940474061,
_0.0048703529934518, _0.000391740373377, 0.0006754494064506,
_0.0001174767841248
end.
)
>It's indeed difficult to suggest things if we can not try it out.
Conceptually, I'd say things which don't change in one invocation
are prime
candidates for being changed into adverb arguments.
Eg. fixing thewavelet type as "u" would eliminate the need for boxes in
the left argument, something along the lines of:
dwtL2=: 1 : 0
'yn wn'=. u&dwt y
wn; ((<:x)&dwtL2^:(x>1) yn)
)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm