add full test

This commit is contained in:
Olivier Debeir
2012-10-29 18:07:47 +01:00
parent 8222a58ec8
commit c633fb8953
3 changed files with 65 additions and 90 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ from generic import find_bitdepth
import _crank16_bilateral
__all__ = ['bilateral_mean']
__all__ = ['bilateral_mean','bilateral_pop']
def bilateral_mean(image, selem, out=None, mask=None, shift_x=False, shift_y=False, s0=10, s1=10):
+2 -2
View File
@@ -13,8 +13,8 @@ from generic import find_bitdepth
import _crank16_percentiles,_crank8_percentiles
__all__ = ['percentile_autolevel','percentile_gradient',
'percentile_mean','percentile_mean_substraction','percentile_median',
'percentile_minimum','percentile_modal','percentile_morph_contr_enh','percentile_pop']
'percentile_mean','percentile_mean_substraction',
'percentile_morph_contr_enh','percentile_pop']
def percentile_autolevel(image, selem, out=None, mask=None, shift_x=False, shift_y=False, p0=.0, p1=1.):
"""Return greyscale local autolevel of an image.
+62 -87
View File
@@ -4,100 +4,75 @@ from pprint import pprint
from skimage import data
from skimage.morphology.selem import disk
from skimage.rank import _crank8,_crank8_percentiles
from skimage.rank import _crank16,_crank16_percentiles,_crank16_bilateral
import skimage.rank as rank
def plot_all():
a8 = data.camera()
a16 = a8.astype('uint16')*16
# selem = np.ones((30,30),dtype='uint8')
selem = disk(5)
name_list = sorted([n for n in dir(rank) if n[0] is not '_'])
print name_list
for n in dir(_crank16):
method = eval('_crank16.%s'%n)
t = type(method)
if t == type(_crank8.maximum):
print n,t
f = method(a16,selem = selem,bitdepth=12)
plt.figure()
plt.subplot(1,2,1)
plt.imshow(a16)
plt.colorbar()
plt.subplot(1,2,2)
plt.imshow(f)
plt.colorbar()
plt.title(method)
for n in dir(_crank8):
method = eval('_crank8.%s'%n)
t = type(method)
if t == type(_crank8.maximum):
print n,t
f = method(a8,selem = selem)
plt.figure()
plt.subplot(1,2,1)
plt.imshow(a8)
plt.colorbar()
plt.subplot(1,2,2)
plt.imshow(f)
plt.colorbar()
plt.title(method)
for n in dir(_crank8_percentiles):
method = eval('_crank8_percentiles.%s'%n)
t = type(method)
if t == type(_crank8.maximum):
print n,t
f = method(a8,selem = selem,p0=.1,p1=.9)
plt.figure()
plt.subplot(1,2,1)
plt.imshow(a8)
plt.colorbar()
plt.subplot(1,2,2)
plt.imshow(f)
plt.colorbar()
plt.title(method)
for n in dir(_crank16_percentiles):
method = eval('_crank16_percentiles.%s'%n)
t = type(method)
if t == type(_crank8.maximum):
print n,t
f = method(a16,selem = selem,bitdepth=12,p0=.1,p1=.9)
plt.figure()
plt.subplot(1,2,1)
plt.imshow(a16)
plt.colorbar()
plt.subplot(1,2,2)
plt.imshow(f)
plt.colorbar()
plt.title(method)
selem = disk(50)
for n in dir(_crank16_bilateral):
method = eval('_crank16_bilateral.%s'%n)
t = type(method)
if t == type(_crank8.maximum):
print n,t
f = method(a16,selem = selem,bitdepth=12,s0=300,s1=300)
plt.figure()
plt.subplot(1,2,1)
plt.imshow(a16)
plt.colorbar()
plt.subplot(1,2,2)
plt.imshow(f)
plt.colorbar()
plt.title(method)
#
for n in name_list:
if n.rfind('bilateral')==0:
print n
method = eval('rank.%s'%n)
if type(method) == type(rank.maximum):
print method
f8 = method(a8,selem = selem,s0=10,s1=10)
f16 = method(a16,selem = selem,s0=10,s1=10)
plt.figure()
plt.subplot(2,2,1)
plt.imshow(a8)
plt.colorbar()
plt.subplot(2,2,2)
plt.imshow(f8)
plt.colorbar()
plt.subplot(2,2,3)
plt.imshow(f16)
plt.colorbar()
plt.title(method)
for n in name_list:
if n.rfind('percentile')==0:
print n
method = eval('rank.%s'%n)
if type(method) == type(rank.maximum):
print method
f8 = method(a8,selem = selem,p0=.1,p1=.9)
f16 = method(a16,selem = selem,p0=.1,p1=.9)
plt.figure()
plt.subplot(2,2,1)
plt.imshow(a8)
plt.colorbar()
plt.subplot(2,2,2)
plt.imshow(f8)
plt.colorbar()
plt.subplot(2,2,3)
plt.imshow(f16)
plt.colorbar()
plt.title(method)
for n in name_list:
if n.find('percentile')==-1 and n.find('bilateral')==-1:
print n
method = eval('rank.%s'%n)
if type(method) == type(rank.maximum):
print method
f8 = method(a8,selem = selem)
f16 = method(a16,selem = selem)
plt.figure()
plt.subplot(2,2,1)
plt.imshow(a8)
plt.colorbar()
plt.subplot(2,2,2)
plt.imshow(f8)
plt.colorbar()
plt.subplot(2,2,3)
plt.imshow(f16)
plt.colorbar()
plt.title(method)
plt.show()
if __name__ == '__main__':
# plot_all()
pprint(dir(_crank8))
plot_all()
pprint(dir(rank))