Skip to content

Instantly share code, notes, and snippets.

@tejus-gupta
Created July 9, 2017 17:34
Show Gist options
  • Save tejus-gupta/e391cbdd7dea1320be64c38ad16285f8 to your computer and use it in GitHub Desktop.
Save tejus-gupta/e391cbdd7dea1320be64c38ad16285f8 to your computer and use it in GitHub Desktop.
function median_filter{T, N}(img::AbstractArray{T, N}, window::NTuple{N, Int})
all(isodd(w) for w in window) || error("entries in window must be odd, got $window")
R = CartesianRange(size(img))
half_window = map(w->w>>1, window)
Rinner = CartesianRange(first(R)+CartesianIndex(half_window), last(R)-CartesianIndex(half_window))
for i in Rinner
if i[1] = first(Rinner)[1]
#reinitialize histogram
end
#update elements and calculate new median
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment