Here's my Python3 implementation in analogy to MatLab's imreconstruct algorithm:

import cv2
import numpy as np


def imreconstruct(marker: np.ndarray, mask: np.ndarray, radius: int = 1):
    """Iteratively expand the markers white keeping them limited by the mask during each iteration.

    :param marker: Grayscale image where initial seed is white on black background.
    :param mask: Grayscale mask where the valid area is white on black background.
    :param radius Can be increased to improve expansion speed while causing decreased isolation from nearby areas.
    :returns A copy of the last expansion.
    Written By Semnodime.
    """
    kernel = np.ones(shape=(radius * 2 + 1,) * 2, dtype=np.uint8)
    while True:
        expanded = cv2.dilate(src=marker, kernel=kernel)
        cv2.bitwise_and(src1=expanded, src2=mask, dst=expanded)

        # Termination criterion: Expansion didn't change the image at all
        if (marker == expanded).all():
            return expanded
        marker = expanded
Answer from Semnodime on Stack Overflow
🌐
pytz
pythonhosted.org › pymorph
PYMORPH: IMAGE MORPHOLOGY IN PYTHON — pymorph v0.96.0 documentation
openrecth creates the image y by subtracting the open by reconstruction of f, defined by the structuring elements Bero and Bc, of f itself. ... Opening Top Hat. openth creates the image y by subtracting the morphological opening of f by the structuring element b of f itself.
🌐
Medium
medium.com › swlh › image-processing-with-python-morphological-operations-26b7006c0359
Image Processing with Python: Morphological Operations | by Jephraim Manansala | The Startup
February 14, 2021 - We will explore how to clean, prepare and enhance images using morphological operations. The operations like erosion, dilation, opening, closing, area_opening, and area_closing will be demonstrated.
🌐
GitHub
github.com › EdgarOCobas › Morphological-reconstruction
GitHub - EdgarOCobas/Morphological-reconstruction: Morphological reconstruction implementation in OpenCV. MATLAB imreconstruct function in Python.
Morphological reconstruction implementation in OpenCV. MATLAB imreconstruct function in Python. - EdgarOCobas/Morphological-reconstruction
Author   EdgarOCobas
🌐
Psl
people.cmm.minesparis.psl.eu › users › velasco › morpholayers › tutorial1basic.html
Basics on Mathematical Morphology
from morpholayers import * from morpholayers.layers import Dilation2D,Erosion2D,Closing2D,Opening2D,reconstruction_dilation,reconstruction_erosion ... We wiil use the following example, to illustrate the effect of morphological transformation.
🌐
Stack Overflow
stackoverflow.com › questions › 42111467 › opencv-is-there-an-implementation-of-marker-based-reconstruction-in-opencv
python - OpenCV - Is there an implementation of marker based reconstruction in opencv - Stack Overflow
February 8, 2017 - However in contrast, reconstruction uses two images: a “seed” image, which specifies the values that spread, and a “mask” image. Skimage has an implementation of it here http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.reconstruction
Find elsewhere
🌐
Bioimagebook
bioimagebook.github.io › chapters › 2-processing › 5-morph › morph.html
Morphological operations — Introduction to Bioimage Analysis
This is achieved using morphological reconstruction by defining the marker as all pixels exceeding the high threshold, and the mask as all pixels exceeding the low threshold. The markers will expand to fill the mask regions that contain them.
🌐
GitHub
github.com › Pazitos10 › math-morph
GitHub - Pazitos10/math-morph: Mathematical Morphology Operations done with Python.
Mathematical Morphology Operations done with Python. - Pazitos10/math-morph
Starred by 9 users
Forked by 3 users
Languages   Jupyter Notebook 89.6% | Python 10.4% | Jupyter Notebook 89.6% | Python 10.4%
🌐
TutorialsPoint
tutorialspoint.com › scikit-image › scikit-image-morphological-reconstruction.htm
Scikit Image - Morphological Reconstruction of an Image
The scikit library provides a function called reconstruction() in the morphology module to perform the morphological reconstruction of an image.
🌐
OpenCV Q&A Forum
answers.opencv.org › question › 35224 › morphological-reconstruction
Morphological reconstruction - OpenCV Q&A Forum
This one is also nice because it has some example images of what to expect Morphology · The clue is that the reconstructions' main ingredients are geodesic erosion and dilation. These are basically masked erosion and dilation by using a min operator.
🌐
ResearchGate
researchgate.net › publication › 222572655_Efficient_morphological_reconstruction_A_downhill_filter
Efficient morphological reconstruction: A downhill filter | Request PDF
November 1, 2004 - For a 2592 × 1944 pixel image, on a PC with an Intel Core i5 2.4GHz processor and 8 GB RAM, the processing time of the area‐reconstruction h‐dome transform after acceleration is about 549 ms, which is 249 times faster than the unaccelerated algorithm and 4 times faster than the reconstruction function in the Scikit‐image library (an open‐source image processing library for the Python programming language) which performs reconstruction by dilation. The accelerated area‐reconstruction h‐dome transform algorithm was successfully applied to the segmentation of rubber particles in a thermoplastic polyolefin (TPO) compound. Research Highlights Techniques for segmenting particles with irregular shapes based on morphological reconstruction are reviewed.
🌐
GitHub
github.com › scikit-image › scikit-image › issues › 4078
morphology.reconstruction crashes python · Issue #4078 · scikit-image/scikit-image
August 2, 2019 - Description I encounter examples where running morphology.reconstruction() crashes python without error message - it just throws a python system error in windows after which the kernel has to be restarted. The input arrays do not seem to...
Author   scikit-image
🌐
GeeksforGeeks
geeksforgeeks.org › python-opencv-morphological-operations
Python OpenCV - Morphological Operations - GeeksforGeeks
January 3, 2023 - This processing strategy is usually performed on binary images. Morphological operations based on OpenCV are as follows: ErosionDilationOpeningClosingMorphological GradientTop hatB · 7 min read Erosion and Dilation of images using OpenCV in python
🌐
OpenCV-Python Tutorials
opencv24-python-tutorials.readthedocs.io › en › latest › py_tutorials › py_imgproc › py_morphological_ops › py_morphological_ops.html
Morphological Transformations — OpenCV-Python Tutorials beta documentation
Morphological transformations are some simple operations based on the image shape. It is normally performed on binary images. It needs two inputs, one is our original image, second one is called structuring element or kernel which decides the nature of operation.
🌐
OpenCV
docs.opencv.org › 4.13.0 › d9 › d61 › tutorial_py_morphological_ops.html
OpenCV: Morphological Transformations
Returns a structuring element of the specified size and shape for morphological operations.