Morphological image processing for 3D multi-label images.
Project description
fastmorph: multilabel 3D morphological image processing functions.
This is a collection of morphological 3D image operations that are tuned for working with dense 3D labeled images.
We provide the following multithreaded operations:
- Multi-Label Stenciled Dilation, Erosion, Opening, Closing
- Multi-Label Spherical Erosion
- Binary Spherical Dilation, Opening, and Closing
- Multi-Label Fill Voids
Highlights compared to other libraries:
- Handles multi-labeled images
- Multithreaded
- High performance single-threaded
- Low memory usage
- Dilate computes mode of surrounding labels
Disadvantages versus other libraries:
- Not ideal for grayscale images
- Stencil (structuring element) is fixed size 3x3x3 and all on.
import fastmorph
# may be binary or unsigned integer 2D or 3D image
labels = np.load("my_labels.npy")
# multi-label capable morphological operators
# they use a 3x3x3 all on structuring element
# dilate picks the mode of surrounding labels
# by default only background (0) labels are filled
morphed = fastmorph.dilate(labels, parallel=2)
# processes every voxel
morphed = fastmorph.dilate(labels, background_only=False, parallel=2)
morphed = fastmorph.erode(labels)
morphed = fastmorph.opening(labels, parallel=2)
morphed = fastmorph.closing(labels, parallel=2)
# Dilate only supports binary images at this time.
# Radius is specified in physical units, but
# by default anisotropy = (1,1,1) so it is the
# same as voxels.
morphed = fastmorph.spherical_dilate(labels, radius=1, parallel=2, anisotropy=(1,1,1))
# open and close require dialate to work and so are binary only for now
morphed = fastmorph.spherical_open(labels, radius=1, parallel=2, anisotropy=(1,1,1))
morphed = fastmorph.spherical_close(labels, radius=1, parallel=2, anisotropy=(1,1,1))
# The rest support multilabel images.
morphed = fastmorph.spherical_erode(labels, radius=1, parallel=2, anisotropy=(1,1,1))
# Note: for boolean images, this function will directly call fill_voids
# and return a scalar for ct
# For integer images, more processing will be done to deal with multiple labels.
# A dict of { label: num_voxels_filled } for integer images will be returned.
# Note that for multilabel images, by default, if a label is totally enclosed by another,
# a FillError will be raised. If remove_enclosed is True, the label will be overwritten.
filled_labels, ct = fastmorph.fill_holes(labels, return_fill_count=True, remove_enclosed=False)
Performance
A test run on an M1 Macbook Pro on connectomics.npy.ckl
, a 5123 volume with over 2000 dense labels had the following results.
erode / 1 thread: 1.977 sec
erode / 2 threads: 1.104 sec
erode / 4 threads: 0.831 sec
dilate / background_only=True / 1 thread: 1.078 sec
dilate / background_only=True / 2 threads: 0.637 sec
dilate / background_only=True / 4 threads: 0.456 sec
dilate / background_only=False / 1 thread: 14.597 sec
dilate / background_only=False / 2 threads: 7.394 sec
dilate / background_only=False / 4 threads: 4.983 sec
dilate / background_only=False / 8 threads: 4.105 sec
scipy grey_dilation / 1 thread 14.648 sec
scipy grey_erode / 1 thread: 14.412 sec
skimage expand_labels / 1 thread: 62.248 sec
Here is the performance on a completely zeroed 5123 volume:
erode / 1 thread: 0.462 sec
erode / 2 threads: 0.270 sec
erode / 4 threads: 0.245 sec
dilate / background_only=True / 1 thread: 4.752 sec
dilate / background_only=True / 2 threads: 2.530 sec
dilate / background_only=True / 4 threads: 1.717 sec
dilate / background_only=False / 1 thread: 4.572 sec
dilate / background_only=False / 2 threads: 2.419 sec
dilate / background_only=False / 4 threads: 1.493 sec
dilate / background_only=False / 8 threads: 1.201 sec
scipy grey_dilation / 1 thread 10.508 sec
scipy grey_erode / 1 thread: 10.650 sec
skimage expand_labels / 1 thread: 33.353 sec
Memory Profiles
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fastmorph-1.0.2.tar.gz
(23.6 kB
view hashes)
Built Distributions
fastmorph-1.0.2-cp311-cp311-win32.whl
(100.0 kB
view hashes)
Close
Hashes for fastmorph-1.0.2-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c944d683cfd7a3ca43f40bb5fa4627527828b467a7aa70b0c355080aac92ca9 |
|
MD5 | 8c4148e72abd18efb4167bd18c5d28fc |
|
BLAKE2b-256 | 2d5afd2066d4b3c48ee4a01a2b42611dcb94f2b9da0ea73a9827ee8c6f42667c |
Close
Hashes for fastmorph-1.0.2-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1de1bc7953eb99ca4b2182dae7f97b297457652aed67a888abce891cc5919276 |
|
MD5 | 8ef37b78c8dbe563258a27bce5ddbd33 |
|
BLAKE2b-256 | ede79b3f906508a0ec609ba90b262481cd53edf46045e368ba8965de160bc177 |
Close
Hashes for fastmorph-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 592750156f7068d3ced075658f8d26fbbfbe00ccca3e5982543ddb5fdaab8974 |
|
MD5 | e2282f3ce116725a5f47f137c630faff |
|
BLAKE2b-256 | 28edc45a159a3685eeb3cb4b36c5a67536e7f7113af5f80520335751a7807934 |
Close
Hashes for fastmorph-1.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1821b3c67d4f84e185e2856603313378500428d02fc6f3b07dcf649cc8cd989f |
|
MD5 | 894079903ef3598a71cd8c239bead1c9 |
|
BLAKE2b-256 | e0ae010b694689cb3030520aada56a95884a6e7457702b35e2c03579f7091e79 |
Close
Hashes for fastmorph-1.0.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec95830888a697fa59f6318d466107a3378423d0cf440ad8279adc28bcfd6d5e |
|
MD5 | 9e64617ffe7a898d64bf4ddd6596ea50 |
|
BLAKE2b-256 | c1b2b214c3bbaf936faf93b0ca4fff9e9d1e5324bce08e393be3b27a62fc6057 |
Close
Hashes for fastmorph-1.0.2-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66d6153437d162899065074458037ef1edcce0c5a36f2352dd1bd5f457fb71de |
|
MD5 | 1f788d706351703061266781d8d48c05 |
|
BLAKE2b-256 | b55fdda2b5bbd3ebb9bfdbeb6afc11c8a66e5d8bc5547b9c64bac5785a0d6ba4 |
Close
Hashes for fastmorph-1.0.2-cp312-cp312-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0978b06005694a2ce8edd7d371ef15bf91bca78f25da6babe564bc895f1d1f4 |
|
MD5 | 5ddccb9b816e72f87ac61030c7f7ad68 |
|
BLAKE2b-256 | 86a432d700b8f251492e3e5014a21f3ead77d8f8326bdfb885749c2ef7643bb9 |
Close
Hashes for fastmorph-1.0.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d364772fe435eea677dfffcad37435368e68077602793cd3696b03f6ed4a522e |
|
MD5 | 47df513e2cdbc52cb574cce942add026 |
|
BLAKE2b-256 | fe4d8bb2ee2e22f9b57d21744b41c622da4b8e4bd1d85650ca8f5045e5c3db1d |
Close
Hashes for fastmorph-1.0.2-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2faf483db37f5b538292502b8cf287caa428b68298d26cf56e2e5e6b59fd61a4 |
|
MD5 | fabaa49b245794dcff504d2aa31219a1 |
|
BLAKE2b-256 | 6a03b8ea6ad11fe8e9bb3c517d417349bde288ff067e457d4dba52beaf0a41f1 |
Close
Hashes for fastmorph-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6af57af331103560e3b5dc7b7c6d43796a9f823aefd24e2c1f3b58db3e22a3ff |
|
MD5 | 658424f5ad56f6fb22501467c9f5475b |
|
BLAKE2b-256 | 5ed25f1430e6f5e3ca0245329765da563f31d4258643464ae2f6f7fd0b5120cd |
Close
Hashes for fastmorph-1.0.2-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b47fa1b7244508b3b87d9b95414fc88cad1296fb74a72192c2d0a36b963b7ec |
|
MD5 | 9d5ae27fc05e4662c3b45173a00e0d38 |
|
BLAKE2b-256 | 23385cbeef1c0975724d6dc00155f4a33fd769d8a4c4b4e1e5141dcc4a515e45 |
Close
Hashes for fastmorph-1.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a42e96159ae7066309059a5bff93b2516cfab2e4325f57e60ed1d2a046fb070a |
|
MD5 | 74b90909bc0da00c305a5a995e5b09a3 |
|
BLAKE2b-256 | 8d0f1409c5940ca7aaf8be29845af14bee7795c705a969b3d9e8eee56d5645ea |
Close
Hashes for fastmorph-1.0.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffe26af677beab6d2d89270e1a554d6c3ad3a4afc89bab7e81dce4b933415e09 |
|
MD5 | e32dd66e2050f193f581fdf4d216cf10 |
|
BLAKE2b-256 | 46934207e14bc81c4d0e011a3467bcb827f25786d2a728a5928a50d854e9a148 |
Close
Hashes for fastmorph-1.0.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c7dec6c408ffb5431b0024b823c68b592932f911070814405345446ec4c57f1 |
|
MD5 | e06d1f1d1425f8a9c406e9d3983a31e9 |
|
BLAKE2b-256 | b5cb0568e1e3d57c1d055dc3b2c3d59d0ec5b9bf764cc2e8228b1bf45e68b261 |
Close
Hashes for fastmorph-1.0.2-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4ae97e42d00417799c919b69c52155b3ab4d0e080ecf7dd0e033bc4b698eafe |
|
MD5 | a363c40afb727a881edc4ac030a4e5ef |
|
BLAKE2b-256 | 3c1a02e23b8c398c3adeab4fc75fa105dd1cfa686b0d33f1336123ce2830b260 |
Close
Hashes for fastmorph-1.0.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca1c40df8d3964577c0d7a11c3038ef04cbe080a53462d792536242dcb29e129 |
|
MD5 | 41f8c268e9b9c1f2bc642a9705743687 |
|
BLAKE2b-256 | 3cdfc36de49c9693edf02c3497b68a46569e1fa0453b1ed87e22d15969402828 |
Close
Hashes for fastmorph-1.0.2-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca97a1821ee12b0c666cc785bf8dbda68ffa806025a1bb057ec9379586a2b83a |
|
MD5 | 48fbdc8ddeaed7ac3995124aaeb7716e |
|
BLAKE2b-256 | afa5c96c54c1b188035dae00d914a25ea241614c3978ff91cd5c77ed397ed73e |
Close
Hashes for fastmorph-1.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd185936f320c33920acedf391486afb1c4faf614aee15a7ac68aec2f02f8688 |
|
MD5 | 7346869a4984694db7386d9bd69042cf |
|
BLAKE2b-256 | 39dc427fe4213c7e2dad1a1462489b561f802bd7ec1103bde94aebfe452f7112 |
Close
Hashes for fastmorph-1.0.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91dfc114b914b11343f9b9101c05c76daf826ee17be91e2ec604dde7c6de3c08 |
|
MD5 | bc1c6254a864ff0ebc9bd5d1918456a5 |
|
BLAKE2b-256 | 308f9c8ba54c4ffc2459595d7233a6d5605e4a184a10a5c33cd7d5bade114b55 |
Close
Hashes for fastmorph-1.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99eb0607e6fec9a373a82de11e4c0648a28a93070cbc6764a777a2507398c57b |
|
MD5 | eef7089b686f94db5c1415f7a8fb0d6e |
|
BLAKE2b-256 | f2618a5af9b1632a4826c0e196984ddc1d6c9b0bbf13891de02c6fc82ab51092 |
Close
Hashes for fastmorph-1.0.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8da7ac17aae8d0f7daddf6ee0f5a86ce0e51c296abff543003aad29c886dfb80 |
|
MD5 | 8d701005dddea8066978dd9a58a1735a |
|
BLAKE2b-256 | baec1c8272aac901d1e2edaace8cddf46fe08828464fd1fe5ab20e5dfa19e257 |
Close
Hashes for fastmorph-1.0.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 900d045293a451f0eb186b018eba42ee9ae08d8bed5a39c90e49dd9755a8912f |
|
MD5 | 4261c7daa00855daf1a07b9af7379c61 |
|
BLAKE2b-256 | 4b936717607602278f32a908dc4d50311ca9fcb6775d6e213ccb09ea00ae3647 |
Close
Hashes for fastmorph-1.0.2-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1ef641a76589aad9f030902f4a811c8c0b4af12e3f48f1f43d74d9283043276 |
|
MD5 | bc2a4484a44e8de989a72869916b6b8e |
|
BLAKE2b-256 | ba715a979d1fb6b2ec49d5c8a0d170eda4e0945f6feb0f8338b1c5b2280bca60 |
Close
Hashes for fastmorph-1.0.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e2ad1843ff94b0fad663415bd49621a98cf9aaa387dfd9721821e1905aada1e |
|
MD5 | 99bb8d85298464bd408b195e45cc8b5d |
|
BLAKE2b-256 | 40f2085ebdda3587a5d0169bd53f9a11b3c13c558ebc08fdd6119544ec6409a0 |
Close
Hashes for fastmorph-1.0.2-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bb4993c05dbd6356dee62f601a83fc8038ce4c6866a6d39f86b43c7b5d10ef6 |
|
MD5 | ab852fa6b5e818a044e28617cd512e53 |
|
BLAKE2b-256 | d5947d45c90ca1db2ed01ba3fff10390f5e3206028fba20a57b5cae1e1ee86e4 |
Close
Hashes for fastmorph-1.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c880383e2f7e2f90303e3e8f74a709f156d293485a7940933d24b87cdb2bd9ad |
|
MD5 | 29ccc43c4528e6b2ebc2a7b2f2134bcd |
|
BLAKE2b-256 | 55fa03ea638d35f56f62cab385e288fab87d96c3df952ba514ac96aaeefd9bf6 |
Close
Hashes for fastmorph-1.0.2-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b865f964a217c180f577bb88d9e5d841be298f2818c3f9755a9dcf72a49e80d1 |
|
MD5 | 829d3af3b6007b33185be91885602403 |
|
BLAKE2b-256 | 159c6c8f6236b56f0bc5db4b77471004120f8ee0b55d2f72914be08ddf5b8ac1 |
Close
Hashes for fastmorph-1.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4b6d7a02ac69cfb78d4834300fad457b9c9ad6e68cdc12ebfcfb71d64e21007 |
|
MD5 | 6eda23d97a1522a0057f915ade2dd2e8 |
|
BLAKE2b-256 | 58bbd4453b1f0ba4b44bb41d1fc523df4bb3b5c210bc99e43ce2dfc9102fceaf |
Close
Hashes for fastmorph-1.0.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ae8db3b474b603a6f86dc838be2c181128191a11b56699e35ee2271aff77539 |
|
MD5 | 8ee66a0a541ad719558a757443b59732 |
|
BLAKE2b-256 | cd0e9d5ffd7c4c429f450101e67ed455cbbf04214bb86aefc5426841c9d70f50 |
Close
Hashes for fastmorph-1.0.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbc5cd82f75ee12d072b72cd0099342a7f3f3f634adb053cf6b5b5d480f2c652 |
|
MD5 | 98f342e8b399c5afdb3fa904cb64d1e3 |
|
BLAKE2b-256 | 0df6680da63c832ae36f40f2f4f6d430767bb6c299ded3765c7c6bb4c85dc768 |
Close
Hashes for fastmorph-1.0.2-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 591d284fbb744cbcb471ae64c8a93f2ebe99d988a0c90b7dc4c031a63be39f9f |
|
MD5 | 22be6ccc1928f27342828bdb9adf91b9 |
|
BLAKE2b-256 | f5a6c61388355a996adfe50665bb86e73c5905c58d0284d053ddc79ee71282a1 |
Close
Hashes for fastmorph-1.0.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e19a86e9472b8d150c9de1c4defb79e2c9ba531e61695b2c530c2b03083f8426 |
|
MD5 | 1362d2caad69737aeb159ae152a11d37 |
|
BLAKE2b-256 | 203ffbf4d2495ce5026ea8a4d2430b5d4469187bb2fb63c55a1773ffec368dbc |
Close
Hashes for fastmorph-1.0.2-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5da33732912fbd1163e955b3783612ff9ea46a3a38370f30bfc3f3fedad26ebd |
|
MD5 | a0f0a2e297bc618067f1f02b31639ba0 |
|
BLAKE2b-256 | 3376157cba731a91051bb693361ceae2a79021738269c145b4bf0bbaf9ad0ea8 |
Close
Hashes for fastmorph-1.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab96833726604a4dabe68827b0472787e8fcd65cc4179b31168f1917806e92f8 |
|
MD5 | 88db5a02bb83b6344fc38edf20f44f99 |
|
BLAKE2b-256 | 9bdaa59931bc562e0b93468a81ea75d14ac13138d4ec4ee8fce7e78b62ea1271 |
Close
Hashes for fastmorph-1.0.2-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4049f953fce3e42bf19c2e10256ba6211cbd22f5650290cd35d61c6f27c6fbe0 |
|
MD5 | 8e3c62b920ffc44823969d11fd76ab3d |
|
BLAKE2b-256 | 20ea3b8721459400fe9ebe1000d0fcf4e1c63c19830e4bfdb8b588dbbab71162 |
Close
Hashes for fastmorph-1.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c14d581d6487980a2edef055fd8502af002b230691e3d81be82e1cf8e70a712 |
|
MD5 | be345268b0005fe0f6ba7c4babcf8186 |
|
BLAKE2b-256 | 0b5487e133b8fafa643ac3980c20c63919e01c334980bdcbb7ca45578b98e26f |
Close
Hashes for fastmorph-1.0.2-cp38-cp38-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1d50f561b120601373de6f62d4301d6323e90cb2cd915bf1262b3f1363a6cfe |
|
MD5 | fa7eb02ec30f0850e7b6758fdffcf1e8 |
|
BLAKE2b-256 | a388870b663d6d3d5105dd147a84e8796073035e6fba258a791b64bc6e6ebbb2 |
Close
Hashes for fastmorph-1.0.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f8dc2919124ffecbdc3ee06499353b68590e1bf23a11484002f441199c6cbfe |
|
MD5 | 31a7009ffea54d8ae5275244ab577d76 |
|
BLAKE2b-256 | e7d5e6c60bcc7c85df16e66d6f3c1f6a93bf6a51c95b3e5cd059813f96a7bdd4 |
Close
Hashes for fastmorph-1.0.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23de96445fd9c5d103083a6ab1a306ae10c383a87e0b905fcd10dcade04e0235 |
|
MD5 | 0b905af98f4b949ef31be7df0ca885d7 |
|
BLAKE2b-256 | 2e3dab04f5c74287f1aa167891aac94f551c8ef0b699cbea9f595513801a53c5 |