Mercurial > hg > nimfks
comparison src/matlab/rot_kernel.m @ 0:c52bc3e8d3ad tip
user: boblsturm
branch 'default'
added README.md
added assets/.DS_Store
added assets/playButton.jpg
added assets/stopButton.png
added assets/swapButton.jpg
added data/.DS_Store
added data/fiveoctaves.mp3
added data/glock2.wav
added data/sinScale.mp3
added data/speech_female.mp3
added data/sweep.wav
added nimfks.m.lnk
added src/.DS_Store
added src/matlab/.DS_Store
added src/matlab/AnalysisCache.m
added src/matlab/CSS.m
added src/matlab/DataHash.m
added src/matlab/ExistsInCache.m
added src/matlab/KLDivCost.m
added src/matlab/LoadFromCache.m
added src/matlab/SA_B_NMF.m
added src/matlab/SaveInCache.m
added src/matlab/Sound.m
added src/matlab/SynthesisCache.m
added src/matlab/chromagram_E.m
added src/matlab/chromagram_IF.m
added src/matlab/chromagram_P.m
added src/matlab/chromsynth.m
added src/matlab/computeSTFTFeat.m
added src/matlab/controller.m
added src/matlab/decibelSliderReleaseCallback.m
added src/matlab/drawClickCallBack.m
added src/matlab/fft2chromamx.m
added src/matlab/hz2octs.m
added src/matlab/ifgram.m
added src/matlab/ifptrack.m
added src/matlab/istft.m
added src/matlab/nimfks.fig
added src/matlab/nimfks.m
added src/matlab/nmfFn.m
added src/matlab/nmf_beta.m
added src/matlab/nmf_divergence.m
added src/matlab/nmf_euclidean.m
added src/matlab/prune_corpus.m
added src/matlab/rot_kernel.m
added src/matlab/templateAdditionResynth.m
added src/matlab/templateDelCb.m
added src/matlab/templateScrollCb.m
author | boblsturm |
---|---|
date | Sun, 18 Jun 2017 06:26:13 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c52bc3e8d3ad |
---|---|
1 function [Y] = rot_kernel(kernel, deg) | |
2 | |
3 N = size( kernel, 1 ); | |
4 max_rots = 4*(N-1); | |
5 deg_per_rot = 360 / max_rots; | |
6 | |
7 % deg = deg - mod( deg, deg_per_rot ); | |
8 deg = deg_per_rot * ( round( deg / deg_per_rot ) ); | |
9 num_of_rots = ceil( deg / deg_per_rot ); | |
10 | |
11 if num_of_rots < 1 | |
12 Y = kernel; | |
13 return | |
14 else | |
15 for r = 1:num_of_rots | |
16 if mod( r, 2 ) == 0 | |
17 kernel = rot_outer_layer( kernel ); | |
18 else | |
19 kernel = rot_inner_layer( kernel ); | |
20 end | |
21 end | |
22 end | |
23 | |
24 Y = kernel; | |
25 | |
26 end | |
27 | |
28 function [Y] = rot_outer_layer( A ) | |
29 dim = size( A, 1 ); | |
30 top = A( 1, : ); | |
31 right = A( 2:dim, dim )'; | |
32 bottom = fliplr( A( dim, 1:dim - 1 ) ); | |
33 left = fliplr( A( 2:dim - 1, 1 )' ); | |
34 shifted_layers = wshift('1D',[top,right,bottom,left],-1); | |
35 | |
36 top = shifted_layers( 1:length(top)); | |
37 last_ind = length( top ); | |
38 | |
39 right = shifted_layers( last_ind + 1 : last_ind + length(right)); | |
40 last_ind = last_ind + length( right ); | |
41 | |
42 bottom = shifted_layers( last_ind + 1 : last_ind + length(bottom)); | |
43 last_ind = last_ind + length( bottom ); | |
44 | |
45 left = shifted_layers( last_ind + 1 : end ); | |
46 | |
47 A( 1, : ) = top; | |
48 A( 2:dim, dim ) = right'; | |
49 A( dim, 1:dim - 1 ) = fliplr( bottom ); | |
50 A( 2:dim - 1, 1 ) = fliplr( left' ); | |
51 | |
52 Y = A; | |
53 end | |
54 | |
55 function [Y] = rot_inner_layer( kernel ) | |
56 % dim = size( kernel, 1 ); | |
57 % if dim < 2 | |
58 % Y = rot_outer_layer( kernel ) | |
59 % return; | |
60 % else | |
61 % Y = rot_inner_layer( kernel( 2:dim - 1, 2:dim - 1 ) ) | |
62 % end | |
63 dim = size( kernel, 1 ); | |
64 | |
65 if mod( dim / 2, 2 ) == 0 | |
66 max_rots = dim / 2 - 1; | |
67 else | |
68 max_rots = dim / 2 - 0.5; | |
69 end | |
70 | |
71 low = 2; | |
72 high = dim - 1; | |
73 for i = 1:max_rots | |
74 kernel( low:high, low:high ) = rot_outer_layer( kernel( low:high, low:high ) ); | |
75 low = low + 1; | |
76 high = high - 1; | |
77 end | |
78 | |
79 Y = kernel; | |
80 end |