## 2 Materials and Methods
### Algorithm  
The novel stacking algorithm is developed to correct image sequences where the speed of the camera and the moving object are not synchronized, provided that the object maintains a constant linear motion and the distance between the camera and the object is constant. Initially, the algorithm captures raw images during the object's movement, ensuring complete recording. This is followed by preprocessing the data, which varies depending on the camera type. The crucial step involves calculating the pixel shift between frames, which can be achieved through two methods: tracking a checkerboard pattern or using known camera parameters. Once the pixel shift is determined, it is converted into a fraction with a maximum denominator of 10 to balance computational efficiency and accuracy. The images are then upscaled in length according to this denominator. The next phase involves creating a temporal matrix by iterating over frames and copying corresponding rows from the original sequence into this matrix. After constructing the temporal matrix, any shifts due to the object's motion are corrected. Finally, the algorithm downscales the temporal matrix in length by the same fraction's denominator to complete the correction process. This series of steps ensures that the final image sequence accurately represents the object's motion relative to the camera's position. Figure 3 shows a visual overview of the different time steps of the stacking algorithm. The list below explains the algorithm in more detail. Figure 2: Image of the experimental setup with the housing open. Multiple cameras and corresponding light sources are mounted above a translation stage to allow examination of a sample in multiple wavelengths. Several steps are required to correct an image sequence where the camera and object speed is not matched. However, the object has to move in a constant linear motion. For an overview of the correction algorithm, see Figure 3. The following list explains the algorithm in detail. 1. Capture raw data The images are captured during translation of the object while making sure that the start and end of the object are fully recorded. This is displayed graphically in Figure 4 in rows 1-2. 2. Preprocess data Depending on the camera type, preprocessing is required, e.g., NUC (non-uniformity correction) for IR cameras or demosaicing for snapshot HSI cameras. 3. Find pixel shift To calculate the pixel shift from frame n to n + 1, we present two methods. The first method is to detect and track a checkerboard in a sequence of frames. The upper left corner of the checkerboard is tracked across a series of frames and fitted with a first-degree function to minimize the error. The other method is to calculate the pixel shift. This is possible if the camera parameters are known. For more details, see Section 2.1.1[24]. 4. Factorize pixel shift The pixel shift is converted to a fraction with a maximum denominator of 10. The maximum denominator is chosen empirically to limit the computational cost while still providing an accurate result. One should consider the necessary accuracy needed for the application versus the computational cost. 5. Upscale the images The preprocessed images are resized in length, through interpolation, by a factor equal to the denominator of the previously calculated fraction. 6. Create a temporal matrix This step consists of a main loop and a nested loop. The main loop iterates over all the different frames of the temporal matrix. The number of frames is calculated by \(ft=l*Fraction\), where \(ft\) is the resulting number of frames in the temporal matrix and \(l\) is the length of a single frame from the original sequence. The nested loop iterates over the original sequence and copies the corresponding rows from the original sequence into the temporal matrix.