Skip to main content

Morphological tree learning utilities with a stable morphology facade

Project description

MTLearn

CI Package

MTLearn (Morphological Tree Learning) is a C++/Python research library for learnable connected operators based on morphological trees. The Python package is published as mtlearn.

The library explores a simple idea: connected morphology can become a structural prior for deep neural networks. Instead of processing images only through local pixel-wise operations, connected operators reason over components, regions, shape, contrast, and hierarchy. This makes them naturally interpretable and well-suited for tasks where structure matters.

Classical connected filters are powerful, but they usually depend on hard keep/discard decisions and manually selected attribute thresholds. This limits their integration into end-to-end trainable neural architectures.

MTLearn provides a stable implementation platform for this research direction. It currently includes Connected Filter Preprocessing (CFP), and is intended to grow toward trainable connected-operator layers, differentiable or learnable attribute criteria, self-dual tree representations, intermediate network insertions, and scalable implementations.

Main Features

  • Connected Filter Preprocessing (CFP): the current main model, available as mtlearn.layers.ConnectedFilterPreprocessingLayer. CFP replaces hard connected-filter decisions with a differentiable sigmoid gate over normalized tree-node attributes.

  • Stable morphology interface: mtlearn.morphology builds max-trees, min-trees, and tree-of-shapes through a backend-independent API.

  • PyTorch integration: CFP layers are torch.nn.Module objects with trainable parameters, checkpoint helpers, and dataset-level normalization utilities.

  • Validation utilities: includes C++ tests, Python tests, gradient checks, reference implementations, notebook utilities, and registered dataset download helpers.

Install

The Python package is available from PyPI as mtlearn:

pip install mtlearn

See docs/installation.md for installation instructions and docs/development.md for source builds, validation, and releases.

Quick Start

Create a CFP layer and run a forward pass:

import torch
from mtlearn import morphology
from mtlearn.layers import ConnectedFilterPreprocessingLayer

cfp_layer = ConnectedFilterPreprocessingLayer(
    in_channels=1,
    filter_specs=[
        {
            "tree_type": morphology.TreeType.MAX_TREE,
            "attributes": (
                morphology.AttributeType.AREA,
                morphology.AttributeType.CIRCULARITY,
            ),
        }
    ],
    device="cpu",
    scale_mode="none",
)

x = torch.tensor([[[[1, 2], [3, 4]]]], dtype=torch.float32)
y = cfp_layer(x)

assert y.shape == x.shape

For tree-of-shapes specs, normalization, caching, checkpoint helpers, and attribute selection, see the guides listed below.

Documentation

The main documentation is built with Sphinx from docs/source.

Examples and Reproducibility

Executable examples are available in notebooks/. Notebook dependency setup is documented in docs/installation.md.

For ICPR 2026 Reproducible Research in Pattern Recognition (RRPR) review, use notebooks/ICPR2026/README.md as the canonical guide for setup, datasets, notebook execution, hardware notes, and current reproducibility scope.

Scope and API Boundaries

MTLearn is a research-oriented library. CFP is the current validated trainable connected-operator layer, with support for max-tree, min-tree, and tree-of-shapes workflows; mixed tree specs; multi-attribute dataset-level normalization; cached preprocessing; and PyTorch forward/backward for CFP parameters on CPU or CUDA tensors.

User code should interact with morphology through the public Python facade mtlearn.morphology and the primary CFP layer in mtlearn.layers, rather than depending on backend-specific APIs. The backend is MorphologicalAttributeFilters / mmcfilters, but the top-level Python package mmcfilters is not required as a runtime dependency of mtlearn.

Citation

If you use the CFP layer in your work, please cite:

Wonder A. L. Alves, Lucas de P. O. Santos, Ronaldo F. Hashimoto, Nicolas Passat, Anderson H. R. Souza, Dennis J. Silva, Yukiko Kenmochi. A trainable connected filter preprocessing layer based on component trees. International Conference on Pattern Recognition (ICPR), 2026, Lyon, France. ⟨hal-05575141

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

mtlearn-1.0.11.tar.gz (369.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mtlearn-1.0.11-cp314-cp314-win_amd64.whl (515.0 kB view details)

Uploaded CPython 3.14Windows x86-64

mtlearn-1.0.11-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (549.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mtlearn-1.0.11-cp314-cp314-macosx_11_0_arm64.whl (431.9 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

mtlearn-1.0.11-cp313-cp313-win_amd64.whl (502.0 kB view details)

Uploaded CPython 3.13Windows x86-64

mtlearn-1.0.11-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (549.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mtlearn-1.0.11-cp313-cp313-macosx_11_0_arm64.whl (431.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

mtlearn-1.0.11-cp312-cp312-win_amd64.whl (501.9 kB view details)

Uploaded CPython 3.12Windows x86-64

mtlearn-1.0.11-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (549.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mtlearn-1.0.11-cp312-cp312-macosx_11_0_x86_64.whl (466.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ x86-64

mtlearn-1.0.11-cp312-cp312-macosx_11_0_arm64.whl (431.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

mtlearn-1.0.11-cp311-cp311-win_amd64.whl (499.9 kB view details)

Uploaded CPython 3.11Windows x86-64

mtlearn-1.0.11-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (551.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mtlearn-1.0.11-cp311-cp311-macosx_11_0_x86_64.whl (462.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

mtlearn-1.0.11-cp311-cp311-macosx_11_0_arm64.whl (430.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

mtlearn-1.0.11-cp310-cp310-win_amd64.whl (498.8 kB view details)

Uploaded CPython 3.10Windows x86-64

mtlearn-1.0.11-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (550.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mtlearn-1.0.11-cp310-cp310-macosx_11_0_x86_64.whl (461.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

mtlearn-1.0.11-cp310-cp310-macosx_11_0_arm64.whl (429.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

mtlearn-1.0.11-cp39-cp39-win_amd64.whl (508.5 kB view details)

Uploaded CPython 3.9Windows x86-64

mtlearn-1.0.11-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (549.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mtlearn-1.0.11-cp39-cp39-macosx_11_0_x86_64.whl (461.4 kB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

mtlearn-1.0.11-cp39-cp39-macosx_11_0_arm64.whl (429.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file mtlearn-1.0.11.tar.gz.

File metadata

  • Download URL: mtlearn-1.0.11.tar.gz
  • Upload date:
  • Size: 369.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mtlearn-1.0.11.tar.gz
Algorithm Hash digest
SHA256 75e8a4492c0bea3fed4137d64882057e7b3e33f39c1267226f2148c340b2ac47
MD5 9253036582aefae4e8a8930a53a9c8aa
BLAKE2b-256 2a823fd2502bdbb2765ef121b8103121593c948461c73b8c28325a68d8d050a4

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: mtlearn-1.0.11-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 515.0 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mtlearn-1.0.11-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 8f55b22a279c18d6f357efccdbddf494f42fb36358406a5c0a79e9ef976b58be
MD5 7f41a8623c331545e21fe29afb6c97f6
BLAKE2b-256 ecafa2a3957d61ad1765bbb14f8c2c2e8a93c09700210a12deec3fcb0f14ff16

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 38844ded381c77c38e14d5aac4b80514a33ba2347537ae0f2aee615dcb32201c
MD5 3d3a65ffd029df06a017fcf725df296c
BLAKE2b-256 267f89914e94794d75363468d9f21c0a7235d7c8d4eb955e8cc5d01125dce47a

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1bb06fce0f6cf5e4c8a875e28de6b214630e19bd8bd5b15d316eae58e1b50b4f
MD5 0d4de4f06efd4641825dceaf74fc0b28
BLAKE2b-256 da581ac585b74141dba21dd7b733dd8488c21df3b049964e92e65aea475bd110

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: mtlearn-1.0.11-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 502.0 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mtlearn-1.0.11-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e4770339d2789b8c3499e1ed2e752c62f88ef5b6c0eed96794fd63bf704f1ab4
MD5 f47c7b73f89020a5e9e2e3b099275234
BLAKE2b-256 094feffef86140f2432c2f9b50ff22f850c9dc2cf27ab4204313c1af9eac3491

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 30598f0ab1a9c9675b549bab7871b76d66a60de44b1752e646d6c8819104a5e1
MD5 b00a5b399ab0a1ed92bc5f63dcf361f7
BLAKE2b-256 266286915aa74ccad59d79390a85b6b71dd47aff6ddd305aa790c3d64e3afdb6

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20250c82db1ce127c678c3b342c4bb33ab674fd45c2e60988abdca8fd2979e81
MD5 c3ae00149fce3e7e2034ec4696104fc1
BLAKE2b-256 a81dc8e4699601fe097a29555e94b898da3ddf345fe3efe920788cee52f92fd1

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: mtlearn-1.0.11-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 501.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mtlearn-1.0.11-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9daf725a055adb1bfe80346646df2bb708906bb0b4d70e1bb36ee4c2455438c8
MD5 89ffaadba04332133d861eaacbc9a5b8
BLAKE2b-256 44d6cc48428f3d2a384e4d709ef3e579012f0b2b4688df5f7a09bb6e2f68b5d4

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 10b5cb5540cf54ad7166968cd02f8376637c8d44aef88babe9227bd67b34cb55
MD5 bf2cd9bfe3d7425f4dee6858829ea259
BLAKE2b-256 d3c5ae33f03540baa3231c06532136912b64b5e361cde9ef04955556ddf854e1

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp312-cp312-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 8955abf3af8f545b0cf10dfc7e1bbc44a6a7a2c61c676f60677a5e228d1ebddb
MD5 67d362d95a23c31174d89a31c5c31ead
BLAKE2b-256 d7cdfe86507d65a3e7090e71c230e1f74f73e931ce5fa46cbe3b54171bc674f6

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d3ebf9c906079ae3335193317779e95819f33e98f6adba3969547bf3420a2dc7
MD5 149d4d955a6dbc2da02e315004079264
BLAKE2b-256 b2658a8465e2cb9cb8047f1e6c9cf55f1fcdcf2477e07fb941688bff3421ef8c

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: mtlearn-1.0.11-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 499.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mtlearn-1.0.11-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ad19cf108e7ef83818f67ee20311f06a76c83e5a06b5c4d6a9bddf2ab6d373d9
MD5 346539ed524ffda1f1bf576e6acb2285
BLAKE2b-256 09180fc9ec3299750aba0a5cb9a62c0e833bf7350db96fc4a01a54bdaf31241a

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3226dc96bae3774e3e56c8f77813a7d0f261d162843b5ff35f949bc2daae5c76
MD5 3a8e56ed7392930e59b3e1cc33c9f325
BLAKE2b-256 30a5e8532503bfef59c2c6240d987ec15c1e8d87724cbbd8ae34e49e3e218add

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 4d323bc6e10d448c32550a92076d1688069b52b2140ef867ab027a18ce7488ac
MD5 a80463631fcf5e10b9922eba1109b78d
BLAKE2b-256 cc1a8e787b926f457557f6c21f2f1a1b84df2524de7a2ca23d473412b584a4f1

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fef0f504d74e3e8d5b2797723acf11d1bf37ec58427ce63875035b7d3eb98342
MD5 b7bbbe19e9f385607946a0dfa2db315a
BLAKE2b-256 d1f9761a7a60983a5b4dfb4fb96837799d004727959775ea6f2218601e2d953a

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: mtlearn-1.0.11-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 498.8 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mtlearn-1.0.11-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 12e04df1adf032b8532ca827214b874c2d2e7fa1695bb7319dfddf1adb71ab64
MD5 f1c30abb4ee64c84fbb757a1793b9d80
BLAKE2b-256 53b89f2b570c0eb5c04ee6f0f3f4c3681c43e29d17389c2ceced28c68c573e61

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f1032960102960d01db60260673e58d1d71b7734f81112b9b1cdd4539b451f08
MD5 84908db5f4c1d568b92486a25a1e2eb3
BLAKE2b-256 10410d48852d0584aa72068e71d54fce2a7200d9306e544a0433790784972f9d

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 ee14e509b1418635d1ab82de77780dd75fba65fecaa022318bf5c47e3a38f394
MD5 e039068fd1e4d6d50fa3745fe9b88c1e
BLAKE2b-256 481ed89b565c72e15661c47b18690190eeae5593eb237f659f86b1b90fc2bc4d

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 811460ba04de7f9be39dfb07fa46c7dcc8be096e6e4703ce46613da9f29277c3
MD5 ac20422bb874f5c98632e721f764fd34
BLAKE2b-256 e7a6ae5da252df4356edbe5e33f2e0da7b48017de3c3f5322aa6282d53a8f00b

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: mtlearn-1.0.11-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 508.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mtlearn-1.0.11-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 60b4ff0d36504c40cd87f14695863c7277b59c7da0ce11e517f31d903fbe3520
MD5 c52e1643fc365b32440c7e5047e47ac7
BLAKE2b-256 4bc2db3f3f9ec4b653d02446d3f6cee28bc9105a049deec512c4586bc08e5cb2

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a207af72d40fa1f1ec31053b5a8fc50f5fe8d5d978697885ce4c31df1456b38d
MD5 1d35d67eb4527c27a2b825dbbd21bdbd
BLAKE2b-256 8fa3a26f222e2b751aa7bd05036e1cff64f18b910be4662786c3be881a076ba9

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 17bbc360829c0d2c0b48e2cbdfffd2f8a597d7b66408098976ede9c1a43bfcf0
MD5 ebf06df4322167690f353be37a526f6c
BLAKE2b-256 6f76d7a1e98ab9f029d07326563a8de6d3bb304ed01ea21daa26f5150c28d7d0

See more details on using hashes here.

File details

Details for the file mtlearn-1.0.11-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mtlearn-1.0.11-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03fc613e586b3b04644a725a68eb46439556946a5f13fd9957cc1ecbb5e99d8d
MD5 9e25f68ba5f38af84c55ffd865907aa0
BLAKE2b-256 3619ee645cc8b2b5fd97d1c666009f3358fe1c8fa2cea6e0c2dc0278c14c6f71

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page