new file: surface_slice.py
[wrf-fire-matlab.git] / cycling / rlx_shp.m
bloba3db75d612b602dcc8ef06f3b6de36164e9547b4
1 function out_shp = rlx_shp(in_shp,alpha,patch_size)
2 %does some kind of relaxation scheme on shapes
3 % local average over sub-matrix determined by patch_size
4 % alpha \in [0,1] weight of average
6 min_t = min(in_shp(:));
7 a = in_shp;
8 beta = 1-alpha;
9 new_shp = in_shp;
10 [n,m] = size(in_shp);
11 %patch_size = 4;
12 for i = patch_size+1:n-patch_size
13     for j = patch_size+1:m-patch_size
14         %stencil of pts around a(i,j)
15         %a(i,j) = alpha*a(i,j)+beta/4*(a(i-1,j)+a(i+1,j)+a(i,j-1)+a(i,j+1));
16         %3x3 ring of pts aound a(i,J)
17         %a(i,j) = alpha*a(i,j)+beta*(mean(mean(a(i-1:i+1,j-1:j+1))));   
18         %new_shp(i,j) = alpha*a(i,j)+beta/4*(a(i-1,j)+a(i+1,j)+a(i,j-1)+a(i,j+1));
19         patch = a(i-patch_size:i+patch_size,j-patch_size:j+patch_size);
20         new_shp(i,j) = alpha*a(i,j)+beta*mean(patch(:));
21     end
22 end
23 a(a<min_t) = min_t;
24 out_shp = a;
25 end