Skip to content

Use NumPy bit packing for Fit2D masks - #686

Merged
kif merged 1 commit into
silx-kit:mainfrom
CAOShurong:216_numpy_mask
Nov 16, 2026
Merged

kif merged 1 commit into
silx-kit:mainfrom
CAOShurong:216_numpy_mask

Conversation

@CAOShurong

Copy link
Copy Markdown
Contributor

Replace the per-bit loops with NumPy's packbits/unpackbits, preserving little-endian bit order, 32-bit row padding, and zero/nonzero mask values. Add independent byte-level checks for padding, bit order, strided input, and compressed files.

On Windows/Python 3.13 with NumPy 2.5.4, a 2048×2048 mask reads about 10× faster and writes about 3.3× faster (14 interleaved samples per implementation, including file I/O, identical output bytes).

Closes #216.

@kif kif left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for the work done.

@kif
kif merged commit 10d45d3 into silx-kit:main Nov 16, 2026
7 checks passed
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.

Use numpy function to pack binary mask in fit2dmaskimage

2 participants