# Two-Stage Deep Learning Method for Breast Cancer Detection Using High-Resolution Mammogram Images
## 3 Methodology
### RoI Generation  
To improve the detection accuracy, smaller patches (i.e., RoIs) are generated from the original mammogram. This consists of two steps--breast area extraction and square patches generation. In the majority of mammogram images, 32% to 56% pixels are background pixels, which do not add any contribution to breast cancer diagnosis. Therefore, we can crop the breast region accurately using image processing tools. This image processing step inputs the original mammogram and outputs extracted bounding box (\(x\), \(y\), \(w\), \(h\)), where \(x\), \(y\) represents the top-left coordinate of the box and \(w\) and \(h\) denote width and height of  
Figure 1: Overall process of our two-stage breast cancer detection method. Red boxes denote the bounding boxes of detected tumors. the box, respectively. Given that all breast masses and micros (e.g., cysts, calcification) are included inside this extracted area, it can serve as our primary RoI. Next, using the obtained bounding box for the breast region (\(x\), \(y\), \(w\), \(h\)), we generate \(n\) square patches. Figure 2 illustrates how square patches are obtained from the extracted breast area (for simplicity, only the case of \(h>w\) is presented in the figure). When \(h>w\), all patches are generated by sliding down the square box vertically (from top to bottom), meaning that the \(x\) coordinate does not change. Moreover, since we generate _square_ patches, their width and height are the same (i.e., both are \(w\)). Hence, to represent each patch, only \(y\) coordinates are computed. First, the number of patches, \(n\), is determined by Equation (1). \[n=max([w/h]+1,\ [h/w]+1) \tag{1}\]  
where \(max\) (\(\cdot\)) is a function that returns the maximum of values and \([\cdot]\) denotes a standard rounding function. The increment (\"+1\" term) in the equation assures each tumor is included within at least one square patch. The details of patch generation are shown in Algorithm 1. The coordinates of the first and last patches are known (lines 4-5 and 10-11); therefore, depending on \(n\), the remaining patches are computed. In a similar fashion, when \(h<w\), we move the square horizontally (from left to right) to generate patches (i.e., both width and height are \(h\); the \(y\) coordinate does not change; \(x\) changes according to \(n\)), as shown in lines 10-14. ```
1:Input:\(n\), (\(x\), \(y\), \(w\), \(h\))
2:Output: list of bounding boxes, \(bbox[]\)
3:if\(h>w\)then
4:\(bbox[0]\)\(\leftarrow\)\(x\), \(y\), \(w\), \(w\)
5:\(bbox[n-1]\)\(\leftarrow\)\(x\), \(y+h-w\), \(w\)
6:for\(i=1\) to \(n-2\)do
7:\(bbox[i]\)\(\leftarrow\)\(x\), \(y+i\times(h-w)/(n-1)\), \(w\), \(w\)
8:end
9:else
10:\(bbox[0]\)\(\leftarrow\)\(x\), \(y\), \(h\), \(h\)
11:\(bbox[n-1]\)\(\leftarrow\)\(x+w\) - \(h\), \(y\), \(h\), \(h\)
12:for\(i=1\) to \(n-2\)do
13:\(bbox[i]\)\(\leftarrow\)\(x+i\times(w-h)/(n-1)\), \(y\), \(h\)
14:end
15:end

Figure 2: Example of generating square patches for \(h>w\) case. The far-left image shows the output bounding box of breast extraction (\(x\), \(y\), \(w\), \(h\)). The second image shows the first square patch’s bounding box given as (\(x\), \(y\), \(w\), \(w\)). Next, patches are obtained by sliding down the square, as indicated by the arrow. The far-right image shows three (\(n=3\)) square patches (highlighted in light blue, dashed green, and yellow). ### Tumor Detection

After we obtained all patches, breast tumors are detected using object detection methods. Generally, any state-of-the-art object detection model can be employed, such as You Only Look Once (YOLO) [23], SSD [16], Region Based Convolutional Neural Network (R-CNN) [24; 25] models, and their variants. In our study, Faster R-CNN [25] is used as it performed slightly better than YOLO and SSD models for our dataset (refer to Table 2). Moreover, Mask R-CNN [24] is also another option to consider as it can determine corresponding masks (segmentation) for detected tumors, which can be useful for medical reporting.