# Contrast-Invariant Edge Detection: A Methodological Advance in Medical Image Analysis
## 3 Proposed Methods
After bit-plane decomposition, we obtain the 3 MSB planes of the grayscale image. \[I_{p}(x,y)=\sum_{i=0}^{7}B_{i}(x,y)\cdot 2^{i}\] (7)  
\[B_{i}(x,y)=\frac{I_{p}(x,y)\delta 2^{i}}{2^{i}},\quad i\in\{7,6,5\} \tag{8}\]  
* Step 2: This step is the 3 \(\times\) 3 neighborhood analysis and process on 3 MSB planes. After obtaining the 3 MSB planes, we perform the 3 \(\times\) 3 neighborhood analysis and process for the 3 MSB planes to obtain the edge detection result of each plane. The 3 \(\times\) 3 neighborhood can fully consider the local information around a pixel to more accurately identify whether it is an edge point. To obtain more efficient edge detection results, we utilize the integral image technique to accelerate the processing procedure of the 3 \(\times\) 3 neighborhood. First, we calculate the integral image of each entire bit plane. For each pixel point \((x,y)\) on the bit plane, the integral image of the bit plane \(I_{b}(x,y)\) is calculated by Equation (9). Here, \(B_{i}(m,n)\) represents the pixel value at position \((m,n)\) on the bit plane. We add up all the pixel values in the rectangular area from the upper left corner to position \((x,y)\) to obtain integral image \(I_{b}(x,y)\) of the entire bit plane. During this calculation process, in order to calculate the integral image of the bit plane more quickly, we can use Equation (10), where \(I_{b}(x-1,y)\) represents the integral sum of the rectangular area to the left of the current point, \(I_{b}(x,y-1)\) represents the integral sum of the rectangular area above the current point, and \(I_{q}(x-1,y-1)\) is the part that has been repeatedly calculated in the upper left corner and needs to be subtracted. Finally, by adding the pixel value \(B_{i}(x,y)\) of the current point, the value of the current point (x,y) in the integral image is obtained. In this way, through Equation (10), the integral value corresponding to each pixel point in the integral image can be efficiently calculated without having to recalculate the sum of the pixels in the rectangular area starting from the upper left corner every time. Second, we use the calculated integral image to determine the sum of pixel values in the 3 \(\times\) 3 neighborhood of each pixel. For the pixel point at the position \((x,y)\), the sum of pixel values in its 3 \(\times\) 3 neighborhood \(I_{b}(x,y)\) can be calculated by Equation (11). This method of calculating the sum of the 3 \(\times\) 3 neighborhood using the integral image improves the speed compared to calculating the pixel values in the \(3\times 3\) neighborhood one by one. Because it only needs to perform simple addition and subtraction operations on the values of four specific positions in the integral image to obtain the sum of the \(3\times 3\) neighborhood, avoiding the repeated summation operation of the 9 pixels in the \(3\times 3\) neighborhood one by one, and improving the computational efficiency. Based on the sum of the neighborhood \(S_{i}(x,y)\), we determine whether the pixel is an edge point according to the Equation (12). Here, \(B_{i}^{\prime}(x,y)\) represents the edge detection result of the bit plane. If the sum of neighborhood \(S_{i}(x,y)\) of a pixel is less than or equal to 2 or greater than or equal to 7, then the pixel is set to 0 which is the background, otherwise it is set to 1 which is the edge. When the sum of the values in the \(3\times 3\) neighborhood is 0 or 9, the current pixel point is regarded as the background. When the sum of the values in the neighborhood is greater than 1 and lesser than 8, the current pixel point is set as an edge point. Such a judgment condition is relatively loose, which identifies too many edge points and thus results in thicker edges. When the sum of the values in the neighborhood is greater than 3 and lesser than 6, the current pixel point is set as an edge point. Such a judgment condition is relatively strict and sometimes may lead to the loss of some edge points.