scikit-image's morphological operations seem to be a bit slower.
Here are the test results
import cv2
from scipy import ndimage
import numpy as np
from skimage import data, morphology, transform, filter
coins = data.coins()
coins_10_12 = (255*transform.resize(coins, (1000, 1200))).astype("uint8")
kernel = np.ones((3, 3)).astype("uint8")
kernel50 = np.ones((50, 50)).astype("uint8")
For image size=(303, 384) and kernel size (read: structuring element) (3,3)
%timeit cv2.dilate(coins, kernel)
%timeit ndimage.grey_dilation(coins, footprint=kernel)
%timeit morphology.dilation(coins, kernel)
10000 loops, best of 3: 123 µs per loop
100 loops, best of 3: 7.67 ms per loop
100 loops, best of 3: 12.3 ms per loop
For image size=(1000, 1200) and kernel size=(3,3)
%timeit cv2.dilate(coins_10_12, kernel)
%timeit ndimage.grey_dilation(coins_10_12, footprint=kernel)
%timeit morphology.dilation(coins_10_12, kernel)
100 loops, best of 3: 2.04 ms per loop
10 loops, best of 3: 78.4 ms per loop
10 loops, best of 3: 123 ms per loop
For image size=(1000, 1200) and kernel size=(3,3)
%timeit cv2.morphologyEx(coins_10_12, cv2.MORPH_OPEN, kernel)
%timeit ndimage.grey_opening(coins_10_12, footprint=kernel)
%timeit morphology.opening(coins_10_12, kernel)
100 loops, best of 3: 4.17 ms per loop
10 loops, best of 3: 157 ms per loop
1 loops, best of 3: 304 ms per loop
For image size=(1000, 1200) and kernel size=(50,50)
%timeit cv2.dilate(coins_10_12, kernel50)
%timeit ndimage.grey_dilation(coins_10_12, footprint=kernel50)
%timeit morphology.dilation(coins_10_12, kernel50)
100 loops, best of 3: 10.8 ms per loop
1 loops, best of 3: 665 ms per loop
1 loops, best of 3: 33 s per loop
For image size=(303, 384) and kernel size=(50,50)
%timeit cv2.dilate(coins, kernel50)
%timeit ndimage.grey_dilation(coins, footprint=kernel50)
%timeit morphology.dilation(coins, kernel50)
1000 loops, best of 3: 815 µs per loop
10 loops, best of 3: 72.1 ms per loop
1 loops, best of 3: 3.32 s per loop
Update
%timeit filter.rank.maximum(coins, kernel)
%timeit filter.rank.maximum(coins, kernel50)
%timeit filter.rank.maximum(coins_10_12, kernel)
%timeit filter.rank.maximum(coins_10_12, kernel50)
10 loops, best of 3: 50.8 ms per loop
1 loops, best of 3: 219 ms per loop
1 loops, best of 3: 498 ms per loop
1 loops, best of 3: 2.5 s per loop
- scipy's morphological operators are faster than skimage's.
- skimage's operators get slower with increasing structuring element size? (or I've missed something?)
Are bigger structuring elements causing the speed issues in this specific case? Or is it time to speed up the base operators to catch-up scipy's performance?
P.S: opencv is mentioned only for performance base with no intentions to make a comparison between oranges and apples. And, thanks for the skimage library, have just started using it.
scikit-image's morphological operations seem to be a bit slower.
Here are the test results
For image size=(303, 384) and kernel size (read: structuring element) (3,3)
For image size=(1000, 1200) and kernel size=(3,3)
For image size=(1000, 1200) and kernel size=(3,3)
For image size=(1000, 1200) and kernel size=(50,50)
For image size=(303, 384) and kernel size=(50,50)
Update
Are bigger structuring elements causing the speed issues in this specific case? Or is it time to speed up the base operators to catch-up scipy's performance?
P.S: opencv is mentioned only for performance base with no intentions to make a comparison between oranges and apples. And, thanks for the skimage library, have just started using it.