# 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_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)