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(:));
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(:));