Skip to content

performance update raw python implementation#29

Open
wouterverweirder wants to merge 1 commit into
LingDong-:masterfrom
wouterverweirder:master
Open

performance update raw python implementation#29
wouterverweirder wants to merge 1 commit into
LingDong-:masterfrom
wouterverweirder:master

Conversation

@wouterverweirder
Copy link
Copy Markdown

I've been able to get a 20x performance update for the raw python implementation. (and 40x when using a caching mechanism).

  1. Added Numba JIT compilation (@jit(nopython=True)) to:
    • thinningZSIteration() - The most critical bottleneck with nested loops
    • chunkToFrags() - Another function with nested loops
  2. Fixed notEmpty() function - Changed from np.sum(im) > 0 to np.any(im[y:y+h, x:x+w]) which:
    • Properly slices the image region (the original version summed the entire image!)
    • Uses np.any() which is faster and more appropriate for boolean checks
  3. Replaced nested loops with NumPy slicing in traceSkeleton():
    • Horizontal seam search: np.sum(im[i-1:i+1, x:x+w]) instead of nested loop
    • Vertical seam search: np.sum(im[y:y+h, j-1:j+1]) instead of nested loop

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

Successfully merging this pull request may close these issues.

1 participant