You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It would be better if there is an easier way for converting the data type of the image to NumPy's datatype.
currently, a workaround is np.dtype(img.array_interface["typestr"]).
Describe the solution you'd like
Will expose typestr property to the image object so np.dtype(img.typestr) is possible.
Additional context
This feature is necessary for interoperability with other libraries/frameworks.
The text was updated successfully, but these errors were encountered:
gigony
changed the title
[FEA] Expose typestr to CuImage object for converting data type of the image to numpy.dtype.
[FEA] Expose typestr to CuImage object for converting data type of the image to numpy.dtype
Mar 24, 2022
)
- Expose typestr property on CuImage object
- Expose DLDataType and DLDataTypeCode under cucim.clara
Without this patch,
DLDataType and DLDataTypecode can be accessible with the below workaround.
```python
>>> from cucim import CuImage
>>> a = CuImage("notebooks/input/image.tif")
>>> b = a.read_region((0,0), (10,10))
>>> import numpy as np
>>> np.dtype(b.__array_interface__["typestr"]) # b would expose `__cuda_array_interface__` if memory is in GPU.
dtype('uint8')
```
With this patch, we can convert data type to NumPy's dtype easily, and also can access cuCIM's DLDataType.
```python
>>> from cucim import CuImage
>>> a = CuImage("notebooks/input/image.tif")
>>> b = a.read_region((0,0), (10,10))
>>> import numpy as np
>>> b.typestr
'|u1'
>>> np.dtype(b.typestr) == np.uint8
True
>>> from cucim.clara import DLDataType, DLDataTypeCode
>>> b.dtype == DLDataType(DLDataTypeCode.DLUInt, 8, 1)
True
```
Fixes#243
Authors:
- Gigon Bae (https://github.com/gigony)
Approvers:
- https://github.com/jakirkham
URL: #246
Is your feature request related to a problem? Please describe.
It would be better if there is an easier way for converting the data type of the image to NumPy's datatype.
currently, a workaround is np.dtype(img.array_interface["typestr"]).
Describe the solution you'd like
Will expose typestr property to the image object so
np.dtype(img.typestr)
is possible.Additional context
This feature is necessary for interoperability with other libraries/frameworks.
The text was updated successfully, but these errors were encountered: