mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-27 11:27:08 +08:00
Merge pull request #307 from kuantkid/inlinedisplay
FIX issue #263: Inline display for binary image (range problem when converted from bool type)
This commit is contained in:
@@ -150,8 +150,16 @@ def convert(image, dtype, force_copy=False, uniform=False):
|
||||
itemsize = dtypeobj.itemsize
|
||||
itemsize_in = dtypeobj_in.itemsize
|
||||
|
||||
if kind == 'b' or kind_in == 'b':
|
||||
if kind == 'b':
|
||||
# to binary image
|
||||
if kind_in in "fi":
|
||||
sign_loss()
|
||||
prec_loss()
|
||||
return dtype(image)
|
||||
|
||||
if kind_in == 'b':
|
||||
# from binary image, to float and to integer
|
||||
return dtype(image) * dtype(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