Created
June 5, 2013 01:30
-
-
Save iskandr/5711019 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dilate_naive(x, k): | |
m,n = x.shape | |
y = np.empty_like(x) | |
for i in xrange(m): | |
for j in xrange(n): | |
currmax = x[i,j] | |
for ii in xrange(max(0, i-k/2), min(m, i+k/2+1)): | |
for jj in xrange(max(0, j-k/2), min(n, j+k/2+1)): | |
elt = x[ii,jj] | |
if elt > currmax: | |
currmax = elt | |
y[i,j] = currmax | |
return y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment