Return a float64 image in [-1.0, 1.0]. Parameters ---------- kwargs: To be passed to skimage.io.imread.
(path, as_gray=False, **kwargs)
| 5 | |
| 6 | |
| 7 | def imread(path, as_gray=False, **kwargs): |
| 8 | """Return a float64 image in [-1.0, 1.0]. |
| 9 | |
| 10 | Parameters |
| 11 | ---------- |
| 12 | kwargs: |
| 13 | To be passed to skimage.io.imread. |
| 14 | |
| 15 | """ |
| 16 | image = iio.imread(path, as_gray, **kwargs) |
| 17 | if image.dtype == np.uint8: |
| 18 | image = image / 127.5 - 1 |
| 19 | elif image.dtype == np.uint16: |
| 20 | image = image / 32767.5 - 1 |
| 21 | elif image.dtype in [np.float32, np.float64]: |
| 22 | image = image * 2 - 1.0 |
| 23 | else: |
| 24 | raise Exception("Invalid image dtype: %s!" % image.dtype) |
| 25 | return image.astype(np.float64) |
| 26 | |
| 27 | |
| 28 | def imwrite(image, path, quality=95, **plugin_args): |