This commit is contained in:
Olivier Debeir
2012-10-18 10:21:34 +02:00
parent 53deddf5e0
commit ce0a609579
5 changed files with 40 additions and 21 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ cdef inline np.uint8_t is_in_mask(Py_ssize_t rows, Py_ssize_t cols, Py_ssize_t r
cdef inline _core16(
np.uint16_t kernel(Py_ssize_t *, float, np.uint16_t, Py_ssize_t, Py_ssize_t, Py_ssize_t, float, float, Py_ssize_t, Py_ssize_t),
np.uint16_t kernel(Py_ssize_t * , float, np.uint16_t, Py_ssize_t, Py_ssize_t, Py_ssize_t, float, float, Py_ssize_t, Py_ssize_t),
np.ndarray[np.uint16_t, ndim=2] image,
np.ndarray[np.uint8_t, ndim=2] selem,
np.ndarray[np.uint8_t, ndim=2] mask,
+1 -1
View File
@@ -47,7 +47,7 @@ cdef inline np.uint8_t is_in_mask(Py_ssize_t rows, Py_ssize_t cols, Py_ssize_t r
return 0
cdef inline _core8(
np.uint8_t kernel(Py_ssize_t * , float, np.uint8_t, float, float, Py_ssize_t, Py_ssize_t),
np.uint8_t kernel(Py_ssize_t *, float, np.uint8_t, float, float, Py_ssize_t, Py_ssize_t),
np.ndarray[np.uint8_t, ndim=2] image,
np.ndarray[np.uint8_t, ndim=2] selem,
np.ndarray[np.uint8_t, ndim=2] mask,
+6 -3
View File
@@ -45,7 +45,8 @@ def _apply(func8, func16, image, selem, out, mask, shift_x, shift_y, s0, s1):
bitdepth = find_bitdepth(image)
if bitdepth > 11:
raise ValueError("only uint16 <4096 image (12bit) supported!")
return func16(image, selem, shift_x=shift_x, shift_y=shift_y, mask=mask, bitdepth=bitdepth + 1, out=out,
return func16(
image, selem, shift_x=shift_x, shift_y=shift_y, mask=mask, bitdepth=bitdepth + 1, out=out,
s0=s0, s1=s1)
@@ -110,7 +111,8 @@ def bilateral_mean(image, selem, out=None, mask=None, shift_x=False, shift_y=Fal
"""
return _apply(None, _crank16_bilateral.mean, image, selem, out=out, mask=mask, shift_x=shift_x, shift_y=shift_y,
return _apply(
None, _crank16_bilateral.mean, image, selem, out=out, mask=mask, shift_x=shift_x, shift_y=shift_y,
s0=s0, s1=s1)
@@ -175,7 +177,8 @@ def bilateral_pop(image, selem, out=None, mask=None, shift_x=False, shift_y=Fals
"""
return _apply(None, _crank16_bilateral.pop, image, selem, out=out, mask=mask, shift_x=shift_x, shift_y=shift_y,
return _apply(
None, _crank16_bilateral.pop, image, selem, out=out, mask=mask, shift_x=shift_x, shift_y=shift_y,
s0=s0, s1=s1)
if __name__ == "__main__":
+18 -9
View File
@@ -35,7 +35,8 @@ def _apply(func8, func16, image, selem, out, mask, shift_x, shift_y, p0, p1):
bitdepth = find_bitdepth(image)
if bitdepth > 11:
raise ValueError("only uint16 <4096 image (12bit) supported!")
return func16(image, selem, shift_x=shift_x, shift_y=shift_y, mask=mask, bitdepth=bitdepth + 1, out=out,
return func16(
image, selem, shift_x=shift_x, shift_y=shift_y, mask=mask, bitdepth=bitdepth + 1, out=out,
p0=p0, p1=p1)
else:
raise TypeError("only uint8 and uint16 image supported!")
@@ -102,7 +103,8 @@ def percentile_autolevel(image, selem, out=None, mask=None, shift_x=False, shift
"""
return _apply(_crank8_percentiles.autolevel, _crank16_percentiles.autolevel, image, selem, out=out, mask=mask,
return _apply(
_crank8_percentiles.autolevel, _crank16_percentiles.autolevel, image, selem, out=out, mask=mask,
shift_x=shift_x, shift_y=shift_y, p0=p0, p1=p1)
@@ -167,7 +169,8 @@ def percentile_gradient(image, selem, out=None, mask=None, shift_x=False, shift_
"""
return _apply(_crank8_percentiles.gradient, _crank16_percentiles.gradient, image, selem, out=out, mask=mask,
return _apply(
_crank8_percentiles.gradient, _crank16_percentiles.gradient, image, selem, out=out, mask=mask,
shift_x=shift_x, shift_y=shift_y, p0=p0, p1=p1)
@@ -232,7 +235,8 @@ def percentile_mean(image, selem, out=None, mask=None, shift_x=False, shift_y=Fa
"""
return _apply(_crank8_percentiles.mean, _crank16_percentiles.mean, image, selem, out=out, mask=mask,
return _apply(
_crank8_percentiles.mean, _crank16_percentiles.mean, image, selem, out=out, mask=mask,
shift_x=shift_x, shift_y=shift_y, p0=p0, p1=p1)
@@ -297,7 +301,8 @@ def percentile_mean_substraction(image, selem, out=None, mask=None, shift_x=Fals
"""
return _apply(_crank8_percentiles.mean_substraction, _crank16_percentiles.mean_substraction, image, selem, out=out,
return _apply(
_crank8_percentiles.mean_substraction, _crank16_percentiles.mean_substraction, image, selem, out=out,
mask=mask, shift_x=shift_x, shift_y=shift_y, p0=p0, p1=p1)
@@ -362,7 +367,8 @@ def percentile_morph_contr_enh(image, selem, out=None, mask=None, shift_x=False,
"""
return _apply(_crank8_percentiles.morph_contr_enh, _crank16_percentiles.morph_contr_enh, image, selem, out=out,
return _apply(
_crank8_percentiles.morph_contr_enh, _crank16_percentiles.morph_contr_enh, image, selem, out=out,
mask=mask, shift_x=shift_x, shift_y=shift_y, p0=p0, p1=p1)
@@ -428,7 +434,8 @@ def percentile(image, selem, out=None, mask=None, shift_x=False, shift_y=False,
"""
return _apply(_crank8_percentiles.percentile, _crank16_percentiles.percentile, image, selem, out=out, mask=mask,
return _apply(
_crank8_percentiles.percentile, _crank16_percentiles.percentile, image, selem, out=out, mask=mask,
shift_x=shift_x, shift_y=shift_y, p0=p0, p1=p1)
@@ -493,7 +500,8 @@ def percentile_pop(image, selem, out=None, mask=None, shift_x=False, shift_y=Fal
"""
return _apply(_crank8_percentiles.pop, _crank16_percentiles.pop, image, selem, out=out, mask=mask, shift_x=shift_x,
return _apply(
_crank8_percentiles.pop, _crank16_percentiles.pop, image, selem, out=out, mask=mask, shift_x=shift_x,
shift_y=shift_y, p0=p0, p1=p1)
@@ -559,7 +567,8 @@ def percentile_threshold(image, selem, out=None, mask=None, shift_x=False, shift
"""
return _apply(_crank8_percentiles.threshold, _crank16_percentiles.threshold, image, selem, out=out, mask=mask,
return _apply(
_crank8_percentiles.threshold, _crank16_percentiles.threshold, image, selem, out=out, mask=mask,
shift_x=shift_x, shift_y=shift_y, p0=p0, p1=p1)
+14 -7
View File
@@ -96,7 +96,8 @@ def autolevel(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
"""
return _apply(_crank8.autolevel, _crank16.autolevel, image, selem, out=out, mask=mask, shift_x=shift_x,
return _apply(
_crank8.autolevel, _crank16.autolevel, image, selem, out=out, mask=mask, shift_x=shift_x,
shift_y=shift_y)
@@ -158,7 +159,8 @@ def bottomhat(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
[ 0, 0, 0, 0, 0]], dtype=uint16)
"""
return _apply(_crank8.bottomhat, _crank16.bottomhat, image, selem, out=out, mask=mask, shift_x=shift_x,
return _apply(
_crank8.bottomhat, _crank16.bottomhat, image, selem, out=out, mask=mask, shift_x=shift_x,
shift_y=shift_y)
@@ -220,7 +222,8 @@ def equalize(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
[3071, 2730, 2047, 2730, 3071]], dtype=uint16)
"""
return _apply(_crank8.equalize, _crank16.equalize, image, selem, out=out, mask=mask, shift_x=shift_x,
return _apply(
_crank8.equalize, _crank16.equalize, image, selem, out=out, mask=mask, shift_x=shift_x,
shift_y=shift_y)
@@ -283,7 +286,8 @@ def gradient(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
"""
return _apply(_crank8.gradient, _crank16.gradient, image, selem, out=out, mask=mask, shift_x=shift_x,
return _apply(
_crank8.gradient, _crank16.gradient, image, selem, out=out, mask=mask, shift_x=shift_x,
shift_y=shift_y)
@@ -470,7 +474,8 @@ def meansubstraction(image, selem, out=None, mask=None, shift_x=False, shift_y=F
"""
return _apply(_crank8.meansubstraction, _crank16.meansubstraction, image, selem, out=out, mask=mask,
return _apply(
_crank8.meansubstraction, _crank16.meansubstraction, image, selem, out=out, mask=mask,
shift_x=shift_x, shift_y=shift_y)
@@ -721,7 +726,8 @@ def morph_contr_enh(image, selem, out=None, mask=None, shift_x=False, shift_y=Fa
"""
return _apply(_crank8.morph_contr_enh, _crank16.morph_contr_enh, image, selem, out=out, mask=mask, shift_x=shift_x,
return _apply(
_crank8.morph_contr_enh, _crank16.morph_contr_enh, image, selem, out=out, mask=mask, shift_x=shift_x,
shift_y=shift_y)
@@ -847,7 +853,8 @@ def threshold(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
"""
return _apply(_crank8.threshold, _crank16.threshold, image, selem, out=out, mask=mask, shift_x=shift_x,
return _apply(
_crank8.threshold, _crank16.threshold, image, selem, out=out, mask=mask, shift_x=shift_x,
shift_y=shift_y)