Image recognition system and method
By designing an improved image recognition system, the traditional Sobel edge detection algorithm has solved the shortcomings in image edge information accuracy and continuity, and more efficient image edge information processing and FPGA design verification are achieved.
Patent Information
- Application Number
- CN202111432291.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-29
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2041-11-29
AI Technical Summary
The traditional Sobel edge detection algorithm has problems such as thicker image edges, low accuracy of edge information, and poor continuity.
An image recognition system was designed, including an image reading module, a median filtering module, a gradient direction angle division and calibration module, a region non-maximum suppression module, an adaptive dynamic threshold generation module, an image edge point calibration module, and an output module with comparison module. This system improves the accuracy and continuity of image edge information by improving the Sobel operator edge refinement algorithm.
It effectively improves the accuracy and continuity of image edge information, and provides a reliable verification method and simulation system for image edge refinement FPGA design, with the characteristics of scalability, easy portability, high versatility and visualization.
Smart Images

Figure CN114092358B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image edge detection and pattern recognition, and in particular to an image recognition system and method. Background Art
[0002] With the rapid development of technologies such as image recognition and artificial intelligence, image processing, as a foundation, has gradually become an important subject. The edge information of an image contains important image information, so how to efficiently extract the edge information of an image is particularly critical.
[0003] Traditional edge detection algorithms include Sobel operator, Canny operator, Roberts operator, Prewitt operator, Log operator, etc. Their basic principle is to use the step nature of the image gradient value at the edge and detect the edge point after weighting according to the operator template. Among them, the Sobel edge detection operator has a fast calculation speed and has been widely used in many fields. However, the traditional Sobel edge detection algorithm has problems such as coarse image edges, low edge information accuracy, and poor continuity. Summary of the invention
[0004] In order to solve the above technical problems, the present application provides an image recognition system, which includes: an image reading module, a median filtering module, a gradient direction angle division and calibration module, a regional non-maximum suppression module, an adaptive dynamic threshold generation module, an image edge point calibration module, an output module and a comparison module;
[0005] The image reading module is used to: read the grayscale values of the pixels of the grayscale image and store them in a matrix manner;
[0006] The median filter module is used to: use a 3x3 pixel neighborhood as a sliding window, take the middle value of the pixel value as the central pixel value, and perform denoising on the image;
[0007] The regional non-maximum suppression module is used to: compare the gradient value of the central pixel with the gradient values of the 3x3 neighboring pixels according to the angular region to which the central pixel belongs, and if the gradient value of the central pixel is the maximum value, retain the gradient value, otherwise set the gradient value to 0;
[0008] The adaptive dynamic threshold generation module is used to: on the basis of a fixed single threshold, according to the area where the gradient direction angle of the central pixel point is located, respectively compare the gradient of the central pixel with the neighboring gradient value of its direction angle area, and take the median as the adaptive dynamic gradient threshold;
[0009] The image edge point calibration module is used to further remove pseudo edge points according to a dynamic threshold;
[0010] The output module includes an edge information output module and an edge image display module. The edge information output module writes the calibrated edge point coordinates to a specified position; the edge image display module displays the binary edge image after edge refinement.
[0011] The comparison module includes a VCS simulation edge point data reading module and an edge data comparison module; the VCS simulation edge point data reading module reads the edge detection result of the VCS simulation; and the edge data comparison module compares the edge point data of the simulation model with the edge point data of the VCS simulation.
[0012] In a possible implementation, the gradient direction angle division and calibration module includes a gradient value calculation module, a gradient direction angle calculation module and a gradient direction angle calibration module;
[0013] The gradient value calculation module is used to: use the Sobel operator to perform convolution with 3x3 neighborhood pixels to calculate the horizontal gradient value, vertical gradient value and gradient value of the central pixel; the gradient direction angle calculation module is used to calculate the gradient direction angle of the central pixel.
[0014] In a possible implementation, the gradient direction angle calibration module is used to divide the gradient direction angle, and each pixel is further divided into 2x2 sub-pixels with 3x3 neighborhood pixels, that is, each pixel is composed of 4 sub-pixels with the same pixel value, and the center point and the sub-pixel corner points are connected in sequence to obtain 12 angle values, and the corresponding diagonals are divided into the same angle area; the gradient direction angle of the central pixel is calibrated, and the angle area to which it belongs is confirmed and marked. That is, area 1:
[0015] [-18.4349°,18.4349°), [161.5651°,180°), [-180°,-161.5651°); Area 2 [18.4349°,45°), [-161.5651°,-135°); Area 3 [45°,71.5651°),
[0016] [-135°,-108.4349°); Area 4: [71.5651°,108.4349°),
[0017] Area 5: [108.4349°, 135°), [-71.5651°, -45°); Area 6: [135°, 161.5651°), [-45°, -18.4349°). Then the gradient direction angle of the central pixel is calibrated to confirm and mark the angle area to which it belongs.
[0018] The regional non-maximum suppression module compares the gradient value of the central pixel with the gradient values of the 3x3 neighboring pixels according to the angular region to which the central pixel belongs. If the gradient value of the central pixel is the maximum value, the gradient value is retained, otherwise the gradient value is set to 0. The specific comparison method is: Region 1: Comparison of the gradient values of three horizontal pixels; Region 2: Comparison of the gradient values of five horizontal + right diagonal pixels; Region 3: Comparison of the gradient values of five vertical + right diagonal pixels; Region 4: Comparison of the gradient values of three vertical pixels; Region 5: Comparison of the gradient values of five vertical + left diagonal pixels; Region 6: Comparison of the gradient values of five horizontal + left diagonal pixels.
[0019] In a possible implementation, the image edge point calibration module is used to: when the gradient value of the central pixel is greater than or equal to the dynamic threshold, the central pixel is an edge point and the grayscale value is set to 255; otherwise, it is a pseudo edge point and is eliminated and the grayscale value is set to 0.
[0020] On the other hand, the present application provides an image recognition method, the method comprising:
[0021] S1: Read the pixel grayscale value of the grayscale image and store it in a matrix format;
[0022] S2: Use the 3x3 pixel neighborhood as a sliding window, take the middle value of the pixel value as the center pixel value, and perform denoising on the image;
[0023] S3: According to the angular region to which the central pixel belongs, the gradient value of the central pixel is compared with the gradient values of the 3x3 neighboring pixels. If the gradient value of the central pixel is the maximum value, the gradient value is retained, otherwise the gradient value is set to 0;
[0024] S4: On the basis of a fixed single threshold, according to the area where the gradient direction angle of the central pixel is located, the gradient of the central pixel is compared with the neighboring gradient values of its direction angle area, and the median is taken as the adaptive dynamic gradient threshold;
[0025] S5: further remove pseudo edge points according to the dynamic threshold;
[0026] S6: The edge information output module writes the calibrated edge point coordinates to the specified position; the edge image display module displays the binary edge image after edge refinement;
[0027] S7: The comparison module includes a VCS simulation edge point data reading module and an edge data comparison module; the VCS simulation edge point data reading module reads the edge detection result of the VCS simulation; the edge data comparison module compares the edge point data of the simulation model with the edge point data of the VCS simulation.
[0028] In a possible implementation, the method further includes:
[0029] Use the Sobel operator to perform convolution with the 3x3 neighborhood pixels, calculate the horizontal gradient value, vertical gradient value, and gradient value of the center pixel, and calculate the gradient direction angle of the center pixel.
[0030] In a possible implementation, the gradient direction angle is divided, and each pixel is further divided into 2x2 sub-pixels with 3x3 neighborhood pixels, that is, each pixel is composed of 4 sub-pixels with the same pixel value, and the center point and the sub-pixel corner points are connected in sequence to obtain 12 angle values, and the corresponding diagonals are divided into the same angle area; the gradient direction angle of the center pixel is calibrated, and the angle area to which it belongs is confirmed and marked.
[0031] In a possible implementation, step S5 includes:
[0032] When the gradient value of the central pixel is greater than or equal to the dynamic threshold, the central pixel is an edge point and the grayscale value is set to 255. Otherwise, it is a pseudo edge point and is removed, and the grayscale value is set to 0.
[0033] Due to the application of the above technical solution, the present invention has the following beneficial effects compared with the prior art:
[0034] The present invention realizes a simulation system for improved Sobel operator edge refinement FPGA by modeling the improved Sobel operator edge refinement algorithm, which not only effectively improves the accuracy and continuity of image edge information, but also provides a reliable verification method and simulation system for image edge refinement FPGA design, and has the characteristics of scalability, easy transplantation, high versatility and visualization. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0036] Figure 1 A block diagram of the principles and components provided for an exemplary embodiment of the present invention;
[0037] Figure 2 A simulation model processing flow chart provided for an exemplary embodiment of the present invention;
[0038] Figure 3 A schematic diagram of the structure of a simulation platform provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0039] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0040] like Figure 1 As shown, this example includes: image reading module, median filtering module, gradient direction angle division and calibration module, regional non-maximum suppression module, adaptive dynamic threshold generation module, image edge point calibration module, output module and comparison module. Among them, the image reading module realizes the reading and caching of the original image, and inputs the image data into the median filtering module for denoising. The gradient direction angle division and calibration module consists of three modules: gradient value calculation, gradient direction angle calculation, and gradient direction angle calibration.
[0041] First, the Sobel operator is used to convolve with the denoised image to obtain the horizontal gradient value Gx, vertical gradient value Gy and gradient value G of each pixel. The gradient direction angle is calculated according to the gradient value and the direction angle is calibrated according to six diagonal areas.
[0042] The regional non-maximum suppression module performs non-maximum suppression processing on the pixel gradient value according to the gradient direction angle calibration result, and the adaptive dynamic threshold generation module generates the decision threshold corresponding to each pixel according to the gradient direction angle calibration result.
[0043] The image edge point determination module uses a dynamic threshold to determine the gradient value after suppression processing and removes pseudo edge points.
[0044] The output module includes an edge information output module and an edge image display module. The edge image display module performs binarization processing on the edge image according to the filtered edge points and outputs and displays it; the edge information output module outputs the filtered edge pixel point coordinate information to a dat file.
[0045] The comparison module includes a VCS simulation edge point data reading module and an edge data comparison module. The VCS edge point data reading module is used to read the edge point data generated by the VCS simulation FPGA design. Further, the edge data comparison module compares the .dat file generated by the edge information output module with the edge point data generated by the VCS simulation.
[0046] The simulation model is based on Matlab for simulation modeling, and its processing flow is as follows: Figure 2As shown in the figure, the model sequentially performs functions such as reading the original image file, median filtering, gradient value calculation, gradient direction angle calculation, gradient direction angle calibration, dynamic threshold calculation, regional non-maximum suppression, edge point determination, edge point data output, edge image generation and display. In order to further compare the edge point data generated by the VCS simulation FPGA design, the joint simulation of VCS and Matlab is realized, which not only improves the simulation verification speed, but also verifies the correctness of the FPGA design and the effectiveness of the simulation system.
[0047] In this example, the platform structure diagram of VCS and Matlab joint simulation is as follows: Figure 3 As shown in the figure. A basic simulation stimulus Testbench is built based on VCS to read the original image data Image file and record the edge data generated by the FPGA design in the edge information dat file 1; a simulation model is built based on Matlab to read the original image data Image file and record the edge data in dat file 2, and further read the edge data in dat file 1 and compare it with the edge data in dat file 2 to achieve the purpose of verifying the correctness of the FPGA design.
[0048] The invention concept is described in detail using specific examples herein, and the description of the above embodiments is only used to help understand the core idea of the invention. It should be pointed out that any obvious modification, equivalent substitution or other improvement made by a person of ordinary skill in the art without departing from the invention concept should be included in the protection scope of the present invention.
[0049] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are considered to be exemplary only, and the true scope and spirit of the present application are indicated by the above-mentioned claims.
[0050] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
[0051] It should be understood that the "plurality" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0052] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0053] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. An image recognition system, characterized in that: The system comprises: an image reading module, a median filtering module, a gradient direction angle division and calibration module, a regional non-maximum suppression module, an adaptive dynamic threshold generation module, an image edge point calibration module, an output module and a comparison module; The image reading module is used to: read the grayscale values of the pixels of the grayscale image and store them in a matrix manner; The median filter module is used to: use a 3x3 pixel neighborhood as a sliding window, take the middle value of the pixel value as the central pixel value, and perform denoising on the image; The gradient direction angle division and calibration module includes a gradient value calculation module, a gradient direction angle calculation module and a gradient direction angle calibration module. The gradient value calculation module is used to: use the Sobel operator to perform convolution with 3x3 neighborhood pixels to calculate the horizontal gradient value, vertical gradient value and gradient value of the center pixel; the gradient direction angle calculation module is used to calculate the gradient direction angle of the center pixel; the gradient direction angle calibration module is used to perform gradient direction angle division, using 3x3 neighborhood pixels to further divide each pixel into 2x2 sub-pixels, that is, each pixel is composed of 4 sub-pixels with the same pixel value, and the center point and the sub-pixel corner points are connected in sequence to obtain 12 angle values, and the corresponding diagonals are divided into the same angle area; the gradient direction angle of the center pixel is calibrated to confirm and mark the angle area to which it belongs; The regional non-maximum suppression module is used to: compare the gradient value of the central pixel with the gradient values of the 3x3 neighboring pixels according to the angular region to which the central pixel belongs, and if the gradient value of the central pixel is the maximum value, retain the gradient value, otherwise set the gradient value to 0; The adaptive dynamic threshold generation module is used to: on the basis of a fixed single threshold, according to the area where the gradient direction angle of the central pixel point is located, respectively compare the gradient of the central pixel with the neighboring gradient value of its direction angle area, and take the median as the adaptive dynamic gradient threshold; The image edge point calibration module is used to further remove pseudo edge points according to a dynamic threshold; The output module includes an edge information output module and an edge image display module. The edge information output module writes the calibrated edge point coordinates to a specified position; the edge image display module displays the binary edge image after edge refinement. The comparison module includes a VCS simulation edge point data reading module and an edge data comparison module; the VCS simulation edge point data reading module reads the edge detection result of the VCS simulation; and the edge data comparison module compares the edge point data of the simulation model with the edge point data of the VCS simulation.
2. The system according to claim 1, characterized in that The image edge point calibration module is used to: when the gradient value of the central pixel is greater than or equal to the dynamic threshold, the central pixel is an edge point and the grayscale value is set to 255; otherwise, it is a pseudo edge point and is removed and the grayscale value is set to 0.
3. An image recognition method, characterized in that: The method comprises: S1: Read the pixel grayscale value of the grayscale image and store it in a matrix format; S2: Use a 3x3 pixel neighborhood as a sliding window, take the middle value of the pixel value as the center pixel value, and perform denoising on the image; S3: Use the Sobel operator to perform convolution with the 3x3 neighborhood pixels, calculate the horizontal gradient value and vertical gradient value of the center pixel, and calculate the gradient direction angle of the center pixel; divide the gradient direction angle, and further divide each pixel into 2x2 sub-pixels with the 3x3 neighborhood pixels, that is, each pixel is composed of 4 sub-pixels with the same pixel value, connect the center point and the sub-pixel corner points in sequence, obtain 12 angle values, and divide the corresponding diagonals into the same angle area; calibrate the gradient direction angle of the center pixel, confirm and mark the angle area to which it belongs; S4: According to the angular region to which the central pixel belongs, the gradient value of the central pixel is compared with the gradient values of the 3x3 neighboring pixels. If the gradient value of the central pixel is the maximum value, the gradient value is retained, otherwise the gradient value is set to 0; S5: On the basis of a fixed single threshold, according to the area where the gradient direction angle of the central pixel is located, the gradient of the central pixel is compared with the neighboring gradient values of its direction angle area, and the median is taken as the adaptive dynamic gradient threshold; S6: further remove pseudo edge points according to the dynamic threshold; S7: The edge information output module writes the calibrated edge point coordinates to the specified position; the edge image display module displays the binary edge image after edge refinement; S8: The comparison module includes a VCS simulation edge point data reading module and an edge data comparison module; the VCS simulation edge point data reading module reads the edge detection result of the VCS simulation; the edge data comparison module compares the edge point data of the simulation model with the edge point data of the VCS simulation.
4. The method according to claim 3, characterized in that The step S6 comprises: When the gradient value of the central pixel is greater than or equal to the dynamic threshold, the central pixel is an edge point and the grayscale value is set to 255. Otherwise, it is a pseudo edge point and is removed, and the grayscale value is set to 0.