An Improved NMS-Based Adaptive Edge Detection Method and Its FPGA Implementation
For improving the processing speed and accuracy of edge detection, an adaptive edge detection method based on improved NMS (nonmaximum suppression) was proposed in this paper. In the method, the gradient image was computed by four directional Sobel operators. Then, the gradient image was processed by using NMS method. By defining a power map function, the elements values of gradient image histogram were mapped into a wider value range. By calculating the maximal between-class variance according to the mapped histogram, the corresponding threshold was obtained as adaptive threshold value in edge detection. Finally, to be convenient for engineering application, the proposed method was realized in FPGA (Field Programmable Gate Array). The experiment results demonstrated that the proposed method was effective in edge detection and suitable for real-time application.
Due to the broad application fields, such as in industry, spaceflight, medicine, and military [1–3], the study on edge detection became a hot issue in image processing. At present, the researches on edge detection are mainly focused on mathematical morphology methods [4, 5] and gradient methods [6, 7]. The morphology based edge detection methods can effectively detect edges; however, complex iterative operations in these methods are the main obstacle for real-time applications.
On the other hand, the gradient based edge detection methods are more suitable for engineering implementation due to relatively simple calculation. Many improved edge detection algorithms based on gradient calculation such as Roberts operator , Sobel operator , Canny operator , and Laplacian operator  were proposed successively. For example, based on the Canny operator, Yu et al.  designed an edge directional interpolation method to process the MRI (magnetic resonance image) of fetal spinal column. Wang et al.  improved the Sobel edge detection algorithm by using NMS algorithm. Wiehle and Lehner  proposed an edge detection algorithm for high definition satellite images based on Sobel operator.
Owing to the advantages in high calculation speed and parallel processing, the FPGA became a useful hardware realization tool for real-time images processing [15–18]. Li et al.  designed a data block accelerator to optimize the Sobel operator in FPGA, and this method could be applied in real-time edge detection.
In previous works, the accuracy and speed of edge detection methods were improved from different aspects. Nevertheless, edge detection threshold has not been given much concern. In this paper, an adaptive edge detection algorithm based on the NMS was proposed. In this method, the gradient image was processed by utilizing NMS method. Then, the elements values of gradient image histogram were mapped into a wider value range by a certain power map, which can help calculate the threshold accurately.
According to the maximal between-class variance, the threshold was calculated and inverse mapped to original gradient map. The inverse mapped threshold was considered as adaptive threshold value in edge detection. Finally, for application in engineering fields, the proposed method was realized in FPGA. The experiment results showed that the proposed method has higher processing speed and detection accuracy.
2. The Adaptive Edge Detection Algorithm
The flow chart of edge detection algorithm was shown in Figure 1. Gradient image was computed from original image data by Sobel operator. Then, NMS method was employed to process gradient image. Because gradient values in processed gradient image clustered in low value range, histogram mapping was performed to obtain a more spread distribution. After histogram mapping, the threshold in mapped histogram was calculated by using OTSU method. By inverse mapping, adaptive threshold was achieved. Double thresholds computed from threshold were applied to determine potential edges.
2.1. Gradient Calculation and NMS Processing
The original image was divided into 5 5 subregion. The 3 3 Sobel operator of vertical, horizontal, and two diagonals (0°, 45°, 90°, and 135°) was employed to calculate the gradient, as shown in Tables 1(a), 1(b), 1(c), and 1(d).
The gradient of a 3 3 image region (Table 1(e)) can be computed by multiplying the element value with the corresponding value in four directional Sobel operators. Then, four gradient values with direction were calculated as in the following equation:where , , , and are the gradient amplitude with 0°, 45°, 90°, and 135°, respectively. The maximal value and its direction were selected as gradient amplitude as shown in (2) and gradient direction, respectively, in the following process:
For 5 5 subregion, nine gradient amplitudes and the directions according to each gradient amplitude can be computed, as shown in Table 2.
The nonmaximum suppression method set the gradient values of central point to 0 if the gradient amplitude of central point is not local maximal, which indicates the location with the sharpest change of intensity value. According to the direction, the final gradient of the central point can be calculated by (3) as follows:where is the direction of central point and is the gradient amplitude of the central point after NMS processing.
By traversing the whole image, the NMS processed gradient image was achieved. The larger value of gradient amplitude means more possibility of edge. To improve the accuracy of edge detection, threshold of gradient amplitude should be calculated to determine whether one point is edge point or not.
2.2. The Adaptive Strategy of Threshold Calculation
After NMS processing, gradient amplitude mainly concentrated in the smaller values ranges. The accuracy of edge detection is very sensitive to threshold. Thus, the calculation of threshold is a key step in the proposed method. In this subsection, calculation of adaptive threshold consists of three parts: histogram mapping, calculation of threshold according to maximal between-class variance, and inverse mapping of threshold as shown in Figure 2.
In the step of histogram mapping, the gradient amplitudes were mapped into more widely values ranges. Histogram mapping function was defined as follows:where is the value in original histogram and is the value in mapped histogram. Function round rounds decimal to the nearest integer.
In OTSU method , the optimum threshold separating the two classes was calculated by maximizing the between-class variance. Assuming that the NMS processed image contains two classes of point (edge point or not), the between-class variance can be computed by the following equation: where is the between-class variance, is the total number of pixels of NMS processed gradient image, is the average gradient amplitude, is the number of edge points, and and are the average values of edge points and background points, respectively, in the mapped gradient image.
Furthermore, where is the number of points whose gradient value is .
The average gradient value can be calculated as (8)
and can be calculated as follows: where is equal to .
By traversing from 1 to 254, the value corresponding to the maximum between-class variance is the threshold . Finally, the adaptive threshold in NMS processed image can be obtained by using inverse mapping as follows:
2.3. The Processing of Double Threshold
The double thresholds were designed to determine the true or false edge points in NMS processed image. The threshold value was defined as the mean value between the high threshold and the low threshold. Then, the high threshold and the low threshold can be calculated as the following equations:where is the high threshold and is the low threshold.
In edge detection process, if the gradient value is greater than , it was edge point. If the gradient value is smaller than , it was not considered as edge point. In addition, if the gradient value is between high threshold and low threshold, at least one gradient value of neighborhood points (Table 2) is greater than the high threshold; this point was edge point; otherwise, it was not the edge point.
3. FPGA Implementation
The FPGA implementation scheme was mainly divided into three modules: image storage module, VGA display module, and algorithm executive module. The whole structure diagram was shown in Figure 3.
3.1. Image Storage Module
Image storage module consists of two on-chip ROMs. One was used to store address of pixels, and the other one was used to store the grayscale of the corresponding pixel. This design can reduce image storage space as shown in Figure 4.
3.2. VGA Display Module
VGA display module was designed to realize two main functions. Firstly, it can generate clock signal, blanking signal, line sync signal, and field sync signal for the display . Secondly, it can produce the correct address signal for reading the image data stored in ROM. The module circuit was shown in Figure 5.
3.3. Algorithm Executive Module
Six submodules were designed to realize the edge detection algorithm, including gradient amplitude calculation submodule, gradient direction calculation submodule, NMS processing submodule, histogram mapping submodule, maximal between-class variance calculation submodule, and double threshold processing submodule.
Gradient amplitude calculation submodule and gradient direction calculation submodule were used to calculate the eight neighborhood gradient amplitudes and gradient direction of center point, respectively. NMS processing module was designed to process gradient image. These three submodules were shown in Figure 6.
(a) Gradient amplitude
(b) Gradient direction
(c) NMS processing
Histogram mapping submodule was used to map the histogram of the gradient image. Maximal between-class variance calculation submodule was designed to find the threshold corresponding to maximal between-class variance. Double threshold processing submodule was used to inverse map the threshold and calculate double threshold. Threshold calculation related three submodules and connection were shown in Figure 7.
4. The Experiment Results and Analysis
In this section, the experimental results were analyzed in three aspects: resource usage rate, running duration, and accuracy of edge detection.
4.1. Resource Usage Rate
The DE2-115 education development board (Altera Corporation) with EP4CE115F29C7N chip was used in this experiment. The size of image was 640 × 480 pixels. The system resource usage was shown in Table 3. Note that the resource usage of the whole system is less than the sum of the two subsystems, because of the repetition usage of the logical elements in subsystems. The logical elements used were 11% of the whole elements in running time, which suggested that the resource usage rate of proposed method is relatively low.
4.2. Running Duration of Each Process
In previous works, adaptive edge detection algorithm  and a simple Canny algorithm  were realized by FPGA. Comparison of running duration with those works was shown in Table 4. Although the working frequency of proposed method was relatively lower, the running duration of each process was shorter, which demonstrated the higher speed of proposed algorithm.
4.3. Accuracy of Edge Detection
Image Lena (Figure 8(a)) and image Flower (Figure 9(a)) were used in edge detection experiments. The detection results of the two images were shown in Figures 8(b), 8(c), and 8(d) and Figures 9(b), 9(c), and 9(d), respectively. Compared with the other two methods, the detected edge by proposed method is thinner than the other methods.
The positive rates of edge detection were calculated to evaluate the effect of the proposed method, as shown in Table 5. Compared with Roberts operator, Prewitt operator, Sobel operator, LoG operator, and Canny operator, true positive rate by proposed method is the highest and false positive rate is relatively lower. These results suggested that the proposed method can detect the edge more accurately.
An improved adaptive edge detection algorithm based on the NMS method was proposed in this paper. In the proposed method, a power map function was defined to map the NMS processed gradient image. Then, adaptive threshold corresponding to maximal between-class variance was calculated based on the mapped histogram. Additionally, the proposed method was realized in FPGA. Experimental results showed that this method has higher processing speed and better accuracy, which was suitable for application in real-time image processing.
Conflict of Interests
The authors declare that there is no conflict of interests regarding the publication of this paper.
W. Shi, X. Zhu, and G. Zhu, “Adaptive edge detection algorithm of MRI image based on morphology,” Chinese Journal of Scientific Instrument, vol. 34, no. 2, pp. 408–414, 2013.View at: Google Scholar
Y. Wu, Y. Song, and H. Zhou, “Edge detection of combustion flame images based on anisotropic mathematical morphology,” Chinese Journal of Scientific Instrument, vol. 34, no. 8, pp. 1818–1825, 2013.View at: Google Scholar
Y. Liu and X. Cheng, “A new edge detection algorithm using wavelet and threshold method,” Journal of Information & Computational Science, vol. 6, no. 4, pp. 1759–1766, 2009.View at: Google Scholar
L. G. Roberts, “Machine perception of three-dimensional solids,” in Optical and Electro-Optical Information Processing, vol. 20, pp. 31–39, MIT Press, 1963.View at: Google Scholar
I. Sobel, Camera Models and Machine Perception, Department of Computer Science, Stanford University, Stanford, Calif, USA, 1970.
J. Canny, “A computational approach to edge detection,” IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 8, no. 6, pp. 679–698, 1986.View at: Google Scholar
W. Wang, S. Zhu, and W. Tang, “Adaptive non-maxima suppression edge detection algorithm and FPGA design to achieve,” Chinese Journal of Scientific Instrument, vol. 35, no. 8, pp. 1926–1930, 2014.View at: Google Scholar
Z. Hu, D. Wang, Q. Zhao, and Q. Zhu, “Design of portable intelligent image acquisition system based on SOPC,” Chinese Journal of Scientific Instrument, vol. 31, no. 2, pp. 371–376, 2010.View at: Google Scholar
Y. Guo, Y. Su, and C. Gao, “Design and implementation of real time infrared image collection system based on FPGA,” Chinese Journal of Scientific Instrument, vol. 32, no. 3, pp. 514–519, 2011.View at: Google Scholar
L. Zhang and C. Ling, “Application of sobel edge detection based on FPGA,” Embedded Technology, vol. 37, no. 8, pp. 26–29, 2011.View at: Google Scholar
Z. Li, C. Liu, and M. An, “The design of sobel image edge detection based on FPGA,” Modern Scientific Instruments, vol. 2012, no. 4, pp. 84–86, 2012.View at: Google Scholar
J. Jiang, D. Yu, and J. Wang, “The CCD color image acquisition and displaying system of electronic endoscope based on FPGA,” Chinese Journal of Scientific Instrument, vol. 21, no. 1, pp. 50–53, 2000.View at: Google Scholar