mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-29 16:16:07 +08:00
add exhaustive comparison between 8bit and 16bit filters
This commit is contained in:
@@ -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)
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user