Search for a command to run...
SYSTEM REQUIREMENTS & TOOLBOXES To run this script successfully, the following are required: MATLAB Base (R2020a or newer recommended) Statistics and Machine Learning Toolbox (Required for 'knnsearch' in ICP) Image Processing Toolbox (Required for image matrix and mask handling) CUSTOM DEPENDENCIES 'FFT_Poisson.m': A fast least-squares integration solver with a periodic boundary conditions. This file must be included in the MATLAB path. ["Normal Integration: a Survey", Quéau et al., Journal of Mathematical Imaging and Vision 60(4), pp 576--593 https://doi.org/10.1007/s10851-017-0773-x.] [Avaible for download at: normal_integration/Toolbox/FFT_Poisson.m at master · yqueau/normal_integration] Description The selection of rmin and rmax is based on the sensor-specific noise floors and on how reliable the geometric information is at different spatial frequencies. The parameter rmin is set to the frequency where the low-frequency bias (artifacts) of the normal integration becomes non-negligible. Frequencies lower than 1/L (where L is the papyrus fragment length) are dominated by integration artifacts, rather than actual topography given by the RTI. By setting rmin between 1 and 2, the RTI topography is anchored to the absolute spatial coordinates provided by the flat surface or the photogrammetry. Regarding the parameter rmax, which defines the limit of the transition zone, a value of rmax = 5 represents a narrow transition band, while a value of rmax = 10 provides a gradual frequency blending. This wider transition is preferred because it reduces aliasing and artifacts that can appear when combining two datasets with different characteristics. Depending on the specific requirements of the study, it may be more advantageous to integrate the surface obtained with photogrammetry rather than the artificial flat surface. Regardless of the method chosen, RTI and normal integration techniques provide high accuracy for high spatial frequencies, potentially up to the Nyquist frequency. The Nyquist frequency defines the theoretical resolution limit imposed by the digital model's sampling density (or pixel pitch). Mathematically expressed as half the sampling rate (f_N=1/2∙f_Sample) it serves as a threshold for detail preservation. Consequently, stating that the integration techniques maintain accuracy up to this limit implies that the method fully exploits the discretization grid, successfully reconstructing the finest surface features physically allowed by the sensor's resolution. To clarify its structure and functioning, the computational architecture of the developed MATLAB code is organized into four sequential processing modules: 1. Surface Integration: The system first converts the RTI normal maps into gradient fields (p, q) and performs a fast least-squares integration using a Poisson solver with Fast Fourier Transform (FFT) to generate a high-frequency depth map (see "Custom Dependencies"). 2. Frequency Domain Fusion: The low-frequency photogrammetric point cloud is scaled and interpolated onto the 2D image grid. The software computes the Power Spectral Density (PSD) for both the integrated high-frequency surface and the low-frequency reference using 2D FFT. These are blended in the frequency domain governed by user-defined radial thresholds (rmin and rmax), and reconstructed into a single surface via inverse FFT. 3. Background Masking: Undesired background areas are removed by mapping the combined 3D coordinates against a 2D binary mask. 4. Z-Preserving Alignment: The final point cloud is aligned to the object-space defined in Metashape using a customized registration algorithm. Detailing the post-processing phases, the background removal employs a mask-based approach. The process begins by reading a text file containing the three-dimensional coordinates (X, Y, Z) of the combined RTI point cloud. Simultaneously, a binary image is loaded as a mask that defines which areas of the point cloud to retain and which to discard. For each point, the software checks the corresponding pixel in the mask: if the pixel is black, the software zeroes the point’s Z coordinate. This zeroing step flags points for removal. Subsequently, all points with a zero Z coordinate are eliminated, completing the background-cleaning operation. The final operation, point cloud alignment, is more complex and involves multiple steps to align the model within the photogrammetric object-space. This method utilizes a combination of nearest neighbor searches (k-NN) and Iterative Closest Point (ICP) algorithms. Prior to alignment, an initial scale estimation is performed based on the 2D bounding boxes of the point clouds. This normalization is a temporary step that preserves the object’s true dimensions while performing distance comparisons. The k-NN algorithm then establishes initial correspondences between the two datasets, and the ICP iteratively refines these matches—calculating 2D rotation, translation, and scale—to achieve optimal alignment. A defining feature of this software is its preservation of the RTI cloud’s original Z values during alignment. Depth and height values deriving from RTI often exceed the accuracy of those deriving from photogrammetric measurements; therefore, the algorithm isolates and operates solely on the X and Y coordinates, fully retaining the original depth information for the final output. Finally, a minor manual adjustment, when needed, can be performed in CloudCompare. Since Z values are excluded during alignment, a slight shift may occur between the object and the aligned cloud. This last refinement is rapid, thanks to the preceding preprocessing steps. Through this workflow, we can generate a highly informative point cloud that integrates the high-frequency details from RTI with the low-frequency components of photogrammetry. This process creates a scaled 3D model suitable for metric calculations. Furthermore, by aligning the generated model within the same object-space as the photogrammetric reference, it can seamlessly replace the original geometry within the processing software to be fully textured.