## 2 Materials and Methods
### Image Dataset  
To develop an automated detection method using Mask R-CNN, we collected 42 healthy subjects (1208 images) and 93 cases (94 lesions, 533 images) of gastric cancer for preoperative examinations between 16 July 2013 and 30 August 2017 in Fujita Health University Hospital. When a lesion was found using endoscopy, the lesion was photographed from various directions. Additionally, two lesions were found in one patient. As a result, an average of 5.66 images were collected per lesion. Table 1 shows the characteristics of gastric cancer patients and lesions according to the Japanese classification of gastric carcinoma [22].  
For healthy subjects, we reassessed the cases diagnosed as without any abnormality by the endoscopists and characterized a case as \"healthy\" when there was no specific lesion, such as a polyp or tumor, and a regular arrangement of collecting venules was observed in the amucosa [23]. We reassessed the cases diagnosed as chronic gastritis by the endoscopists and characterized them as \"gastritis\" when there was no specific lesion, such as a polyp or tumor, and with atrophy C-1 or severe grade of Kimura-Takemoto classification for chronic gastric mucosa atrophy [24].  
Images were obtained using upper endoscopes (GIF-290Z, GIF-HQ290, GIF-XP290N, GIF-260Z; Olympus Medical Systems, Co., Ltd., Tokyo, Japan; and EG-L600 ZW7; Fujifilm Corp., Tokyo, Japan) and standard endoscopic video systems (EVIS LUCERA CV-260/CLV-260, EVIS LUCERA ELITE CV-290/ CLV-290 SL; Olympus Medical Systems; and VP-4450 HD/LL-4450; Fujifilm Corp.).  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Characteristics** & **Number of Cases** \\ \hline Tumor location & \\ Upper third & 9 \\ Middle third & 52 \\ Lower third & 33 \\ Macroscopic types & \\ Type 0-I & 0 \\ Type 0-lla & 10 \\ Type 0-IIb & 0 \\ Type 0-IIc & 63 \\ Type 0-III & 0 \\ Type 0 mixed (0-lla + IIc, IIc + III) & 21 \\ Depth of tumor invasion & \\ T1a (mucosa) & 71 \\ T1b (submucosa) & 23 \\ Histopathological classification & \\ Differentiated & 75 \\ Undifferentiated & 13 \\ Mixed & 6 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Characteristics of patients and lesions in the gastric cancer test image set according to the Japanese classification of gastric carcinoma.  
Figure 1: Schematic of the study outline.  
The size of the images ranged from \(640\times 480\) to \(1440\times 1080\) pixels; these were standard white-light images stored in JPEG format. Because the image matrix size differed depending on the case, all the images were downsampled to \(256\times 256\) pixels. They were then trimmed in the shape of a circle (Figure 2). The circular view can easily increase the number of images by rotation, as described below. Subsequently, the ground truth was specified by a single expert endoscopist (TS) and board-certified by the Japan Gastroenterological Endoscopy Society. The ground truth was presented as a label image. All label images were created using the original Python program.  
Generally, the training of deep learning requires a large amount of data, as a small dataset may cause overfitting. To prevent this, we augmented the training dataset using image processing [25]. Because the endoscopic images are direction-invariant, augmentation operations such as image rotation and flipping were also performed. In-house software was used for automatic data augmentation. Here, the rotation angles were set to \(10^{\circ}\) and \(6^{\circ}\), respectively, to adjust the bias in the number of images of healthy subjects and gastric cancer patients.