add exhaustive comparison between 8bit and 16bit filters

This commit is contained in:
Olivier Debeir
2012-10-11 12:03:34 +02:00
parent 90351170d7
commit 42feb70a31
2 changed files with 24 additions and 1 deletions
+5 -1
View File
@@ -1019,4 +1019,8 @@ def tophat(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
raise ValueError("only uint16 <4096 image (12bit) supported!")
return _crank16.tophat(image,selem,shift_x=shift_x,shift_y=shift_y,mask=mask,bitdepth=bitdepth+1,out=out)
else:
raise TypeError("only uint8 and uint16 image supported!")
raise TypeError("only uint8 and uint16 image supported!")
if __name__ == "__main__":
import doctest
doctest.testmod(verbose=True)
+19
View File
@@ -104,6 +104,25 @@ class TestSequenceFunctions(unittest.TestCase):
assert (loc_autolevel==loc_perc_autolevel).all()
def test_compare_8bit_vs_16bit(self):
# filters applied on 8bit image ore 16bit image (having only real 8bit of dynamic) should be identical
i8 = data.camera()
i16 = i8.astype(np.uint16)
methods = ['autolevel','bottomhat','equalize','gradient','maximum','mean'
,'meansubstraction','median','minimum','modal','morph_contr_enh','pop','threshold', 'tophat']
for method in methods:
func = eval('rank.%s'%method)
print func
f8 = func(i8,disk(3))
f16 = func(i16,disk(3))
# if (f8==f16).all() is False:
if not (f8==f16).all():
print f8
print f16
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestSequenceFunctions)