Skip to content

radon function accepts any data type and implicitly converts arrays to float #4130

Closed

Description

@rfezzani

Description

It is stipulated in the radon function doc that only float input arrays are supported but radon actually accepts any data type.

There is no explicit conversion of the array type in radon function code. This conversion is made implicitely in the cython _warp_cy function.

This is may be related to #3799 and impacts #4128

Way to reproduce

import numpy as np
from skimage.transform import radon

pixels = 128
xy = np.arange(-pixels / 2, pixels / 2) + 0.5
x, y = np.meshgrid(xy, xy)
image = x**2 + y**2 <= (pixels/4)**2  # array.dtype is bool
theta = np.linspace(0., 180., max(image.shape), endpoint=False)
radon(image, theta=theta)
radon(image.astype(np.uint8), theta=theta)
radon(image.astype(np.float32), theta=theta)
radon(image.astype(np.float64), theta=theta)

Version information

>>> from __future__ import print_function
>>> import sys; print(sys.version)
3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 21:52:21) 
[GCC 7.3.0]
>>> import platform; print(platform.platform())
Linux-4.15.0-58-generic-x86_64-with-debian-buster-sid
>>> import skimage; print("scikit-image version: {}".format(skimage.__version__))
scikit-image version: 0.15.0
>>> import numpy; print("numpy version: {}".format(numpy.__version__))
numpy version: 1.16.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions