scikit-image / scikit-image

Image processing in Python
https://scikit-image.org
Other
6.06k stars 2.22k forks source link

SLIC very slow with win 10 #3026

Closed kwiechen closed 6 years ago

kwiechen commented 6 years ago

Description

SLIC is very slow with Winpython/Windows 10 but faster when using WSL/Windows 10

Winpython/Win10 log: image size 1421x998 pixel superpixel_size = 25 micrometer 72 pixel Windows-10-10.0.16299-SP0 ('64bit', 'WindowsPE') Python 3.5.4 scikit-image version 0.13.1 SLIC elapsed time 29.36 s

WSL/Win10 log: image size 1421x998 pixel superpixel_size = 25 micrometer 72 pixel Linux-4.4.0-43-Microsoft-x86_64-with-Ubuntu-16.04-xenial ('64bit', 'ELF') Python 3.5.2 scikit-image version 0.13.1 SLIC elapsed time 4.87 s

segments = slic(img_as_float(image), n_segments = numSegments, multichannel = True, convert2lab = True, slic_zero = True)

[If reporting a bug, attach the entire traceback from Python.] [If proposing an enhancement/new feature, provide links to related articles, reference examples, etc.]

Way to reproduce

[If reporting a bug, please include the following important information:]

soupault commented 6 years ago

@kwiechen Could you share the image you use to reproduce the behaviour?

kwiechen commented 6 years ago

@soupault: I have tried to attach - not possible for TIFF https://1drv.ms/u/s!AkA_lULl4S96g9U6o-8W__S1y923dQ

soupault commented 6 years ago

I personally don't know how Winpython is implemented, so the only thing I'd suggest is to try to update it to the latest version (and also the corresponding numpy and scipy installations).

In my Linux environment I have the performances similar to your WSL/Win10.

@scikit-image/core do we officially support this distribution?

kwiechen commented 6 years ago

I have used latest Winpython and retested with latest 64 bit Anaconda 3.6.4 Windows 10 - here SLIC runtime is approx. 32 s

cgohlke commented 6 years ago

I can reproduce the slowness on Windows. It is due to the use of the pow function in inner loops, e.g. at https://github.com/scikit-image/scikit-image/blob/master/skimage/segmentation/_slic.pyx#L135. Probably gcc optimized those function call away while msvc does not, or it could depend on the Cython version used. Replacing x**2 with x*x reduces slic runtime 10 times from 26s to 2.4s on my system.

cgohlke commented 6 years ago

Looks like _quickshift_cython might suffer from the same problem.

soupault commented 6 years ago

@cgohlke you might find this interesting also - https://github.com/scikit-image/scikit-image/issues/2657

cgohlke commented 6 years ago

Any **2 used in inner loops is a candidate for manual optimization. That includes radon_transform, hough_transform, quickshift, and denoising.

JDWarner commented 6 years ago

Wow. Unless there's any significant reason or performance issue with the alternative x*x, this one is a no-brainer.

cgohlke commented 6 years ago

I'm currently checking if this fixes any of #2657 ...

soupault commented 6 years ago

Closed via #3035 .

soupault commented 6 years ago

@cgohlke thank you very much to the investigation and the fix!

kwiechen commented 6 years ago

Thank you very much for the SLIC/Win10 run-time optimization. Do you plan to release v0.13.2 with this fix (and maybe with others like new parameter anti_aliasing in transform.resize)?

2018-04-28 10:38 GMT+02:00 Egor Panfilov notifications@github.com:

@cgohlke https://github.com/cgohlke thank you very much to the investigation and the fix!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/scikit-image/scikit-image/issues/3026#issuecomment-385153414, or mute the thread https://github.com/notifications/unsubscribe-auth/AQ3sm6LVjN6Y_GXylu6dxdecSH8l70Ayks5ttCqegaJpZM4Tgb4r .

jni commented 6 years ago

@kwiechen we are very close to releasing 0.14. Please bear with us!