mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-25 13:30:51 +08:00
This commit is contained in:
@@ -157,10 +157,7 @@ def convert(image, dtype, force_copy=False, uniform=False):
|
||||
|
||||
if kind_in == 'b':
|
||||
# from binary image, to float and to integer
|
||||
if kind == 'f':
|
||||
return dtype(image)
|
||||
elif kind in 'ui':
|
||||
return dtype(image) * dtype_range[dtype][1]
|
||||
return dtype(image) * dtype_range[dtype][1]
|
||||
|
||||
if kind in 'ui':
|
||||
imin = np.iinfo(dtype).min
|
||||
|
||||
@@ -93,12 +93,14 @@ def test_bool():
|
||||
img_[1, 1] = True
|
||||
img8[1, 1] = True
|
||||
funcs = (img_as_float, img_as_int, img_as_ubyte, img_as_uint, img_as_bool)
|
||||
for func in funcs:
|
||||
for (func, dt) in [(img_as_int, np.int16),
|
||||
(img_as_float, np.float64),
|
||||
(img_as_uint, np.uint16),
|
||||
(img_as_ubyte, np.ubyte)]:
|
||||
converted_ = func(img_)
|
||||
assert np.sum(converted_) == 1
|
||||
assert np.sum(converted_) == dtype_range[dt][1]
|
||||
converted8 = func(img8)
|
||||
assert np.sum(converted8) == 1
|
||||
|
||||
assert np.sum(converted8) == dtype_range[dt][1]
|
||||
|
||||
if __name__ == '__main__':
|
||||
np.testing.run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user