changed name of array variable

This commit is contained in:
Johannes Schönberger
2012-04-27 10:06:36 +02:00
parent 59376a7c20
commit 13c716f5eb
+8 -8
View File
@@ -9,27 +9,27 @@ cimport cython
def _threshold_adaptive(np.ndarray[np.double_t, ndim=2] image, int block_size,
method, double offset, mode, param):
cdef int r, c
cdef np.ndarray[np.double_t, ndim=2] thres_image
cdef np.ndarray[np.double_t, ndim=2] thresh_image
if method == 'generic':
thres_image = scipy.ndimage.generic_filter(image, param, block_size,
thresh_image = scipy.ndimage.generic_filter(image, param, block_size,
mode=mode)
elif method == 'gaussian':
if param is None:
# automatically determine sigma which covers > 99% of distribution
sigma = (block_size - 1) / 6.0
thres_image = scipy.ndimage.gaussian_filter(image, sigma, mode=mode)
thresh_image = scipy.ndimage.gaussian_filter(image, sigma, mode=mode)
elif method == 'mean':
mask = 1. / block_size * np.ones((block_size,))
# separation of filters to speedup convolution
thres_image = scipy.ndimage.convolve1d(image, mask, axis=0, mode=mode)
thres_image = scipy.ndimage.convolve1d(thres_image, mask, axis=1,
thresh_image = scipy.ndimage.convolve1d(image, mask, axis=0, mode=mode)
thresh_image = scipy.ndimage.convolve1d(thresh_image, mask, axis=1,
mode=mode)
elif method == 'median':
thres_image = scipy.ndimage.median_filter(image, block_size, mode=mode)
thresh_image = scipy.ndimage.median_filter(image, block_size, mode=mode)
for r in range(image.shape[0]):
for c in range(image.shape[1]):
thres_image[r,c] = image[r,c] > (thres_image[r,c] - offset)
thresh_image[r,c] = image[r,c] > (thresh_image[r,c] - offset)
return thres_image.astype('bool')
return thresh_image.astype('bool')