# Finding the Least Motion-Blurred Image by Reusing Early Features of Object Detection Network
## 2 Materials and Methods
### Data Preparation  
The proposed method is based on the machine learning algorithm LightGBM ranker (gradient boosting decision tree), so the development of the method requires training and testing data. Both training and testing datasets contain real and augmented data (real data after augmentation). For both sets, augmentation allows for the simulation of gradually increasing motion blur. Controlled augmentation of the training data helps to increase the robustness of the developed quality evaluation method. Test data augmentation is used to simulate real situations where the method will be used to find the highest quality or least motion-blurred image from the selected set of images. Real images were extracted from videos that were collected and used in the previous experiment [86], where the methodology for the improvement of 3D head reconstruction was developed, and it was used to propose changes for the general-purpose 3D reconstruction algorithm. Details regarding video collection are presented in the mentioned work, and here we give a short summary. Smartphone Samsung Galaxy S10+ standard Camera App was used to take videos. In total, 19 videos were captured, varying in acquisition conditions, such as changing the orientation of the smartphone, changing lighting conditions, and stationary or varied backgrounds. The average length of videos was \(51.5\pm 16.7\) s. The movement pattern of the camera was simulating an effort to make a selfie--zigzagging sideways and moving slowly from top to bottom, making sure all sides of one's head are captured. From the set of 19 videos, 15 videos were used for training and four videos for testing. After frame extraction, the training set contained 10,100 initial/original images, and 50,500 images after augmentations. The test set contained 3253 initial images and 16,265 images after augmentations. The construction of training and test datasets by augmenting the original image is explained in Figure 4. As mentioned before, augmentation of datasets is needed to simulate gradually increasing motion blur distortions. Randomness in the simulation of motion blur effects provides better generalization properties of the LightGBM ranker. Augmentation of test data is needed to simulate real situations where the single best frame should be selected from the consecutive frames. Training data augmentations included only simulations of the linear motion of a camera. The angle of motion was selected randomly, allowing any possible movement direction. The length of the camera motion was 5, 10, 15, and 20 pixels. It is 0.13%, 0.26%, 0.39%, and 0.52% from the largest image dimension. The mentioned motion lengths in Figure 4 are marked as MB1 (motion blur 1), MB2, MB3, and MB4. Augmentation of test data included the same motion blur distortions but additionally were altered by affine transformation (\"AT\" in the Figure 4). The parameters of the affine transformation were constant for all transformations of the same initial image but were generated randomly for different initial/original images. The affine transformation was applied cumulatively to the initial image generating four new spatially altered images. This imitates consecutive frames in the video when the camera is moving while taking video. The affine transformation was composed of rotation and X- and Y-translations. Rotation was uniformly sampled from the interval \([-0.55,0.55]\) degrees. Translations were uniformly sampled from the \([-15,15]\) pixels range. Datasets contained all I1-I5 images. However, training and test set exploited images differently. Training of the LightGBM ranker model needs the ranked list of images. The training algorithm received features that were extracted from a list of images ordered in increasing motion blur distortions and grouped by image ID (initial image name). Ranks were provided as targets, with the highest rank assigned to I1 and the lowest to I5.