Advertisement
Guest User

Untitled

a guest
Apr 27th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.60 KB | None | 0 0
  1. function disk(radius)
  2.     x = collect(-radius:radius)
  3.     y = x'
  4.    d = Int.((x .^ 2 .+ y .^2)  .<= radius ^ 2)
  5. end
  6.  
  7. function custom_filter(buf)
  8.    radius = 5
  9.    d = disk(radius)
  10.    values = buf[d .== 1]
  11.    
  12.    buf = centered(buf)
  13.    mid = buf[0, 0]
  14.    G = sum(values .>= mid) - 1
  15.    S = sum(values .< mid)
  16.    N = length(values) - 1
  17.    return (G - S) / N
  18. end
  19.  
  20. function min_max(img, mask)
  21.    img = maximum(img) - img
  22.    filtered = imfilter(img, Kernel.gaussian(2))
  23.    filtered[mask .== 0] = 0
  24.    mm = mapwindow(custom_filter, filtered, (11,11), Fill(0))
  25.    return mm
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement