FIX convert to (unsigned) integer from bool type

This commit is contained in:
kuantkid
2012-09-09 23:20:21 +08:00
parent af0a866591
commit 38f0ca3dbc
+10 -1
View File
@@ -150,8 +150,17 @@ 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
prec_loss()
return dtype(image)
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]
if kind in 'ui':
imin = np.iinfo(dtype).min