## 2 Materials and Methods
### Image Preprocessing and Data Augmentation  
The four independent masks are preprocessed before being combined into a single segmentation mask to ensure that there is at least one background pixel between each instance, which is required to encode hand separation using weight maps. Combining the mask directly leads to two problems. First, there are overlapping masks, where in extreme cases, a single pixel partially belongs to two classes in the original ground truth. Second, some masks are adjacent without actually overlapping. The dataset masks, with values ranging from 0 to 255, blob interiors have a value of 255, background pixels are encoded with a value of 0, and the borders that separate these have intermediate values. Masks are first binarized, to encode whether a pixel belongs to a hand or not. A threshold of 128 is empirically chosen as a value that produces regular and coherent hand borders. Once the masks are binarized, dilations (\(\oplus\)) and logical operations AND (\(\wedge\)), OR (\(\vee\)), and NOT (\(\
eg\)) will be used to detect and eliminate conflicts between  
Figure 1: Images from the EgoHands dataset with their segmentation masks. **(a)** Jenga game in the backyard. **(b)** Card game at the office. instance masks. Conflicting regions are obtained from dilated versions of the original masks, rather than the original masks directly; this allows removing conflicts from overlapping and also non-overlapping masks. A round \(5\times 5\) kernel (\(k\)) that preserves smooth borders is used to dilate these masks. \[k= \begin{bmatrix}0&0&1&0&0\\ 0&1&1&1&0\\ 1&1&1&1&1\\ 0&1&1&1&0\\ 0&0&1&0&0\end{bmatrix} \]  
Let \(A\), \(B\), \(C\), and \(D\) denote the four segmentation masks associated with an image. Their dilated versions, denoted as \(A^{d}\), \(B^{d}\), \(C^{d}\), and \(D^{d}\), are calculated as follows:  
\[A^{d} =A\oplus k \tag{1}\] \[B^{d} =B\oplus k\] (2) \[C^{d} =C\oplus k\] (3) \[D^{d} =D\oplus k \tag{4}\]  
Then, the intersection \(R\) of any pair of these dilated masks and their dilation \(R^{d}\) are obtained,  
\[R_{0} =A^{d}\wedge(B^{d}\lor C^{d}\lor D^{d}) \tag{5}\] \[R_{1} =B^{d}\wedge(C^{d}\lor D^{d})\] (6) \[R_{2} =C^{d}\wedge(D^{d})\] (7) \[R =R_{0}\lor R_{1}\lor R_{2}\] (8) \[R^{d} =R\oplus k \tag{9}\]  
Finally, the processed mask \(M\) is the logical union of \(A\), \(B\), \(C\), and \(D\), representing the original data, excluding the dilated conflicting areas \(R^{d}\),  
\[M=(A\lor B\lor C\lor D)\wedge\
eg R^{d} \tag{10}\]  
Thus, the conflicting areas become part of the background. Images are then re-scaled to a resolution of \(640\times 368\) pixels to increase throughput of the final model. Pixel weight maps are then used on top of a per-pixel loss function to emphasize the importance of pixels separating two blobs, forcing the network to learn this separation (Figure 2). Increasing weight in certain background regions further amplifies class imbalance, hence the base weight of background pixels has been reduced to 0.95 compared to 1.0 for hand pixels. This value of 0.95 was experimentally determined to achieve a balanced rate of false positives (\(FP\)) and false negatives (\(FN\)) in an initial test. The weight of background pixels is, therefore,  
\[B^{d} =B\oplus k\]0  
where \(w_{c}\) represents the base weight of background pixels, \(w_{0}\) is a multiplier, \(\sigma\) is a reference distance in pixels, and \(d_{1}\) and \(d_{2}\) are distances in pixels from the current pixel to the nearest two hands. The chosen values were \(w_{c}=0.95\), \(w_{0}=12.0\), and \(\sigma=5.0\). The exponentially decaying nature of the weight function ensures that the value over the base weight is only significant when both \(d_{1}\) and \(d_{2}\) are sufficiently small. These parameters lead to a maximum pixel weight of approximately 13 times the base weight. Datasets used in computer vision typically contain a limited number of images because their acquisition process is often non-automatable. This is particularly true for segmentation tasks, which require highly precise labels.