Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where is the warp api of python but not the 'fast_warp' of cython? #5248

Closed
Joevaen opened this issue Feb 24, 2021 · 3 comments
Closed

Where is the warp api of python but not the 'fast_warp' of cython? #5248

Joevaen opened this issue Feb 24, 2021 · 3 comments

Comments

@Joevaen
Copy link

Joevaen commented Feb 24, 2021

Description

The 'fast_warps' api is here. It is based on Cython.I want to know where is the old python 'warp' api?
image
Is it here?
image

Way to reproduce

# Place the full code we need to recreate your issue here
# upload all necessary images to github too!

Version information

# Paste the output of the following python commands
from __future__ import print_function
import sys; print(sys.version)
import platform; print(platform.platform())
import skimage; print("scikit-image version: {}".format(skimage.__version__))
import numpy; print("numpy version: {}".format(numpy.__version__))
# your output here
3.7.6 (default, Jan  8 2020, 19:59:22) 
[GCC 7.3.0]
Linux-5.4.0-65-generic-x86_64-with-debian-buster-sid
scikit-image version: 0.17.2
numpy version: 1.19.2
@jni
Copy link
Member

jni commented Feb 24, 2021

@Joevaen I don't really understand your question? Here is our documentation for skimage.transform.warp, which is what I think you're after:

https://scikit-image.org/docs/stable/api/skimage.transform.html#skimage.transform.warp

It hasn't changed places in about a decade so I don't know where the confusion is! 😅

I'm going to close this issue as I don't think it's a code issue, but please feel free to continue the discussion if you need further clarification!

@jni jni closed this as completed Feb 24, 2021
@Joevaen
Copy link
Author

Joevaen commented Feb 24, 2021

Sorry about not describe my question clearly.
I notice there is two file about warp in scikit-image/skimage/transform/. Usually, some projects like to using the _warps_cy.pyx because it is based on Cython and it is faster. Am I right?
But it is not enough quickly for me, so I want to try to modify the python 'warp' which doesn't use Cython. Maybe Cupy taking place of Numpy will be better option to speed it up. I just wanna try.
In the _warps_cy.pyx, there is api named _warp_fast like below:
image
Does it correspond to the api named warpin _warps.py like below:
image
if they have same input image, do they have same output?
Thank for your kindness!
Best,
Joevaen.

@jni
Copy link
Member

jni commented Feb 24, 2021

Yes, under certain circumstances, they are the same. You can see that the _warp_fast Cython function is imported into Python in this line:

from ._warps_cy import _warp_fast

And then warp calls _warp_fast here:

if matrix is not None:
matrix = matrix.astype(image.dtype)
ctype = 'float32_t' if image.dtype == np.float32 else 'float64_t'
if image.ndim == 2:
warped = _warp_fast[ctype](image, matrix,
output_shape=output_shape,
order=order, mode=mode, cval=cval)
elif image.ndim == 3:
dims = []
for dim in range(image.shape[2]):
dims.append(_warp_fast[ctype](image[..., dim], matrix,
output_shape=output_shape,
order=order, mode=mode,
cval=cval))

This is used when the transform is linear and the interpolation is of order 0, 1, or 3. If those conditions aren't met, then a slower path is taken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants