{'fraction_non_alphanumeric': 0.02551735932957072, 'fraction_numerical': 0.010501111681204036, 'mean_word_length': 4.600766283524904, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Domain Siamese CNNs for Sparse Multispectral Disparity Estimation

Multispectral disparity estimation is a difficult task for many reasons: it has all the same challenges as traditional visible-visible disparity estimation (occlusions, repetitive patterns, textureless surfaces), in addition of having very few common visual information between images (e.g. color information vs. thermal information). In this paper, we propose a new CNN architecture able to do disparity estimation between images from different spectrum, namely thermal and visible in our case. Our proposed model takes two patches as input and proceeds to do domain feature extraction for each of them. Features from both domains are then merged with two fusion operations, namely correlation and concatenation. These merged vectors are then forwarded to their respective classification heads, which are responsible for classifying the inputs as being same or not. Using two merging operations gives more robustness to our feature extraction process, which leads to more precise disparity estimation. Our method was tested using the publicly available LITIV 2014 and LITIV 2018 datasets, and showed best results when compared to other state of the art methods.


I. INTRODUCTION
Disparity estimation from stereo images is one of the fundamental task in the field of computer vision. It can be used to predict the depth in a scene, register images into the same coordinate system and perform object detection. It also has many real-world applications such as for autonomous vehicles and for 3D model reconstruction [1], [2].
Many works in the literature focus on disparity estimation in the visible (RGB) domain [3], [4], [5], [6], [7], where both images are captured with RGB cameras. Recently, more works use multispectral image pairs, where one of the images is in the infrared (IR) spectrum [8], [9], [10]. This has both advantages and disadvantages. For instance, when we want to detect a given object that has a temperature different from the environment, working with thermal IR images can be beneficial since the desired object will be easily detected. For example, humans usually have a body temperature that is higher or lower than the ambient temperature in public places, making human detection easier. This is especially true if a person's clothes have a low contrast with the environment. For instance, at night time, if someone is walking in a public park, detecting him or her with a thermal IR camera will be easy. However, detecting the same person with a RGB camera would be a lot more challenging. The opposite is also true, where detecting a human in daylight will be easier than in thermal if this human has a body temperature similar to the environment (low thermal contrast). RGB provides as well more information to help describe and identify persons. Thus, if we work with two  [11] stereo dataset where we can see a lot of common information between the two images. Second row: images from the VIS-NIR [12] dataset, which still shows similar textures between both images. Third row: images from the LITIV 2014 [13] stereo dataset where the only common information between the two images are the objects emitting heat, with very few common textures.
cameras from different spectrums, we can get the best of both worlds, since RGB cameras provide more visual information in the case of people, but they require appropriate lighting to do so, while IR camera can capitalize on the thermal contrast between humans and their environment, but will by default remove a lot of details like textures and colors from the image making people identification harder. Many works in disparity estimation are designed to work for RGB cameras, where both images have similar content (colors, textures). Lately, several works focus on multispectral images where one image is in RGB while the other one is in the infrared domain. In this case, the amount of similar content in both images will depend on the type of infrared used. However, in all cases, working with IR images reduces the similarity between the two images of the stereo pair, which means that matching the content of said images is harder, and therefore disparity estimation is also harder.
In figure 1, we show three different image pairs. It showcases how similarities between image pairs diminish depending on the spectrum of the images. In the case of RGB-RGB images, we can notice that there are a lot of similarities between the two images. Generally, in this domain, the main difficulties are with repetitive patterns, occlusions and textureless areas. However, it is fairly easy to match pixels between two RGB images, as the results on public benchmarks are very good [14], [15]. Next, for the case of RGB-NIR (near infrared) images, we observe that there is less common information between the images, but it is still possible to note common objects between both spectrum, as textures are shared and object edges are well defined in both images.
Lastly, if we take a look at RGB-LWIR (long wavelength infrared or thermal IR) images, we see that there are very few common features between images, mainly the people whom we can match, but every object in the background, if not emitting heat, is very hard to see in the LWIR image. This makes the matching of pixels between both domains much harder than in the previous domain pairs stated above. Our proposed method operates on RGB-LWIR image pairs, which means that we need a method that is able to learn to match features between those domains.
In this paper, we present a new convolutional neural network (CNN) architecture inspired by [16], [7] able to do disparity estimation between RGB-LWIR image pairs. Our model is a domain siamese network, meaning that each image of the stereo pair has its own feature extractor, but both feature extractors have the same components i.e. there is no weight sharing between the branches of the siamese network. We are not able to do dense disparity estimation because of the nature of our datasets, which are not densely annotated. That is why we will work with patches instead of images. Our model takes two small square patches as input, and extracts features from those resulting in a feature vector for each image patch. We do two operations on the feature vectors: 1) we do a correlation product between both vectors and forward the result to the correlation head, 2) we do a concatenation between the two vectors and forward it to the concatenation head. Using two different complementary techniques gives more robustness to our network, leading to better performance when compared to using only correlation or concatenation. Both the correlation and concatenation heads consist of fully connected layers outputting the probability of both patches being the same or not. Each classification head has its own loss function, and at testing, we use both classification heads to get the disparity predictions. The source code of our method will be available online at https:// github.com/ beaupreda upon publication.
Our paper has the following two main contributions: • We propose a new siamese CNN architecture able to do sparse disparity estimation between multispectral RGB-LWIR image pairs. Our architecture extract features from both image domains and uses both concatenation and correlation to get a probability representing if the input patches are the same or not. • Experiments performed on the LITIV 2014 [13] and LITIV 2018 [17] datasets show that our model is able to achieve better performance than all past methods, either using classical descriptors or methods based on CNNs.

A. Multispectral Images
Until recently, the best way to do disparity estimation between the RGB and LWIR domains was with handcrafted feature descriptors, such as SIFT [18] or mutual information [19]. Mutual information is an example of a windowbased method, meaning that the descriptor is computed as a similarity between pixels inside two candidate windows. The method consists in computing statistics based on the cooccurrences of the pixels inside the windows. This method was able to get the best results among all handcrafted feature descriptors according to a study [13]. The sum of squared difference (SSD) [13] is another example of window-based method. Other methods like local self-similarity (LSS) [20], histogram of oriented gradients (HOG) [21] and SIFT [18] are based on modeling the distribution of data. LSS is a local descriptor that captures the self-similarity of regions with colors and textures, which makes it the best descriptor in its category [13]. SIFT and HOG are both based on gradients and are invariant to illumination changes which is beneficial when working with multispectral images.
In the last years, there were also works based on CNNs that were designed for patch matching between RGB and IR domains. It is to note that for visible/IR stereo pair datasets, there is not enough data to train CNNs for endto-end dense stereo matching. The work of [10] gives an interesting comparison of different CNN architectures to do patch matching between the RGB and NIR domains. Aguilera et al. [9] propose a quadruplet network inspired by the popular triplet networks [22]. Quadruplet networks take four input patches, creating two positive pairs and four negatives ones, leading to top performance on the VIS-NIR benchmark [12]. In the same task, AFD-Net [8] uses a model based on metric learning using the difference of features between the RGB and NIR images. Zhi et al. [23] worked with a new RGB-NIR dataset made up of road scenes. It is an unsupervised method that transforms the RGB image into a pseudo-NIR image and uses projection of the pseudo image to do self-supervision. It also uses segmentation to differentiate the materials in the scene. Beaupre et al. [16] proposed a dual siamese network, effectively working with four inputs to enforce consistency between the predictions of the left and right subnetworks.

B. Stereo Matching
We will focus on works that use CNNs since they are the most relevant to our work. Zbontar et al. [3] were the first to Fig. 2. Details of the proposed architecture. We have two CNNs doing domain feature extraction to obtain feature vectors. These vectors are then merged with a correlation and concatenation operation before being passed to the classification heads, which are responsible of classifying the two inputs either as the same or not with a probability score.
propose using a CNN to extract features from images instead of using handcrafted feature descriptors. They created a cost volume with the features from the CNN with SGM [24] to obtain the disparity map. Luo et al. [4] used a correlation product to merge features from the left and right images, resulting in much faster stereo matching than [3]. Kendall et al. [5] were the first to propose an end-to-end architecture for stereo matching which is now the default architecture choice for state of the art methods on public benchmarks [15]. They used 3D convolutions to learn from the context of features, before doing a regression in order to get the disparity map. Chang et al. [6] also wanted to improve disparity estimation with help from the context, so they used a spatial pyramid pooling module to extract features at multiple scales and used an hourglass network to regularize the cost volume. The methods of [25] and [26] both train a network jointly with another task to improve disparity, namely segmentation and edge detection, respectively. Both papers hypothesize that most errors in disparity estimation come at object borders, so using another task that defines boundary between objects will improve stereo matching. Zhang et al. [27] focus on the aggregation step by proposing two new layers: semi-global guided aggregation layer (SGA) and local guided aggregation layer (LGA). SGA is basically a version of SGM, but with learnable parameters, while LGA learns to refine thin structures. Guo et al. [7] focus on the cost volume step by creating two cost volumes: one from the concatenation of features and the other one from the correlation of features. These are then merged in a group-wise manner to form a combine volume of rich features, which leads to better performance than only using concatenation or correlation.

III. METHOD
This section presents an overview of the proposed method, consisting of a domain siamese network with a classification branch and a correlation branch, as well as an explanation of our training and testing methodology, and the implementation details. Figure 2 illustrates the global architecture of our model.

A. Network Architecture
Our network architecture is inspired by previous work in RGB-RGB disparity estimation, as well as RGB-LWIR disparity estimation. It is based on the popular siamese architecture in stereo estimation, where a network takes two inputs and extracts features from these. We modified this base architecture for our needs. Usually, siamese networks share the same feature extractor between the two inputs. However, in our case, we found that having a different feature extractor for each domain gave better results since RBG and LWIR images have different visual appearance. This same conclusion was reached in [28] for matching keypoints between the RGB and NIR domains.
Our architecture takes two square patches as inputs, one from the RGB image and the other from the LWIR image, which will be referred to as P RGB and P LW IR throughout the paper. Each patch is forwarded into their respective domain feature extractors, one for the RGB features, and the other one for the LWIR features. Both of these CNNs have the exact same structure, which is detailed in table I, but each have their own weights. We know from numerous papers that weight sharing between siamese networks is a common practice, specifically in RGB-RGB stereo vision. However, we found that the model performed better when each patch had its own CNN to extract features. We suppose this is because, as mentioned in section I, there is not a lot of common information between images of the RGB-LWIR domains. In the case of images in the RGB domain, sharing weights is logical since we want the network to learn to find similar features from the images. In our multispectral case, since the content of both images can be quite different, we believe it is preferable to extract features separately and then combine them with a fusion operation. The CNNs each produce a 256D feature vector, f RGB and f LW IR , representing P RGB and P LW IR respectively. With these feature vectors, we proceed to do two different fusion operations: correlation and concatenation. These two operations are the most common operations in disparity estimation to join features from both images. Each has advantages over the other. Correlation is usually faster to compute and consumes less memory than concatenation, but it loses information i.e. it does not keep all the feature information across the channel dimension. On the other hand, concatenation does not lose any information as the whole channel dimension is kept, at the cost of more memory consumption and longer computation time. It was shown that using both a correlation cost volume and a concatenation cost volume improves performance when compared to using only one of the two [7]. We take inspiration from this work to use both operations to form the merged feature vectors and f corr is computed as the element-wise product between the feature vectors f RGB and f LW IR , so it remains a 256D vector.
On the other hand, f concat is a 512D vector, since both f RGB and f LW IR are concatenated. Both merged vectors are then forwarded into their respective classification heads, one for correlation and the other for concatenation. Their structure is detailed in table I and both of them outputs a 2D probability vector, representing the probability that the two patches are the same or not. This is therefore a binary classification problem.

B. Training
The first step in training the network is to extract training patches P RGB and P LW IR around known ground-truth pixels in rectified stereo pairs. P RGB will be centered on pixel p at location (x, y), while P LW IR will be centered on pixel q at location (x + d, y), accounting for the disparity d, x and y representing the pixel coordinates in the image space. To make our network more robust, we consider as positive matches, two patches that are positioned from one another at d ± 1 in x.
Since we are considering the task as a binary classification problem, we also need samples of negative pairs. In order to create negative pairs, we start by taking all the positive patches located at (x, y) and (x + d, y) and add an offset o to the x values. The range of o is [−30, −10] and [10,30], meaning that we consider negative samples either to the left or the right of the ground-truth pixels. For every positive pair, we create a negative pair at (x + o, y) and (x − d + o, y) so we have a balanced dataset with as many positive samples as negative ones. The value of o is determined randomly following a uniform distribution for each example. All positive and negative samples are then shuffled together.
We use two binary cross-entropy loss functions to train our network, one for the correlation branch, and the other one for the concatenation branch. They are given by where N represents the number of samples, gt i the groundtruth value, being either 1 if the patches are the same or 0 if they are not, and y i the probability of patches being the same or not. The total loss is then given by loss = loss corr + loss concat .

C. Prediction
Since our goal is to predict a disparity, we need to add some operations on top of our network to obtain it. For prediction, we expand the width of P LW IR to take into account the maximum disparity parameter disp max . Half of disp max is added to the width on both side of the center of the original P LW IR patch. P RGB is kept the same size. We forward both patches into the CNNs, leaving us with f RGB a 256D vector and f LW IR a 256 × disp max tensor. Now, for each disparity d. we extract the corresponding feature vector from f LW IR leaving us with two vectors, each of 256D. We then forward both vectors into the FCs layers to obtain probabilities of the vectors being the same or not. We do this process for every disparity d, and only keep the probability of both patches being the same, which leaves us with a probability vector p of size disp max of the patches being the same at every disparity. We   do a disparity regression as in [5] i.e. a weighted sum of the normalized probabilities multiplied by d to obtain our disparity predictionsd corr andd concat for each head, respectively witĥ d, the final disparity prediction, is the mean of the disparity predictions of both branches and is given bŷ

D. Implementation details
We implemented our network with the PyTorch [31] framework, and as stated earlier, the code will be made publicly available online at https:// github.com/ beaupreda. The default patch size is 36 × 36 and the maximum disparity used for testing is 64. We use the Adam [32] optimizer to train our network with backpropagation and a starting learning rate α of 0.01 which is updated to α 2 every 40 epochs. We trained our model on every fold of data for 200 epochs, which takes a little more than 12 hours for each fold on a single NVIDIA Titan X.

IV. EXPERIMENTS
This section will present in details the datasets we used to train and test our model, as well as the data augmentation techniques we used to get more data. It will also show the results we got and discuss them with a comparison against other methods.

A. Datasets
We use two datasets to train our network and do the evaluation, namely the LITIV 2014 dataset [13] and the LITIV 2018 dataset [17]. Some examples of images found in both datasets are shown in figure 3. These images show some of the difficulties of the datasets, like occlusions, where the occluded person is less visible in one of the spectrum, making the matching of patches harder. Another difficulty is the difference of textures between the RGB and the LWIR domains, where a checkered shirt appears as of uniform appearance in the LWIR domain. Another difficulty comes from the number of persons in a given scene, since the number of potential matches increases with the amount of people in a video.
The LITIV 2014 dataset is made of three videos, named vid01, vid02 and vid03, each presenting scenes with people with annotated disparities. The amount of subjects in each video varies from one to five, and they are all walking at different depth in the scene, creating occlusions, which is one of the difficulty in this dataset. The videos respectively have 89, 67 and 53 image pairs for a total of 11 166 points in the first video, 7529 points in the second and 6524 points in the third. The LITIV 2018 is also separated in three videos, named vid04, vid07 and vid08. These videos feature one to three subjects walking in a scene with the additional difficulty of them manipulating some objects emitting heat, such as a kettle. There are 117 images for 4252 ground-truth points in the first video (v04), 144 images for 5653 ground-truth points in the second video (v07) and 89 images for 5277 ground-truth points in the third sequence (v08).
We compared the performance of our model against classical methods that do not need any training phase, so these were tested on all available videos. However, in our case, we need to separate data into three sets, namely training, validation and testing. Since we want to have a fair comparisons against all methods, we split the both datasets into three folds, each fold having a distinct testing set as to have the complete dataset tested. Tables II and III show the separations of the folds with the number of data points in each fold for the LITIV 2014 and LITIV 2018 datasets, respectively. The separation scheme is fairly simple: for a given dataset, we keep one video for testing and use the other two for training and validation. The other dataset is used as training data. For the validation sets, we selected randomly 30 images for LITIV 2014 and 150 images for LITIV 2018.

B. Data Augmentation
One problem with RGB-LWIR multispectral datasets is that there is not a lot of available data to train CNNs. For instance, in our case, we use both LITIV datasets, and obtain a little more than 40 000 ground-truth points without any data augmentation. However, with the way we train our network and two data augmentation operations, we are able to effectively increase by a factor of 20 the amount of training data.
The first data augmentation operation that we did is what we call the cross duplication. This process is illustrated in figure 4 Fig. 4. Illustration of our cross data augmentation method. Basically, we add four training points from one pixel from which we have the ground-truth, giving us more training data to reduce overfitting. and basically consists in giving the same disparity to neighbors of a given ground-truth pixel. If we have a ground-truth pixel p at location (x, y) with disparity d, we simply create four new ground-truth points with the same disparity d at locations (x ± 1, y ± 1), giving the shape of a cross to our groundtruth points. We remove any duplicates that this process can create, as two ground-truth point having a common neighbor will duplicate a new point. This operation basically adds a factor of five to the number of original disparity points. One important thing to note, however, is that from the original 40 000 points, some of them cannot be used in this step since they are too close to the image border, and we cannot extract patches around those points. Since all our points are on people, this does not happen very often, mostly when a subject enters the scene.
The second data augmentation operation we performed is the mirroring of images i.e. flipping the images around the y axis. This operation doubles the amount of data points from the vanilla data. Now, if we combine both data augmentation technique and use the fact that we have to create negative samples for each ground-truth point that we have (doubles the number of data), these operations give us a factor of 20 when compared to the original training data. With this amount of training data, we reduce the chance of overfitting and increase the robustness of our network.

C. Results
The performance measure we use to compare our model to other methods is the recall, which computes the number of predictionsd that our network made that is at a distance of t pixels or less from the ground-truth. We formally define it by where N stands for the number of samples,d i , the disparity prediction for the ith example and gt i the ground-truth of the ith example. This evaluation methodology is the same as the other methods that we compare ourselves to, so we can directly report the results from those papers.  Table IV presents the results from our ablation study which evaluates the performance of our model when only one fusion operation is considered. For the correlation branch only results, we trained our network without the concatenation branch. The same process was applied to the concatenation only results, where only the concatenation branch was considered during training. The last column is our proposed model with both branches present during training, and the final disparity predictiond is the average of the predictions of both heads. The most important result from this table is that using both branches leads to better results for disparity prediction. This is expected since using both correlation and concatenation leads to better extracted features by the CNNs, and therefore better predictions. We also observe that by itself, the concatenation branch has better results than the correlation branch. This result is logical since the concatenation operation keeps more features (512D feature vector) compared to the correlation operation (256 feature vector). Also, it is the same conclusion reached in RGB-RGB disparity estimation where networks who build a concatenation cost volume have better performance than the ones who use a correlation operation. Table VI shows the results of our method compared to a CNN-based method from [16] and several methods based on handcrafted feature descriptors, as reported in [13]. The recall obtained by our proposed model is the weighted average (by the number of test points) of the recalls obtained for the three separate folds reported in table IV. We can see that our proposed method surpasses every other method by a large margin. We improve the past results based on deep learning by a little bit more than 0.12, while also having an improvement of around 0.07 over mutual information [19], which was the best on the LITIV 2014 dataset. We also achieve this performance while working with less pixels than any other methods. Our performance is significantly superior to siamese CNNs with around the same number of pixels to make our decision, but if we compare our small 36 × 36 patches to the other methods, we can notice that they use up to four times more pixel, and yet, we are able to obtain better disparity predictions. Table V presents the results on the LITIV 2018 dataset against two approaches, one being classical, while the other is a sophisticated cosegmentation method applying belief propagation to optimize disparity estimation and segmentation jointly. Here, we can see that our method is superior two the other two approaches, having an overall better performance of more than 0.20 for the smallest threshold, and more than 0.30 for the bigger one.
We believe this demonstrates that our method is robust and that CNNs-based methods are able to be competitive on hard tasks like disparity estimation between RGB-LWIR image pairs. We believe that these performances are due to mainly two features of our model: first, the domain feature extractors, which are responsible to get features from both domains separately and the use of two fusion operations which forces the network to learn better representations of the multispectral images.

V. CONCLUSION
In this paper, we presented a new model able to do sparse multispectral disparity estimation between image pairs from the RGB and LWIR domains. Our model uses a siamese domain feature extractor, which extracts features independently for both images, as opposed to traditional siamese networks who shares the same weights for both images. We believe that it is preferable to keep the feature extractions separate in the case of images from different spectral domains. We use two operations to merge the features extracted by our CNNs, namely correlation and concatenation. Using the two jointly is shown to improve the performance of our network. We believe that by using the two fusion operations, we augment the learning capability of our network and make it more robust which leads to better performance. Evaluation on public datasets shows that our method is significantly better then all the other methods tested for sparse multispectral disparity estimation.