Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function disk(radius)
- x = collect(-radius:radius)
- y = x'
- d = Int.((x .^ 2 .+ y .^2) .<= radius ^ 2)
- end
- function custom_filter(buf)
- radius = 5
- d = disk(radius)
- values = buf[d .== 1]
- buf = centered(buf)
- mid = buf[0, 0]
- G = sum(values .>= mid) - 1
- S = sum(values .< mid)
- N = length(values) - 1
- return (G - S) / N
- end
- function min_max(img, mask)
- img = maximum(img) - img
- filtered = imfilter(img, Kernel.gaussian(2))
- filtered[mask .== 0] = 0
- mm = mapwindow(custom_filter, filtered, (11,11), Fill(0))
- return mm
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement