Source code for miop.default_pipelines

# Copyright (c) 2025, Maxime Paschoud.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
#
# (http://opensource.org/licenses/BSD-3-Clause)
#
# __author__ = "Maxime Paschoud, ETHZ: CMBM"
#
from pipeline import *
from miop import *

[docs] def pipeline_fei(pre_processing: bool = True, tiny: bool = False, depth: int = 7): """ Create a pipeline for processing FEI TIFF images with metadata. This pipeline is designed to process `.tif` images that contain FEI metadata. It includes dense feature matching (RoMa), camera movement estimation from metadata, 3D reconstruction, and surface reconstruction. Parameters ---------- pre_processing : bool, optional If True, the pipeline starts with the `ImageCollection` module to handle image loading and preprocessing. Set to False if images are preprocessed manually. Default is True. tiny : bool, optional If True, use the tiny variant of the RoMa model (faster, less precise). Default is False. depth : int, optional Depth parameter for Poisson Surface Reconstruction. Higher values yield more detail but consume more memory and may produce holes. Default is 7. Returns ------- DAG A pipeline (DAG object) that can be run with the `execute(inputs)` method. """ img_collection = ImageCollection(metadata_type='fei') mat_from_metadata = CameraMvmtFromMetadata() dense = DenseRoma(tiny=tiny, num_matches=5000) reg = RegistrationByICP() rec = Reconstruction(by_pair=False) surface_rec = PoissonSurfaceReconstruction(depth=depth) img_collection >> mat_from_metadata >> rec >> reg >> surface_rec img_collection >> dense >> rec list_of_modules = [mat_from_metadata, dense, rec, reg, surface_rec] if pre_processing: list_of_modules.insert(0, img_collection) start = img_collection else: start = [mat_from_metadata, dense] stop = surface_rec return DAG(start, stop) #, list_of_modules
[docs] def pipeline_no_metadata(pre_processing: bool = True, tiny: bool = False, depth: int = 7, threshold: float = 1., batch_size: int = 4): """ Create a pipeline for images without metadata. This pipeline is designed for `.tif` images that lack metadata. It includes dense feature matching (RoMa), disparity-based point propagation, reprojection error filtering, camera pose estimation, and reconstruction. Parameters ---------- pre_processing : bool, optional If True, the pipeline starts with the `ImageCollection` module for image loading. Default is True. tiny : bool, optional If True, use the tiny variant of the RoMa model (faster, less precise). Default is False. depth : int, optional Depth parameter for Poisson Surface Reconstruction. Higher values yield more detail but consume more memory and may produce holes. Default is 7. threshold : float, optional Threshold (in pixels) for reprojection error. Matches exceeding this error are discarded. Default is 1.0. batch_size : int, optional Number of images to consider at once for camera motion estimation. Default is 4. Returns ------- DAG A pipeline (DAG object) that can be run with the `execute(inputs)` method. """ img_collection = ImageCollection(metadata_type='none') dense = DenseRoma(tiny=tiny, num_matches=5000) inter = Interpolate() reg = RegistrationByICP() surface_rec = PoissonSurfaceReconstruction(depth=depth) corresp = CorrespondingPointsFromDisparity() fac = Factorization(threshold, 0, max_matches=10000, batch_size=batch_size) rec = Reconstruction(by_pair=False) img_collection >> dense >> inter >> corresp >> fac >> rec >> reg >> surface_rec dense >> rec if pre_processing: start = img_collection else: start = dense stop = surface_rec return DAG(start, stop)
[docs] def pipeline_raft(pre_processing: bool = True, depth: int = 7): """ Create a pipeline for FEI TIFF images using RAFT flow. This pipeline processes `.tif` images with FEI metadata using RAFT optical flow instead of RoMa for dense correspondence estimation. Includes reconstruction and surface generation. Parameters ---------- pre_processing : bool, optional If True, the pipeline starts with the `ImageCollection` module to load and preprocess images. Set to False if preprocessing is already handled. Default is True. depth : int, optional Depth parameter for Poisson Surface Reconstruction. Higher values yield more detail but consume more memory and may produce holes. Default is 7. Returns ------- DAG A pipeline (DAG object) that can be run with the `execute(inputs)` method. """ img_collection = ImageCollection(metadata_type='fei') mat_from_metadata = CameraMvmtFromMetadata() raft = RaftFlow() corresp = CorrespondingPointsFromDisparity(n_points=10000) reg = RegistrationByICP() rec = Reconstruction(by_pair=True) surface_rec = PoissonSurfaceReconstruction(depth=depth) img_collection >> mat_from_metadata >> rec >> reg >> surface_rec img_collection >> raft >> corresp >> rec if pre_processing: start = img_collection else: start = [mat_from_metadata, raft] stop = surface_rec return DAG(start, stop)