Keywords DM642;; Sobel operator; Program optimization; Image edge detection
1 Introduction
Edge is one of the most important features in an image, and it is an important basis for computer vision, pattern recognition and other research fields. Most of the main information of the image exists in the edge of the image, which mainly shows the discontinuity of the local characteristics of the image. It is the place where the gray level changes strongly in the image, that is, the signal usually changes strangely. The classical edge detection algorithm is a differential algorithm, which uses the first derivative at the edge to take the extreme value, and the second derivative takes the zero crossing at the step edge or takes the extreme value at the roof edge. Image edge detection has always been a hot and difficult point in image processing.
In recent years, with the development of mathematics and artificial intelligence technology, various types of edge detection algorithms have appeared, such as neural network, genetic algorithm, mathematical morphology and other theories applied to image edge detection. However, due to the contradiction between detection accuracy, edge positioning accuracy and noise immunity in edge detection, and there is no unified standard for the accuracy of edge detection results of different algorithms, satisfactory results have not been achieved so far. In addition, with the development of network and multimedia technology, the image database has gradually become very large; However, due to the different changes of targets and backgrounds in real-time images, how to accurately locate and extract the edges of real-time images has become a problem that people must face. With the development of DSP chip processing technology, especially the improvement of image processing, such as TMS320C6000 series, it is possible to realize efficient real-time edge detection [5]. Among the classical edge detection algorithms, Sobel edge detection algorithm is widely used because of its advantages of small calculation, simple implementation, fast processing speed and smooth and continuous edges. According to the performance of Sobel algorithm, with the help of TMS320DM642 processing chip [3], the edge detection algorithm is improved and the program is optimized to meet the real-time requirements.
Improvement of 2 Sobel edge detection algorithm
The classical Sobel image edge detection algorithm is completed by using two direction templates to perform neighborhood convolution with the image in the image space. One of these two direction templates is to detect vertical edges, and the other is to detect horizontal edges. The basic principle of the algorithm: because the brightness changes greatly near the edge of the image, those pixels in the neighborhood whose gray level changes exceed a certain threshold th can be regarded as edge points. The advantages of Sobel algorithm are simple calculation and high speed. However, because only two direction templates are used, only horizontal and vertical edges can be detected, so this algorithm is not effective for image edge detection with complex texture. At the same time, the classical Sobel algorithm thinks that every pixel with a new gray value greater than or equal to the threshold is an edge point. This judgment basis is unreasonable, which will lead to misjudgment of edge points, because the new gray value of noise points is also very large.
2. 1 image weighted median filtering
Because the edge and noise in the image are both high frequency components in frequency domain, it is necessary to filter the image before edge detection to reduce the influence of noise on edge detection. Median filtering is a nonlinear signal processing method [2], which is often used to protect edge information in image processing; Ensure the filtering effect. Weighted median filtering: first, sort each window, take an appropriate proportion and fit the curve. The slope of the fitting curve represents the image characteristics of this window, and then the appropriate weights are selected according to the characteristics of each part of the image.
2.2 Add direction template
In addition to the horizontal and vertical directions, the edge of the image has other directions, such as 135o and 45o. In order to improve the edge detection accuracy of a pixel, the number of direction templates can be increased from two to eight, that is, six direction templates are added on the basis of the classical direction template, as shown in figure 1.
2.3 Edge Location and Noise Removal
Usually, the edge of an object is continuous and smooth, and the edge has two characteristics: direction and amplitude, while the noise is random. You can always find another edge point along any edge point, and the gray level difference and direction difference of the two edge points are similar. However, the noise is different. Generally speaking, it is difficult to find a noise point similar to its gray value and variance along any noise point [4]. Based on this idea, noise points and edge points can be distinguished. For a digital image f(x, y), each pixel in the image is calculated by the Sobel operators of the above eight direction templates, and the maximum value is obtained as the new value of the point, and the direction represented by the template corresponding to the maximum value is the direction of the pixel point. If | f (x, y)-f (x+I, y+j) | > TH2, for any I = 0, 1,-1; If j = 0, 1 and-1 are both true, it can be judged that the point (x, y) is a noise point. Fig. 2 shows the software flow chart of the improved algorithm of the image edge detection system.
Figure 1 Eight direction templates for edge detection
Figure 2 System Structure Diagram
Image processing design and algorithm optimization based on TMS320DM642
3. 1 TMS320DM642 The function module and hardware structure of the image processing system.
DSP is designed for high-speed digital signal processing. It adopts an improved Harvard structure (separation of program bus and data bus), and has the characteristics of hardware multiplier, application pipeline technology, good parallelism, instruction and VLIW (Very Long Instruction Word Structure) dedicated to digital signal processing. It can complete real-time digital image processing with a large amount of calculation.
TMS320DM642 is one of the powerful TMS320C6x series recently introduced by TI formula, and it is one of the high performance in the field of fixed-point DSP at present [6]. Its main frequency is 600MHz, 8 parallel operation units, special hardware logic, on-chip memory and on-chip peripheral circuits, and its processing capacity can reach 4800MIPS. Based on C64x kernel, DM642 has many peripheral devices and interfaces, so it is more widely and simply used in practical engineering. The system uses a 50 MHz crystal oscillator as the external clock input of DSP, and generates a frequency of 600 MHz after internal phase-locked loop 12 frequency multiplication. DM642 adopts two-level cache structure (L 1 and L2), which greatly improves the running performance of the program. On-chip 64-bit EMIF interface can seamlessly connect SDRAM, Flash and other storage devices, which greatly facilitates the movement of a large amount of data. More importantly, as a dedicated video processing chip, DM642 includes three dedicated video ports (VP0~VP2) for receiving and processing video, which improves the performance of the whole system. In addition, the EMAC port of DM642 and ATA port extended from EMIF port also provide storage channels for the massive data generated after processing.
This system adopts the evaluation development board ——Icetek DM 642 PCI developed by ruitai Company based on TI TMS320DM642 DSP chip. In the evaluation board of ICETEK DM642 PCI, the hardware platform is divided into five parts: video acquisition, data storage, image processing, result display and power management. The video acquisition part adopts analog PAL camera and cooperates with high-precision video A/D converter to acquire digital images. Video acquisition based on DSP requires that video signals can be collected, displayed in real time, and the images can be processed and analyzed. Video A/D sampling circuit-SAA 7 115+05 is connected to video port 0 or1to realize real-time video acquisition. Video D/A circuit-SAA 7105 is connected to video port 2, and the video output signal supports RGB, HD composite video, PAL/NTSC composite video and S-terminal video signal. The internal registers of SAA7 105 realize different outputs through I2C bus programming.
The whole system flow consists of three parts: image acquisition-edge processing-output display, as shown in Figure 2. The video signals collected by the camera are digitized by video encoders SAA7 1 15, and DM642 configures the parameters of SAA7 1 15 through I2C bus. After a series of processing and conversion in SAA7 1 15, the digital video data stream is input to the core processing unit DM642. The digital video processed by DSP is D/A converted by SAA7 105 video encoder, and the final processing result is displayed on the display.
3.2 Software design and algorithm optimization of image processing
With the improvement of Sobel edge detection operator's performance, the amount of calculation is relatively increased, especially the direction template is increased, and each pixel is increased from the original 2 convolution operations to 8 convolution operations, so its real-time performance is greatly weakened. In order to improve the above shortcomings, after in-depth study of the processing system and algorithm, according to the hardware structure characteristics of TMS320DM642, an improved Sobel algorithm suitable for efficient operation in TMS320DM642 is studied to meet the requirements of real-time processing. The whole program is written and debugged according to the software development flow of C6000, which is divided into three stages: generating C code, optimizing C code and writing linear assembler. The tool used is TI's integrated development environment CCS. Under CCS, the software can be edited, compiled, debugged and code performance tested. When developing and optimizing C code with C6000 compiler [7-8], the functions in C code that are inefficient and need to be called repeatedly need to be rewritten by linear assembly and then optimized by assembly optimizer. The control and digital image processing of the whole system are realized by C program, and most of the software design is realized by C program, which undoubtedly improves the readability and portability of the program, while the assembler mainly realizes the initialization of all parts of DM642. The implementation steps of edge detection optimization algorithm in DM642 are as follows:
S 1: according to the hardware structure requirements of DM642 and the setting of control registers, initialize the system and write C program to realize the edge detection algorithm.
S2: Generate one. Export files with the help of optimization tools of CCS development environment (such as Profiler).
S3: Display the generated attachment files, such as. Map files, analyze optimization results and source program structure, and further improve source programs and optimization methods.
S4: Use debugging, linking and running tools in CCS to generate it. Executable file output.
S5, running the program, and stopping if the requirements are met; Otherwise, repeat steps S2 to S4 until the use requirements are met.
4 experimental results
This paper takes Lena image as an example, according to the above hardware environment and the principle and method of algorithm implementation. Figures 4 ~ 6 show the video Lena image, edge detection operator and the results of improved post-processing collected under this system respectively. From the experimental results, it can be seen that the system can complete the video image processing in real time, and the edge detection operator given can eliminate the influence of noise and the edge contour is clear. This algorithm can not only suppress most of the noise and false edges in the image, but also ensure high edge positioning accuracy.
Figure 4 Lena original image Figure 5 Traditional Sobel operator Figure 6 Improved Sobel operator
5 abstract
In this paper, an improved Sobel operator is used to detect the edge of the real-time image on TMS320DM642 evaluation board, and the edge image is obtained without delay. The edge detection effect is good, which not only improves the accuracy of image detection, but also meets the real-time requirements. From the detection results, the improved operator has achieved good results in accurate edge location and edge extraction, and has strong anti-noise ability, which provides a solid foundation for the application in target tracking, non-contact detection, autonomous driving, video surveillance and other fields.
refer to
[1] Wang Leyan et al. Improved edge extraction method based on Sobel theory [J]. China Journal of Images and Graphics, 2005+00.
Chen Hongxi. Sobel operator edge detection based on smooth preserving filtering. Journal of Lanzhou Jiaotong University, 2006,25 (1): 86-90
Xiong Wei. Hardware design and implementation of multi-channel video acquisition and processing board based on TMS320DM642 [M]. Foreign electronic components, 2006.
[4] Zhu Li. Research on an image edge extraction algorithm against noise interference [J]. Application of electronic technology. 2004,25 (1)
Liu Songtao, Zhou Xiaodong. Real-time image processing system based on TMS 320 1 [J]. Computer Engineering, 2005 (7): 17-23.
[6] TI TMS320DM642 Data Sheet of Fixed-point Digital Signal Processor for Video/Imaging, 2003.
[7] TMS320C6x Optimized C Compiler User's Guide' Texas Instruments', 2002
[8] TMS320C32x user guide for optimizing C/C++ compiler, Texas Instruments, 200 1