Skip to content

Add imgal to scikit-ops #4

Description

@elevans

Would you be interested in adding imgal to scikit-ops? We have some niche functions that I haven't seen elsewhere like a proper Spatially Adaptive Colocalization Analysis (SACA) 3D, primitive geometric operations (i.e. halfspace intersections, orientation predicates, etc...) and blob simulations. Imgal also has a complete set time domain image phasor analysis functions that can let users take raw data all the way to calibrated G/S image (IIRC scikit-image doesn't do phasor stuff).

I also think it's worth mentioning that imgal is generally faster than scikit-image / scipy. Here is a quick benchmark you can do with the source build of imgal where I've been adding compiler hints to help it autovectorize:

import numpy as np
import imgal
from scipy.spatial import ConvexHull
from skimage.filters import threshold_otsu
from skimage import exposure

# create a random image and point cloud
image = np.random.randint(0, 65536, (2048, 2048), dtype=np.uint16)
cloud = np.random.rand(100000, 3).astype(np.float32)

print("[INFO] --- HISTOGRAM BENCHMARKS ---")
print("[INFO]: NumPy")
%timeit np.bincount(image.ravel(), minlength=65536)
print("[INFO]: scikit-image")
%timeit exposure.histogram(image, nbins=65536)
print("[INFO]: imgal")
%timeit imgal.image.histogram(image, 65536, threads=1) # sequential compute
%timeit imgal.image.histogram(image, 65536, threads=0) # auto for all threads
print("[INFO] --- THRESHOLD BENCHMARKS ---")
print("[INFO]: scikit-image")
%timeit threshold_otsu(image, 65536)
print("[INFO]: imgal")
%timeit imgal.threshold.otsu_value(image, 65536, threads=1) # sequential compute
%timeit imgal.threshold.otsu_value(image, 65536, threads=0) # auto for all threads
print("[INFO] --- SPATIAL BENCHMARKS ---")
print("[INFO]: scipy")
%timeit ConvexHull(cloud)
print("[INFO]: imgal")
%timeit imgal.spatial.convex_hull.quickhull_3d(cloud)

On my system I get:

[INFO] --- HISTOGRAM BENCHMARKS ---
[INFO]: NumPy
9.45 ms ± 40.3 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
[INFO]: scikit-image
11.1 ms ± 39.4 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
[INFO]: imgal
6.94 ms ± 10.6 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
2.15 ms ± 17.7 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
[INFO] --- THRESHOLD BENCHMARKS ---
[INFO]: scikit-image
12.6 ms ± 54.9 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
[INFO]: imgal
7.67 ms ± 28.2 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
2.57 ms ± 46.3 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
[INFO] --- SPATIAL BENCHMARKS ---
[INFO]: scipy
14.9 ms ± 14.1 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
[INFO]: imgal
11.1 ms ± 131 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)

These speed boosts will be part of the 0.4.0 release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions