src/ImFilter.jl

changeset 22
4403f0445814
parent 18
0d99f8f7d261
child 29
05b11c96ef45
equal deleted inserted replaced
21:a9ea98043eb9 22:4403f0445814
11 11
12 ########## 12 ##########
13 # Exports 13 # Exports
14 ########## 14 ##########
15 15
16 export simple_imfilter 16 export simple_imfilter,
17 gaussian
17 18
18 ############## 19 ##############
19 # The routine 20 # The routine
20 ############## 21 ##############
21 22
52 end 53 end
53 54
54 return res 55 return res
55 end 56 end
56 57
58 ######################################################
59 # Distributions. Just to avoid the long load times of
60 # ImageFiltering and heavy dependencies on FFTW etc.
61 ######################################################
62
63 function gaussian(σ, n)
64 @assert(all(isodd.(n)))
65 a=convert.(Integer, @. (n-1)/2)
66 g=OffsetArray{Float64}(undef, [-m:m for m in a]...);
67 for i in CartesianIndices(g)
68 g[i]=exp(-sum(Tuple(i).^2 ./ (2 .* σ.^2)))
69 end
70 g./=sum(g)
71 end
72
57 end # Module 73 end # Module
58 74

mercurial