Edge detection method and device, electronic equipment and storage medium

By utilizing the symmetry of texels in texture images, edge detection results can be directly obtained from the register front point, solving the problem of high complexity in edge detection of high-resolution images on mobile devices and achieving efficient edge detection results.

CN116309657BActive Publication Date: 2025-12-19VIVO SOFTWARE TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310182147.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-20
Publication Date
2025-12-19
Estimated Expiration
2043-02-20

AI Technical Summary

Technical Problem

In existing technologies, edge detection methods for high-resolution images on mobile devices have high computational complexity, making it difficult to achieve the application experience expected by users and failing to effectively utilize the parallel computing capabilities of mobile GPUs.

Method used

By extracting symmetrical texels adjacent to the texel to be detected from the texture image, and utilizing the spatial symmetry of the texels, the edge detection results can be obtained directly from the register front point, reducing the amount of computation and utilizing the parallel computing power of the GPU to reduce the complexity of edge detection.

Benefits of technology

It effectively reduces the computational complexity of edge detection, improves the efficiency and accuracy of fast edge detection on mobile devices, and enhances the efficiency and accuracy of image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116309657B_ABST
    Figure CN116309657B_ABST
Patent Text Reader

Abstract

The application discloses an edge detection method and device, electronic equipment and a storage medium, and belongs to the field of image processing. The edge detection method comprises the following steps: acquiring a texture image to be edge detected; extracting a fourth texel adjacent to a first texel in the texture image from a register front point, and determining a symmetric texel of the first texel based on the fourth texel, wherein the symmetric texel is adjacent to the fourth texel, the first texel is symmetric to the symmetric texel about the fourth texel, and the first texel is a texel to be calculated for edge detection; obtaining an edge detection result of the symmetric texel of the first texel based on the fourth texel; and obtaining an edge detection result corresponding to the first texel based on the edge detection result of the symmetric texel of the first texel.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the field of image processing, and particularly relates to an edge detection method and device, electronic equipment and a storage medium. BACKGROUND

[0002] In the process of image processing, in order to reduce the data size of the image while preserving the original image properties, a set of pixel points with sharp changes in brightness in the image needs to be obtained through edge detection, and the discontinuity of the brightness value is generally detected through an algorithm.

[0003] In the related art, the edge detection method is generally realized and optimized by a central processing unit (CPU), and when the image resolution is high, the complexity of the algorithm increases exponentially, which makes it difficult to efficiently deploy the edge detection method on a mobile terminal and difficult to achieve the expected application experience of the user. SUMMARY

[0004] The embodiments of the present application provide an edge detection method, device, electronic equipment and storage medium, which can reduce the complexity of edge detection and improve the efficiency of mobile terminal fast edge detection method calculation.

[0005] In a first aspect, the embodiments of the present application provide an edge detection method, which comprises:

[0006] obtaining a texture image to be edge detected;

[0007] extracting a fourth texel adjacent to a first texel in the texture image from a register front point, and determining a symmetric texel of the first texel based on the fourth texel, wherein the symmetric texel is adjacent to the fourth texel, the first texel is symmetric about the fourth texel with respect to the symmetric texel, and the first texel is a texel to be edge detected and calculated;

[0008] obtaining an edge detection result of the symmetric texel of the first texel based on the fourth texel;

[0009] obtaining an edge detection result corresponding to the first texel based on the edge detection result of the symmetric texel of the first texel.

[0010] In a second aspect, the embodiments of the present application provide an edge detection device, which comprises:

[0011] a first obtaining module configured to obtain a texture image to be edge detected;

[0012] The second obtaining module is configured to extract a fourth texel adjacent to the first texel in the texture image from the register front point, and determine a symmetric texel of the first texel based on the fourth texel, wherein the symmetric texel is adjacent to the fourth texel, the first texel is symmetric to the symmetric texel about the fourth texel, and the first texel is a texel to be calculated for edge detection;

[0013] The third obtaining module is configured to obtain an edge detection result of the symmetric texel of the first texel based on the fourth texel.

[0014] The fourth obtaining module is configured to obtain an edge detection result corresponding to the first texel based on the edge detection result of the symmetric texel of the first texel.

[0015] In the third aspect, an electronic device is provided, which includes a processor and a memory. The memory stores programs or instructions executable on the processor. When the programs or instructions are executed by the processor, the steps of the method according to the first aspect are implemented.

[0016] In the fourth aspect, a readable storage medium is provided. The readable storage medium stores programs or instructions. When the programs or instructions are executed by a processor, the steps of the method according to the first aspect are implemented.

[0017] In the fifth aspect, a chip is provided. The chip includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is configured to execute programs or instructions to implement the method according to the first aspect.

[0018] In the sixth aspect, a computer program product is provided. The program product is stored in a storage medium. When the program product is executed by at least one processor, the method according to the first aspect is implemented.

[0019] In the embodiments of the present application, when the adjacent texels of the first texel are stored in the register front point, the fourth texel adjacent to the first texel is directly extracted from the register front point, without repeated access to the global register. The symmetric relationship of the texels in the spatial field is utilized to obtain the edge detection result of the first texel based on the calculated edge detection result of the symmetric texel of the first texel, so as to reduce the calculation amount of edge detection, reduce the calculation times by the parallel computing capability of the mobile terminal GPU, reduce the complexity of edge detection, and improve the calculation efficiency of the mobile terminal fast edge detection method. BRIEF DESCRIPTION OF DRAWINGS

[0020] Figure 1 is one of the flowcharts of the edge detection method provided by the embodiments of the present application;

[0021] Figure 2is a processing flowchart of tex_operator provided by an embodiment of the present application.

[0022] Figure 3 is a schematic diagram of an operation process of a texture and edge detection operator provided by an embodiment of the present application.

[0023] Figure 4 is a second schematic diagram of a flow of an edge detection method provided by an embodiment of the present application.

[0024] Figure 5 is a structural schematic diagram of an edge detection apparatus provided by an embodiment of the present application.

[0025] Figure 6 is a structural schematic diagram of an electronic device provided by an embodiment of the present application.

[0026] Figure 7 is a hardware schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0027] The technical solutions in the embodiments of the present application will be described clearly below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art belong to the scope of protection of the present application.

[0028] The terms "first", "second", and the like in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than that illustrated or described herein, and the objects distinguished by "first", "second", and the like are generally of a kind and are not limited in number, for example, the first object can be one or more. In addition, "and / or" in the specification and claims indicates at least one of the connected objects, and the character " / ", generally indicates that the front and rear associated objects are in an "or" relationship.

[0029] The edge detection method, apparatus, electronic device and storage medium provided by the embodiments of the present application will be described in detail below with reference to the drawings and specific embodiments and their application scenarios.

[0030] First, the following content is introduced:

[0031] Edge is one of the most important basic features of an image, and edge detection is an important prerequisite for image segmentation, image understanding, pattern recognition and other image technologies. The purpose is to find a set of pixels with sharp brightness changes in the image, significantly reducing the data size of the image while preserving the original image properties. Therefore, edge detection of an image has always been a hot topic in the field of image processing. An effective and fast edge detection method can greatly improve the efficiency and accuracy of image processing.

[0032] In related technologies, first and second order derivatives can be used to detect discontinuity of brightness values, including differential method, difference edge detection method, Sobel operator, Canny operator, or Laplace operator, etc. Such schemes first perform smoothing operation on the image after grayscale processing, and calculate the partial derivative and gradient vector in the horizontal and vertical directions of the image using first order finite difference, thereby obtaining the final edge detection result.

[0033] With the rapid development of mobile end graphics processing units (GPU), the current mobile end GPU has very strong parallel computing capability, and the floating point operation capability can even reach more than 10 times of the same generation mobile end CPU. At the same time, the implementation and optimization of existing edge detection methods are mostly proposed for CPU processors, without taking advantage of the characteristics of mobile end GPU hardware acceleration structure or effectively utilizing the advantage of high parallelization of the algorithm itself. It should be particularly pointed out that when the image resolution is high, the complexity of the algorithm increases exponentially, making it very difficult to efficiently deploy edge detection methods on mobile end, and it is difficult to achieve the user's expected application experience. Therefore, it is necessary to improve the efficiency and accuracy of the calculation of the mobile end fast edge detection method.

[0034] The edge detection method, device, electronic equipment and storage medium provided by the embodiments of the present application can reduce the complexity of edge detection and improve the efficiency of the calculation of the mobile end fast edge detection method.

[0035] The edge detection method, device, electronic equipment and storage medium provided by the embodiments of the present application will be described in detail below in combination with the drawings, specific embodiments and application scenarios.

[0036] Figure 1 is one of the flowcharts of the edge detection method provided by the embodiments of the present application, as shown in Figure 1 The edge detection method includes the following steps:

[0037] Step 100, acquiring a texture image to be edge detected;

[0038] Optionally, the texture image can reflect a visual feature of homogeneity in the image, and can reflect a surface structure organization arrangement attribute of the surface of the object, which has a slow change or a periodic change.

[0039] Optionally, the edge detection can detect a set of pixels with a sharp change in brightness in the texture image, and can reduce the data size of the texture image while retaining the original texture image attribute.

[0040] Step 110, extracting a fourth texel adjacent to the first texel in the texture image from the register front point, and determining a symmetric texel of the first texel based on the fourth texel, wherein the symmetric texel is adjacent to the fourth texel, the first texel and the symmetric texel are symmetric about the fourth texel, and the first texel is a texel to be calculated for edge detection;

[0041] Optionally, the register can be a cache on the GPU.

[0042] Optionally, the texel can be a basic unit in a computer graphics texture space.

[0043] Optionally, the first texel can include a texel to be calculated for edge detection in the texture image to be edge detected.

[0044] Optionally, the fourth texel can be stored in the register front point.

[0045] Optionally, the fourth texel can include a texel with a higher access frequency when sampling.

[0046] Optionally, the fourth texel can be adjacent to the first texel.

[0047] Optionally, the fourth texel can be extracted from the register front point.

[0048] Optionally, the fourth texel can be adjacent to at least two or three or four first texels, which are not limited in the present application.

[0049] Optionally, the symmetric texel of the first texel can be adjacent to the fourth texel.

[0050] Optionally, among all the adjacent texels of the first texel, there is an adjacent texel stored in the register front point, which has been extracted for edge detection calculation in the edge detection calculation of another texel, and if the other texel is symmetric to the first texel about the adjacent texel, the adjacent texel can be considered as the fourth texel.

[0051] Optionally, in the texture image, the first texel can correspond to coordinates (x, y), in the case that the fourth texel corresponds to coordinates (x+1, y), the symmetric texel of the first texel with respect to the fourth texel can correspond to coordinates (x+2, y); in the case that the fourth texel corresponds to coordinates (x-1, y), the symmetric texel of the first texel with respect to the fourth texel can correspond to coordinates (x-2, y); in the case that the fourth texel corresponds to coordinates (x, y+1), the symmetric texel of the first texel with respect to the fourth texel can correspond to coordinates (x, y+2); in the case that the fourth texel corresponds to coordinates (x, y-1), the symmetric texel of the first texel with respect to the fourth texel can correspond to coordinates (x, y-2); in the case that the fourth texel corresponds to coordinates (x+1, y+1), the symmetric texel of the first texel with respect to the fourth texel can correspond to coordinates (x+2, y+2); in the case that the fourth texel corresponds to coordinates (x-1, y-1), the symmetric texel of the first texel with respect to the fourth texel can correspond to coordinates (x-2, y-2); in the case that the fourth texel corresponds to coordinates (x+1, y-1), the symmetric texel of the first texel with respect to the fourth texel can correspond to coordinates (x+2, y-2); in the case that the fourth texel corresponds to coordinates (x-1, y+1), the symmetric texel of the first texel with respect to the fourth texel can correspond to coordinates (x-2, y+2).

[0052] Optionally, the symmetric texel of the first texel can be horizontally symmetric or vertically symmetric.

[0053] Specifically, in order to efficiently utilize texture caches, the operation complexity is maximally reduced and the parallelism of the GPU is improved by means of the composite memory access mode and the symmetric calculation technology, and the tex_operator can take the calculation unit as a base point, and reduce the sampling and calculation of the texture data by means of the auxiliary texture (i.e. the edge detection result of the symmetric texel).

[0054] In step 120, the edge detection result of the symmetric texel of the first texel is obtained based on the fourth texel.

[0055] Optionally, the edge detection result of the symmetric texel of the first texel can be obtained in the edge detection result obtained based on the fourth texel.

[0056] In step 130, the edge detection result corresponding to the first texel is obtained based on the edge detection result of the symmetric texel of the first texel.

[0057] Optionally, in the case that the first texture element is adjacent to the fourth texture element, the symmetric texture element of the first texture element with respect to each fourth texture element is determined respectively, and then the edge detection result corresponding to the first texture element can be obtained based on the part of the edge detection result of the symmetric texture element of the fourth texture element calculated based on the fourth texture element.

[0058] Optionally, in the case that the first texture element is adjacent to the fourth texture element, the symmetric texture element of the first texture element with respect to each fourth texture element is determined respectively, and then the edge detection result corresponding to the first texture element can be obtained based on the part of the edge detection result of the symmetric texture element of the fourth texture element calculated based on the fourth texture element.

[0059] Optionally, in the case that the first texture element is adjacent to the fourth texture element, the symmetric texture element of the first texture element with respect to each fourth texture element is determined respectively, and then the edge detection result corresponding to the first texture element can be obtained based on the part of the edge detection result of the symmetric texture element of the fourth texture element calculated based on the fourth texture element.

[0060] Optionally, in the case that the first texture element is adjacent to the fourth texture element, the symmetric texture element of the first texture element with respect to each fourth texture element is determined respectively, and then the edge detection result corresponding to the first texture element can be obtained based on the part of the edge detection result of the symmetric texture element of the fourth texture element calculated based on the fourth texture element.

[0061] In the embodiment of the present application, in the case that the adjacent texture element of the first texture element is stored in the register front point, the fourth texture element adjacent to the first texture element is directly extracted from the register front point, without repeated access to the global register, and the symmetry relationship of the texture element in the spatial field is utilized to obtain the edge detection result of the first texture element based on the calculated edge detection result of the symmetric texture element of the first texture element, thereby reducing the calculation amount of edge detection, reducing the number of calculations through the parallel computing capability of the mobile terminal GPU, reducing the complexity of edge detection, and improving the calculation efficiency of the mobile terminal fast edge detection method.

[0062] Optionally, the obtaining of the edge detection result corresponding to the first texture element based on the edge detection result of the symmetric texture element of the first texture element comprises:

[0063] The part of the edge detection result of the fourth texture element is obtained from the edge detection result of the symmetric texture element of the first texture element.

[0064] Alternatively, in the case that the texture elements adjacent to the first texture element all belong to the fourth texture element, the symmetric texture elements of the first texture element with respect to each of the fourth texture elements are determined respectively, and then the edge detection result corresponding to the first texture element can be obtained based on the part of the edge detection result of each of the symmetric texture elements of the fourth texture element calculated based on the fourth texture element. For example, the first texture element a can be adjacent to the texture elements a1, a2, a3, a4, a5, a6, a7 and a8, wherein the first texture element a can correspond to the coordinate (0, 0), the texture element a1 can correspond to the coordinate (1, 0), the texture element a2 can correspond to the coordinate (1, 1), the texture element a3 can correspond to the coordinate (0, 1), the texture element a4 can correspond to the coordinate (-1, 1), the texture element a5 can correspond to the coordinate (-1, 0), the texture element a6 can correspond to the coordinate (-1, -1), the texture element a7 can correspond to the coordinate (0, -1), and the texture element a8 can correspond to the coordinate (1, -1);

[0065] The texture element a1 can be adjacent to the texture element b1 which has not been extracted for edge calculation, the texture element b1 can correspond to the coordinate (2, 0), the texture element a1 is between the first texture element a and the texture element b1, and the texture element b1 is symmetric to the first texture element a with respect to the texture element a1. Therefore, the part of the edge detection result calculated based on the texture element a1 can be obtained from the edge detection result of the texture element b1, and can be used as the part of the edge detection result corresponding to the first texture element a;

[0066] The texture element a2 can be adjacent to the texture element b2 which has not been extracted for edge calculation, the texture element b2 can correspond to the coordinate (2, 2), the texture element a2 is between the first texture element a and the texture element b2, and the texture element b2 is symmetric to the first texture element a with respect to the texture element a2. Therefore, the part of the edge detection result calculated based on the texture element a2 can be obtained from the edge detection result of the texture element b2, and can be used as the part of the edge detection result corresponding to the first texture element a;

[0067] The texture element a3 can be adjacent to the texture element b3 which has not been extracted for edge calculation, the texture element b3 can correspond to the coordinate (0, 2), the texture element a3 is between the first texture element a and the texture element b3, and the texture element b3 is symmetric to the first texture element a with respect to the texture element a3. Therefore, the part of the edge detection result calculated based on the texture element a3 can be obtained from the edge detection result of the texture element b3, and can be used as the part of the edge detection result corresponding to the first texture element a;

[0068] The texel a4 can be adjacent to a texel b4 which has not been extracted for edge computing, the texel b4 can correspond to coordinates (-2, 2), the texel a4 is between the first texel a and the texel b4, the texel b4 is symmetrical to the first texel a about the texel a4, and then the partial edge detection result based on the texel a4 can be obtained from the edge detection result of the texel b4 and can be used as the partial edge detection result corresponding to the first texel a.

[0069] The texel a5 can be adjacent to a texel b5 which has not been extracted for edge computing, the texel b5 can correspond to coordinates (-2, 0), the texel a5 is between the first texel a and the texel b5, the texel b5 is symmetrical to the first texel a about the texel a5, and then the partial edge detection result based on the texel a5 can be obtained from the edge detection result of the texel b5 and can be used as the partial edge detection result corresponding to the first texel a.

[0070] The texel a6 can be adjacent to a texel b6 which has not been extracted for edge computing, the texel b6 can correspond to coordinates (-2, -2), the texel a6 is between the first texel a and the texel b6, the texel b6 is symmetrical to the first texel a about the texel a6, and then the partial edge detection result based on the texel a6 can be obtained from the edge detection result of the texel b6 and can be used as the partial edge detection result corresponding to the first texel a.

[0071] The texel a7 can be adjacent to a texel b7 which has not been extracted for edge computing, the texel b7 can correspond to coordinates (0, -2), the texel a7 is between the first texel a and the texel b7, the texel b7 is symmetrical to the first texel a about the texel a7, and then the partial edge detection result based on the texel a7 can be obtained from the edge detection result of the texel b7 and can be used as the partial edge detection result corresponding to the first texel a.

[0072] The texel a8 can be adjacent to a texel b8 which has not been extracted for edge computing, the texel b8 can correspond to coordinates (2, -2), the texel a8 is between the first texel a and the texel b8, the texel b8 is symmetrical to the first texel a about the texel a8, and then the partial edge detection result based on the texel a8 can be obtained from the edge detection result of the texel b8 and can be used as the partial edge detection result corresponding to the first texel a.

[0073] Based on the above eight partial edge detection results (the edge detection results of a1, a2, a3, a4, a5, a6, a7 and a8) corresponding to the first texel a, the edge detection result corresponding to the first texel a can be determined.

[0074] Optionally, in the case that some of the pixels adjacent to the first pixel belong to the fourth pixel and some do not, if a pixel adjacent to the first pixel does not belong to the fourth pixel, an edge detection calculation can be performed based on the adjacent pixel, such as an edge detection calculation based on related art.

[0075] Optionally, in the case that some of the pixels adjacent to the first pixel belong to the fourth pixel and some do not, if a pixel adjacent to the first pixel belongs to the fourth pixel, a symmetric pixel of the first pixel with respect to the fourth pixel can be determined, and then the edge detection result corresponding to the first pixel can be obtained based on the part of the edge detection result of the fourth pixel symmetric pixel calculated based on the fourth pixel. For example, the first pixel a can be adjacent to pixels a1, a2, a3, a4, a5, a6, a7, and a8, wherein the first pixel a can correspond to coordinates (0, 0), the pixel a1 can correspond to coordinates (1, 0), the pixel a2 can correspond to coordinates (1, 1), the pixel a3 can correspond to coordinates (0, 1), the pixel a4 can correspond to coordinates (-1, 1), the pixel a5 can correspond to coordinates (-1, 0), the pixel a6 can correspond to coordinates (-1, -1), the pixel a7 can correspond to coordinates (0, -1), and the pixel a8 can correspond to coordinates (1, -1);

[0076] The pixel a1 can be adjacent to a pixel b1 that has not been subjected to edge calculation, and an edge detection calculation can be performed based on the pixel a1 to obtain a partial edge detection result corresponding to the first pixel a;

[0077] The pixel a2 can be adjacent to a pixel b2 that has not been subjected to edge calculation, and an edge detection calculation can be performed based on the pixel a2 to obtain a partial edge detection result corresponding to the first pixel a;

[0078] The pixel a3 can be adjacent to a pixel b3 that has not been subjected to edge calculation, and an edge detection calculation can be performed based on the pixel a3 to obtain a partial edge detection result corresponding to the first pixel a;

[0079] The pixel a4 can be adjacent to a pixel b4 that has not been subjected to edge calculation, and an edge detection calculation can be performed based on the pixel a4 to obtain a partial edge detection result corresponding to the first pixel a;

[0080] The pixel a5 can be adjacent to a pixel b5 that has not been subjected to edge calculation, and the pixel b5 can correspond to coordinates (-2, 0). The pixel a5 is between the first pixel a and the pixel b5, and the pixel b5 is symmetric to the first pixel a with respect to the pixel a5. Therefore, a partial edge detection result obtained based on the pixel a5 can be obtained from the edge detection result of the pixel b5 and can be used as a partial edge detection result corresponding to the first pixel a;

[0081] It can be determined whether the texel c to be calculated for edge detection needs to be calculated for edge detection based on the texel b5. If the texel c needs to be calculated for edge detection based on the texel b5, the texel can be saved in the register front point. The edge detection result of the symmetrical texel of the texel c is obtained based on the texel b5. From the edge detection result of the symmetrical texel of the texel c, the part obtained based on the texel b5 is obtained, and the edge detection result corresponding to the texel c can be determined.

[0082] The texel a6 can be adjacent to the texel b6 which does not perform edge calculation. The edge detection calculation can be performed based on the texel a6 to obtain the partial edge detection result corresponding to the first texel a.

[0083] The texel a7 can be adjacent to the texel b7 which has not been extracted for edge calculation. The texel b7 can correspond to the coordinate (0, -2). The texel a7 is between the first texel a and the texel b7. The texel b7 is symmetrical about the texel a7 with the first texel a. The partial edge detection result obtained based on the texel a7 can be obtained from the edge detection result of the texel b7, which can be used as the partial edge detection result corresponding to the first texel a.

[0084] It can be determined whether the texel d to be calculated for edge detection needs to be calculated for edge detection based on the texel b7. If the texel d needs to be calculated for edge detection based on the texel b7, the texel can be saved in the register front point. The edge detection result of the symmetrical texel of the texel d is obtained based on the texel b7. From the edge detection result of the symmetrical texel of the texel d, the part obtained based on the texel b7 is obtained, and the edge detection result corresponding to the texel d can be determined.

[0085] The texel a8 can be adjacent to the texel b8 which does not perform edge calculation. The edge detection calculation can be performed based on the texel a8 to obtain the partial edge detection result corresponding to the first texel a.

[0086] Based on the above eight partial edge detection results (a1, a2, a3, a4, a5, a6, a7 and a8) corresponding to the first texel a, the edge detection result corresponding to the first texel a can be determined.

[0087] For example, in the case where none of the texels adjacent to the first texel (such as texel A) is saved in the register front point, the related art can be used to calculate the edge detection result corresponding to the texel A based on the texel B.

[0088] For example, whether the following texel (texel C) to be edge detection calculation needs to perform edge detection calculation based on texel B when performing edge detection calculation can be detected. If edge detection calculation based on texel B is needed, texel B needs to be extracted when texel C performs edge detection calculation. Texel B can be stored in the register front point. Texel B can be directly extracted when texel C performs edge detection calculation, and edge detection calculation based on texel B is performed to determine the edge detection result corresponding to texel C. If texel A and texel C are symmetrical texels, texel C can directly extract part of the calculation result of texel A (i.e., part of the result based on texel B calculation). If edge detection calculation based on texel B is not needed (i.e., texel B is only adjacent to texel A), texel B can not be stored in the register front point after edge detection calculation based on texel B.

[0089] According to the edge detection method provided in the embodiments of the present application, in the case that all the texels adjacent to the first texel belong to the fourth texel, the edge detection result corresponding to the first texel is directly determined based on the part obtained by calculating the fourth texel. In the case that part of the texels adjacent to the first texel belong to the fourth texel and part of the texels adjacent to the first texel do not belong to the fourth texel, the edge detection result corresponding to the first texel is determined by performing edge detection calculation based on the texels adjacent to the first texel, and the texels belonging to the fourth texel are stored in the register front point. In the case that the adjacent texel of the texel to be edge detection is the texel stored in the register front point, repeated access to the global register is not needed, and the edge detection result calculated based on the texel stored in the register front point can be used to quickly obtain the edge detection result of the texel to be edge detection by using the symmetry of the texels in the spatial field, thereby reducing the calculation amount of edge detection, realizing that the edge detection result of all pixels in the field can be obtained by less calculation, reducing the complexity of edge detection, and improving the calculation efficiency of the mobile terminal fast edge detection method.

[0090] Optionally, the obtaining of the edge detection result corresponding to the first texel based on the edge detection result of the symmetrical texel of the first texel comprises:

[0091] The third texel adjacent to the first texel in the texture image is obtained by scanning the global memory, and a first part of the edge detection result corresponding to the first texel is calculated based on the third texel, wherein the third texel is not stored in the register front point;

[0092] A part obtained by calculating the fourth texel is obtained from the edge detection result of the symmetrical texel of the first texel as a second part of the edge detection result corresponding to the first texel;

[0093] The edge detection result corresponding to the first texel is obtained based on the first part and the second part.

[0094] Optionally, the third texel is not stored in the register front point.

[0095] For example, before the edge detection calculation of the first texel A is performed, the texels B, C and D which have performed the edge calculation are not extracted as the third texels, and the third texels are not stored in the register front point.

[0096] Optionally, the third texel can be adjacent to the first texel.

[0097] Optionally, the third texel can be obtained by scanning the global memory.

[0098] Optionally, the first part of the edge detection result corresponding to the first texel can be calculated based on the third texel.

[0099] Optionally, the part calculated based on the fourth texel can be obtained from the edge detection result of the symmetrical texel of the first texel as the second part of the edge detection result corresponding to the first texel.

[0100] Optionally, the edge detection result corresponding to the first texel can be obtained based on the first part and the second part.

[0101] Figure 2 is a processing flowchart of tex_operator provided by the embodiment of the present application, as shown in Figure 2 In the embodiment of the present application, the texel (third texel) read by the GPU once is placed in the memory, as shown in Figure 2 The right side shows (x, y), (x, y+1), (x, y+2) and (x, y+3), and the repeatedly sampled texels (fourth texels) are uniformly placed in the front point of the register, as shown in Figure 2 The right side shows (x, y), (x, y+1), (x, y+2) and (x, y+3), and the repeatedly sampled texels (fourth texels) are uniformly placed in the front point of the register, as shown in i Tex represents the texture of the texel i point, and in (x, y) and (x, y+1), Tex4,...,Tex9 are the texels which need to be repeatedly sampled, and similarly, in (x, y+1) and (x, y+2), Tex7,...Tex 12 , and in (x, y+2) and (x, y+3), Tex 10 ,...Tex 15 , so as to ensure that the access to the texels which need to be repeatedly sampled is always in the front point of the register, and the global register does not need to be repeatedly accessed;

[0102] The number of texels which need to be repeatedly sampled is 2 / 3 of the original pixel field, which means that 2 / 3 of the texels of the next calculation unit need to be repeatedly sampled; when three texel units are sampled, the number of memory accesses is 15, which is reduced by nearly 44% compared with 27 points in the related art ( Figure 2 The different blocks on the left represent the number of sampling of a texel unit)

[0103] It should be noted that, Figure 2 The left figure is the spatial relationship between the calculation unit of the edge detection algorithm and the field, and each space represents a texel unit. The edge detection algorithm needs to sample 9 data around (x, y) from the texture cache when calculating each texel (x, y). When calculating the next texel unit, part of the data sampled by the previous texel will be repeatedly sampled, resulting in low sampling efficiency.

[0104] Secondly, the access of the GPU calculation memory to the video memory is layered, and the reading speed of the register is obviously faster than that of the main memory. The relationship between adjacent texels and fields in the graphics acceleration algorithm can be used to optimize the reading efficiency of data.

[0105] In the embodiment of the application, the third texel is stored in the global memory, and the texel with a higher access frequency during sampling is stored in the register front point, so as to realize composite memory optimization. At the same time, the field range of the texture index calculation unit is introduced to process multiple texels read at a time, so as to achieve the effect of reading at a time and processing at a time. The GPU needs more than 300 clock cycles to access a data from the global memory, and only needs 10 clock cycles to access the data directly from the register, so the sampling efficiency can be improved.

[0106] Optionally, the fourth part obtained based on the fourth texel includes:

[0107] The second sum value of the image gray value obtained based on the fourth texel is obtained from the edge detection result of the symmetric texel of the first texel.

[0108] Optionally, the second sum value of the image gray value obtained based on the fourth texel can be obtained from the edge detection result of the symmetric texel of the first texel as the second part of the edge detection result corresponding to the first texel.

[0109] Optionally, the first part of the edge detection result corresponding to the first texel based on the third texel includes:

[0110] The first sum value of the image gray value based on the third texel is obtained as the first part;

[0111] The edge detection result corresponding to the first texel is obtained based on the first part and the second part, including:

[0112] The edge detection result corresponding to the first texel is obtained according to the difference between the first sum value and the second sum value.

[0113] Optionally, the third texel adjacent to the first texel in the texture image can be obtained by scanning the global memory, and the first sum value can be calculated based on the image gray value of the third texel as the first part of the edge detection result corresponding to the first texel.

[0114] Optionally, the edge detection result corresponding to the first texel can be obtained based on the difference between the first sum and the second sum.

[0115] Optionally, after sampling the texels in the image, in order to obtain the first and second sums, a full convolution operation can be performed with different edge detection operators. The specific steps are as follows:

[0116] g x g y These are the operators in the two directions of Sobel, as shown in formula (1). The non-zero values ​​of the operators are simply reversed in sign for column and row, and are symmetrical in themselves.

[0117]

[0118] Figure 3 This is a schematic diagram illustrating the operation process of the texel and edge detection operators provided in the embodiments of this application, as shown below. Figure 3 As shown, the neighborhood texels and edge detection operators obtained in step 2 are subjected to a full convolution operation. Figure 3 (Left side), such as Figure 3 As shown on the right, {G x G y} represents the edge detection result of the current texel, which can be represented by {g x ,g y} and texel p 5 The texel dot product of the domain is obtained, and when calculating the output point g(x,y+2), part of the calculation result of g(x,y) can be reused;

[0119] calculate Figure 2 The G of the three texels on the right x G y According to {g x ,g y The symmetry of} and tex_operator, through formula (2), A, B, C, D, E, F are the dot product results of the current computation unit and the Sobel operator (non-zero value):

[0120] A = g(y + n + 1, x - 1);

[0121] B = g(y + n + 1, x);

[0122] C = g(y+n+1,x+1);

[0123] D = g(y + n - 1, x - 1);

[0124] E = 2g(y + n - 1, x - 1);

[0125] F = g(y + n - 1, x - 1);

[0126] s(x, y + n) = A + B + C - D - E - F; (2) n is the number of output points;

[0127] Optionally, the first sum value A + B + C obtained based on the image gray value of the third texel can be obtained based on the image gray value of the third texel.

[0128] Optionally, the second sum value D + E + F of the image gray value in the edge detection result of the symmetric texel based on the first texel can be obtained.

[0129] Optionally, when n is even or odd in the range, A + B + C = D + E + F, so when calculating s(x, y + n), the value of A + B + C or D + E + F can be calculated only once, and the operation amount can be reduced by about 25%.

[0130] Optionally, when n is not even and not odd in the range, the edge detection result corresponding to the first texel can be obtained according to the difference between A + B + C and D + E + F.

[0131] In the embodiment of the application, when three texels are processed at the same time, the number of texture samples, the number of texture calculations, and the single texture utilization rate can all be effectively improved in performance.

[0132] Optionally, the method further includes:

[0133] obtaining an initial input image;

[0134] preprocessing the initial input image based on a Gaussian filter function and a median filter function to obtain the texture image to be edge detected.

[0135] Figure 4 is a flowchart of the edge detection method provided by the embodiment of the application, as shown in Figure 4 After obtaining the initial input image, first, the initial input image is preprocessed based on a Gaussian filter function and a median filter function, the weight between the two filters is determined through an adaptive weight fusion filtering method, then the calculation unit is taken as the base point in tex_operator for calculation, convolution filtering can be performed by using a sobel operator (or a scharr operator or other operators that can be used for image edge detection, which is not limited in the embodiment of the application), and finally the texture image to be edge detected is obtained through a parallel calculation pipeline.

[0136] Optionally, the initial input image is preprocessed based on the Gaussian filter function and the median filter function to obtain the texture image to be edge detected, comprising:

[0137] The first weight and the second weight corresponding to each pixel point in the initial input image are obtained, the first weight is the weight corresponding to the Gaussian filter function, and the second weight is the weight corresponding to the median filter function.

[0138] Based on the first weight and the second weight corresponding to each pixel point, the Gaussian filter function and the median filter function, all pixel points in the initial input image are filtered to obtain the texture image to be edge detected.

[0139] Optionally, the Gaussian filter function can be a linear smoothing filter function that selects weights according to the shape of the Gaussian function.

[0140] Optionally, the Gaussian filter function can be used to eliminate Gaussian noise, for example, it can be applied to the noise reduction process of image processing.

[0141] Optionally, the median filter function can be a nonlinear smoothing filter function, which can set the gray value of each pixel point to the median value of the gray values of all pixel points in a certain neighborhood window of the point.

[0142] Optionally, the median filter function can be used to filter out impulse noise while protecting the edges of the signal, so that the edges of the signal are not blurred.

[0143] Optionally, the preprocessing can be a smoothing process on the input image, which can be used to obtain the texture image to be edge detected.

[0144] Optionally, the smoothing process can be realized by an adaptive weight fusion filtering method.

[0145] Optionally, the adaptive weight fusion filtering method can make full use of the advantages of median filter in suppressing noise and the characteristics of Gaussian filter in preserving basic edge information of the image. By weight fusion of the two filters through the maximum inter-class variance method, the correctness and efficiency of data processing can be effectively guaranteed. The specific steps are as follows:

[0146] First, set g(x, y) to represent the image gray value of pixel point (x, y), set w(i, j) to represent the initial window size, g min , g mid , g max , respectively represent the minimum value, the median value and the maximum value of the gray value under the window;

[0147] If gmin g max , output g(x,y), otherwise output g mid , output g min , output g mid , output g max , continue to execute g min , output g max , then increase the window size based on w(i,j), and finally output g mid ;

[0148] The above results are adaptively Gaussian filtered, and a Gaussian kernel function is first generated using a Gaussian filter function. The Gaussian kernel function is shown in formula (3):

[0149] k is the Gaussian kernel radius, and sigma is the standard deviation.(3)

[0150] The variance D(x,y) of a certain region S(x,y) of the image is shown in formula (4), which is proportional to the degree of dispersion of the pixel value. Selecting a smaller sigma results in a larger Gaussian kernel coefficient weight. R(x,y) is an adaptive filter function related to k and sigma, which determines the result of adaptive weight filtering, as shown in formula (5):

[0151]

[0152]

[0153] The weight fusion information is shown in formula (6). Each pixel will get a weight value of a filter scheme. The solution of adaptive weight fusion needs to establish an objective function based on formula (3) and formula (6) simultaneously, and finally uses the least square method to fit and solve;

[0154] f(x)=a+bx+cy 2 (6)

[0155] It should be noted that f(x)=lnf(x), After solving, we can get By analogy, iterative target function can get adaptive weight fusion filter, and finally all pixel points of the image are preprocessed to get the preprocessed texture image.

[0156] In the embodiments of the application, the edge detection algorithm of each embodiment of the application can be deployed on hardware according to the hardware characteristics of the mobile terminal GPU, and the specific steps are as follows:

[0157] Each rendering pipeline concurrently stores image data. The Compute Shader (program running on GPU) in the pipeline stores n 4-dimensional vectors, which contain the weight values of the texel neighborhood.

[0158] Half of the Sobel operator weights are stored in Compute Shader 1 in the first pipeline, and the other half are stored in Compute Shader 2 in the second pipeline;

[0159] Compute Shader 1 and Compute Shader 2 are executed concurrently, and one execution can obtain the execution result of one Sobel operator, and the operation speed is further improved.

[0160] In the embodiment of the present application, when the adjacent texel of the first texel is stored in the register front point, the fourth texel adjacent to the first texel is directly extracted from the register front point, without repeated access to the global register, and the symmetry relationship of the texel in the spatial field is utilized to obtain the edge detection result of the first texel based on the calculated edge detection result of the symmetric texel of the first texel, thereby reducing the calculation amount of edge detection, reducing the calculation times through the parallel computing capability of the mobile terminal GPU, reducing the complexity of edge detection, and improving the calculation efficiency of the mobile terminal fast edge detection method.

[0161] In one embodiment, the edge detection method can include the following steps:

[0162] Step 1: First, an adaptive weight fusion filtering method is used to smooth the input image. This method fully utilizes the advantages of median filtering in suppressing noise and the characteristics of Gaussian filtering in preserving basic edge information of the image. The above two are fused by weight through the maximum inter-class variance method to ensure the correctness and efficiency of data processing. The specific steps are as follows:

[0163] Step 101: First, set g(x, y) to represent the image gray value of pixel point (x, y), set w(i, j) to represent the initial window size, g min , g mid , g max respectively represent the minimum value, the intermediate value and the maximum value of the gray value under the window;

[0164] Step 102: If g min <g(x, y)<g max , output g(x, y), otherwise output g mid , when g min <g mid <g max , continue to execute g min <g(x, y)<g max , then increase the window size on the basis of w(i, j), and finally output g mid ;

[0165] Step 103: The above results are adaptively filtered by a Gaussian filter. First, a Gaussian kernel function is generated using a Gaussian filter function. The Gaussian kernel function is shown in equation (7):

[0166] k is the Gaussian kernel radius, and σ is the standard deviation. (7)

[0167] Step 104: The variance D(x, y) of a certain region S(x, y) of the image is shown in equation (8). The variance D(x, y) is directly proportional to the degree of dispersion of the pixel value. Selecting a smaller σ results in a larger Gaussian kernel coefficient weight. R(x, y) is an adaptive filter function related to k and σ, which determines the adaptive weight filtering result, as shown in equation (9).

[0168]

[0169]

[0170] Step 105: The weight fusion information is shown in equation (10). Each pixel will obtain a weight value of a filter scheme. The solution of adaptive weight fusion needs to establish an objective function based on equation (7) and equation (10) simultaneously, and finally use the least squares method to fit and solve.

[0171] f(x) = a + bx + cy 2 (10)

[0172] Step 106: At this time, f(x) = ln f(x), After solving, we can get Similarly, iterative target function can get adaptive weight fusion filter, and finally all pixel points of the image are processed.

[0173] Step 2: After obtaining the texture image processed by adaptive weight fusion filter, texture caches can be efficiently used to reduce the computational complexity and improve the parallelism of GPU through composite memory access mode and symmetric calculation technology. The specific steps are as follows:

[0174] Step 201: Figure 2 The left figure shows the spatial relationship between the calculation unit and the field of the edge detection algorithm. Each space represents a texel unit. The edge detection needs to sample 9 data around (x, y) from the texture cache for each calculation of a texel (x, y). When calculating the next texel unit, part of the data sampled by the previous texel will be repeatedly sampled, resulting in low sampling efficiency.

[0175] Step 202: GPU calculates the memory access of the display memory, the reading speed of the register is obviously faster than the speed of the main memory, and the relationship between adjacent pixels and fields in the graphics acceleration algorithm can be used to optimize the reading efficiency of data;

[0176] Step 203: the pixel (third pixel) read by the GPU once is placed in the memory, as shown in Figure 2 The right side shows: (x, y), (x, y+1), (x, y+2) and (x, y+3), and the repeatedly sampled pixels (fourth pixels) are uniformly placed in the front point of the register, as shown in Figure 2 The right side shows: Tex i Tex4,...,Tex9 are the pixels that need to be repeatedly sampled, and similarly, in (x, y+1) and (x, y+2), Tex7,...Tex 12 , and in (x, y+2) and (x, y+3), Tex 10 ,...Tex 15 , so as to ensure that the access to the pixels that need to be repeatedly sampled is always in the front point of the register, and there is no need to repeatedly access the global register;

[0177] Step 204: through the above composite memory optimization, the range of the texture index calculation unit is introduced, and multiple pixels read once are processed, achieving the effect of reading once and processing in batches. GPU needs more than 300 clock cycles to access a data from the global memory, while it only needs 10 clock cycles to access data directly from the register, which can improve the memory access efficiency;

[0178] Step 205: the number of pixels that need to be repeatedly sampled is 2 / 3 of the original pixel field, which means that 2 / 3 of the pixels of the next calculation unit need to be repeatedly sampled; when sampling 3 pixel units, the number of memory accesses is 15, which is nearly 44% less than 27 points in the related art. Figure 2

[0179] Step 3: after efficiently sampling the pixels in the image, full convolution operation can be performed with different edge detection operators, and the specific steps are as follows:

[0180] Step 301: g x , g y are two direction operators of Sobel, see formula (11), the non-zero values of the operator are only opposite in sign by column and by row, and have symmetry by themselves;

[0181]

[0182] ​Step 302: as shown in the left side of Figure 3 , the field texture and the edge detection operator obtained in step 2 are subjected to full convolution operation Figure 3 , as shown in the right side of Figure 3 , {G x ,G y} represents the edge detection result of the current texture, which can be obtained by the dot product of {g x ,g y} and the texture p 5 field, when calculating the output point g(x, y+2), part of the calculation result of g(x, y) can be reused;

[0183] Step 303: calculate Figure 2 the G x ,G y of the three textures on the right side according to the symmetry of {g x ,g y} and the tex_operator, through formula (12), A, B, C, D, E, F are respectively the dot product results of the current calculation unit and the Sobel operator (non-0 value):

[0184] A=g(y+n+1, x-1);

[0185] B=g(y+n+1, x);

[0186] C=g(y+n+1, x+1);

[0187] D=g(y+n-1, x-1);

[0188] E=2g(y+n-1, x-1);

[0189] F=g(y+n-1, x-1);

[0190] s(x, y+n)=A+B+C-D-E-F; (12) n is the number of output points;

[0191] Step 304: by observing formula (12) and g x ,g y , it can be found that when n is even or odd in the range, A+B+C=D+E+F, when calculating s(x, y+n), only the value of A+B+C or D+E+F needs to be calculated once, and the operation amount can be reduced by about 25%;

[0192] Step 305: Table 1 is the performance improvement efficiency table provided by the embodiment of the present application, as shown in Table 1, in the case of processing three textures at the same time, the texture sampling number, the texture calculation number and the single texture utilization rate can all be effectively improved in performance.

[0193] Table 1 Performance improvement efficiency table

[0194]

[0195] Step 4: After the data and algorithm are determined, the edge detection algorithm of each embodiment of the present application can be deployed on the hardware according to the hardware characteristics of the mobile end GPU, and the specific steps are as follows:

[0196] Step 401: Each rendering pipeline concurrently stores image data, and the Compute Shader in the pipeline stores n 4-dimensional vectors containing the weight values of the texel neighborhood;

[0197] Step 402: Half of the Sobel operator weight values are stored in the Compute Shader1 of the first pipeline, and the other half are stored in the Compute Shader2 in the second pipeline;

[0198] Step 403: Compute Shader1 and Compute Shader2 are concurrently executed, and one execution can obtain the execution result of one Sobel operator, and the operation speed is further improved.

[0199] The edge detection method provided by the embodiments of the present application can be executed by the edge detection device. In the embodiments of the present application, the edge detection device is taken as an example to illustrate the edge detection device provided by the embodiments of the present application.

[0200] The embodiments of the present application also provide an edge detection device.

[0201] Figure 5 is a structural schematic diagram of the edge detection device provided by the embodiments of the present application, as shown in Figure 5 The edge detection device 500 includes a first acquisition module 510, a second acquisition module 520, a third acquisition module 530, and a fourth acquisition module 540.

[0202] The first acquisition module 510 is configured to acquire a texture image to be edge detected.

[0203] The second acquisition module 520 is configured to extract a fourth texel adjacent to a first texel in the texture image from a register front point, and determine a symmetric texel of the first texel based on the fourth texel, wherein the symmetric texel is adjacent to the fourth texel, the first texel is symmetric about the fourth texel with respect to the symmetric texel, and the first texel is a texel to be edge detected and calculated.

[0204] The third acquisition module 530 is configured to acquire an edge detection result of the symmetric texel of the first texel based on the fourth texel.

[0205] The fourth obtaining module 540 is configured to obtain the edge detection result corresponding to the first texel based on the edge detection result of the symmetrical texel of the first texel.

[0206] In the embodiment of the present application, when the adjacent texel of the first texel is stored in the register front point, the fourth texel adjacent to the first texel is directly extracted from the register front point, without repeated access to the global register, and the edge detection result of the first texel is obtained based on the calculated edge detection result of the symmetrical texel of the first texel, which reduces the calculation amount of edge detection, reduces the calculation times through the parallel computing capability of the mobile terminal GPU, reduces the complexity of edge detection, and improves the calculation efficiency of the mobile terminal fast edge detection method.

[0207] Optionally, the fourth obtaining module 540 is specifically configured to:

[0208] obtain, from the edge detection result of the symmetrical texel of the first texel, a part calculated based on the fourth texel, and determine the edge detection result corresponding to the first texel.

[0209] Optionally, the fourth obtaining module 540 is further configured to:

[0210] obtain, from the edge detection result of the symmetrical texel of the first texel, a part calculated based on the fourth texel, and determine the edge detection result corresponding to the first texel.

[0211] obtain, from the edge detection result of the symmetrical texel of the first texel, a part calculated based on the fourth texel, as a second part of the edge detection result corresponding to the first texel;

[0212] obtain the edge detection result corresponding to the first texel based on the first part and the second part.

[0213] Optionally, the fourth obtaining module 540 is further configured to:

[0214] obtain, from the edge detection result of the symmetrical texel of the first texel, a second sum value of image gray values calculated based on the fourth texel.

[0215] Optionally, the fourth obtaining module 540 is further configured to:

[0216] obtain, from the edge detection result of the symmetrical texel of the first texel, a second sum value of image gray values calculated based on the fourth texel.

[0217] obtain the edge detection result corresponding to the first texel according to the difference between the first sum value and the second sum value.

[0218] Optionally, the first obtaining module 510 is further configured to:

[0219] obtain an initial input image;

[0220] perform preprocessing on the initial input image based on a Gaussian filter function and a median filter function to obtain the texture image to be subjected to edge detection.

[0221] Optionally, the first obtaining module 510 is further configured to:

[0222] obtain a first weight and a second weight corresponding to each pixel point in the initial input image respectively, the first weight being a weight corresponding to the Gaussian filter function, and the second weight being a weight corresponding to the median filter function;

[0223] perform filter processing on all pixel points in the initial input image based on the first weight and the second weight corresponding to each pixel point respectively, the Gaussian filter function and the median filter function, to obtain the texture image to be subjected to edge detection.

[0224] In the embodiments of the present application, in the case that the adjacent texels of the first texel are stored in the register front point, the fourth texel adjacent to the first texel is directly extracted from the register front point, repeated access to the global register is not needed, and the edge detection result of the first texel is obtained based on the calculated edge detection result of the symmetric texel of the first texel by using the symmetric relationship of the texels in the spatial field, the calculation amount of edge detection is reduced, the calculation frequency is reduced through the parallel computing capability of the mobile terminal GPU, the complexity of edge detection is reduced, and the efficiency of the mobile terminal fast edge detection method calculation is improved.

[0225] The edge detection apparatus in the embodiments of the present application can be an electronic device or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other device than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted electronic device, a Mobile Internet Device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), or the like, and can also be a server, a Network Attached Storage (NAS), a personal computer (PC), a television (TV), a cash register, a self-service machine, or the like. The embodiments of the present application are not limited in this regard.

[0226] The edge detection apparatus in the embodiments of the present application can be a device with an operating system. The operating system can be an Android operating system, an ios operating system, or other possible operating system. The embodiments of the present application are not limited in this regard.

[0227] The edge detection apparatus provided by the embodiments of the present application can implement the method embodiments, and each process of the method embodiments is not repeated here. Figures 1 to 4 The method embodiments implement each process, and to avoid repetition, each process is not repeated here.

[0228] Optionally, as shown in Figure 6 The embodiments of the present application also provide an electronic device 600, which includes a processor 601, a memory 602, and a program or instruction stored in the memory 602 and executable on the processor 601. When the program or instruction is executed by the processor 601, each process of the above edge detection method embodiments is implemented, and the same technical effects are achieved. To avoid repetition, each process is not repeated here.

[0229] It should be noted that the electronic device in the embodiments of the present application includes the mobile electronic device and the non-mobile electronic device.

[0230] Figure 7 To implement the hardware structure of an electronic device according to an embodiment of the present application.

[0231] The electronic device 700 includes, but is not limited to, a radio frequency unit 701, a network module 702, an audio output unit 703, an input unit 704, a sensor 705, a display unit 706, a user input unit 707, an interface unit 708, a memory 709, and a processor 710, etc.

[0232] Those skilled in the art can understand that the electronic device 700 can also include a power supply (such as a battery) for supplying power to each component, and the power supply can be logically connected to the processor 710 through a power management system, so that the power management system can realize functions such as management of charging, discharging, and power consumption management. Figure 7 The electronic device structure shown in the figure is not a limitation on the electronic device, and the electronic device can include more or fewer components than shown, or combine certain components, or different component arrangements, which will not be described here.

[0233] The processor 710 is configured to obtain a texture image to be edge detected.

[0234] A fourth texel adjacent to the first texel in the texture image is extracted from the register front point, and a symmetric texel of the first texel is determined based on the fourth texel, wherein the symmetric texel is adjacent to the fourth texel, the first texel is symmetric about the fourth texel with respect to the symmetric texel, and the first texel is a texel to be calculated for edge detection.

[0235] An edge detection result of the symmetric texel of the first texel is obtained based on the fourth texel.

[0236] Based on the edge detection result of the symmetric texel of the first texel, an edge detection result corresponding to the first texel is obtained.

[0237] In the embodiments of the present application, in the case where the adjacent texels of the first texel are stored in the register front point, the fourth texel adjacent to the first texel is directly extracted from the register front point, without repeated access to the global register, and the symmetric relationship of the texels in the spatial field is utilized to obtain the edge detection result of the first texel based on the calculated edge detection result of the symmetric texel of the first texel, thereby reducing the calculation amount of edge detection, reducing the number of calculations through the parallel computing capability of the mobile terminal GPU, reducing the complexity of edge detection, and improving the calculation efficiency of the mobile terminal fast edge detection method.

[0238] Optionally, the processor 710 is further configured to:

[0239] From the edge detection result of the symmetric texel of the first texel, a part calculated based on the fourth texel is obtained, and an edge detection result corresponding to the first texel is determined.

[0240] Optionally, the processor 710 is further configured to:

[0241] obtain a third texel adjacent to the first texel in the texture image by scanning the global memory, and calculate a first part of the edge detection result corresponding to the first texel based on the third texel, the third texel not being stored in the register front point;

[0242] obtain, from the edge detection result of the symmetric texel of the first texel, a part calculated based on the fourth texel as a second part of the edge detection result corresponding to the first texel;

[0243] obtain the edge detection result corresponding to the first texel based on the first part and the second part.

[0244] Optionally, the processor 710 is further configured to:

[0245] obtain, from the edge detection result of the symmetric texel of the first texel, a second sum of image gray values calculated based on the fourth texel.

[0246] Optionally, the processor 710 is further configured to:

[0247] obtain, as the first part, a first sum of image gray values calculated based on the third texel.

[0248] obtain the edge detection result corresponding to the first texel according to a difference between the first sum and the second sum.

[0249] Optionally, the processor 710 is further configured to:

[0250] obtain an initial input image;

[0251] perform preprocessing on the initial input image based on a Gaussian filter function and a median filter function to obtain the texture image to be edge-detected.

[0252] Optionally, the processor 710 is further configured to:

[0253] obtain a first weight and a second weight corresponding to each pixel point in the initial input image respectively, the first weight being a weight corresponding to the Gaussian filter function, and the second weight being a weight corresponding to the median filter function;

[0254] perform filter processing on all pixel points in the initial input image based on the first weight and the second weight corresponding to each pixel point respectively, the Gaussian filter function and the median filter function, to obtain the texture image to be edge-detected.

[0255] In the embodiment of the present application, in the case that the adjacent texel of the first texel is stored in the register front point, the fourth texel adjacent to the first texel is directly extracted from the register front point, repeated access to the global register is not needed, and the edge detection result of the first texel is obtained based on the calculated edge detection result of the symmetric texel of the first texel by using the symmetric relationship of the texels in the spatial field, the calculation amount of edge detection is reduced, the calculation frequency is reduced by the parallel computing capability of the mobile terminal GPU, the complexity of edge detection is reduced, and the calculation efficiency of the mobile terminal fast edge detection method is improved.

[0256] It should be understood that in the embodiments of the present application, the input unit 704 can include a graphics processor (GPU) 7041 and a microphone 7042. The graphics processor 7041 processes image data of a still picture or a video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 706 can include a display panel 7061, which can be configured in the form of a liquid crystal display, an organic light-emitting diode, etc. The user input unit 707 includes a touch panel 7071 and other input devices 7072. The touch panel 7071 is also called a touch screen. The touch panel 7071 can include two parts of a touch detection device and a touch controller. The other input devices 7072 can include, but are not limited to, a physical keyboard, function keys (such as volume control keys, on-off keys, etc.), a trackball, a mouse, an operation lever, and the like, which will not be described here.

[0257] The memory 709 can be used to store software programs and various data. The memory 709 can mainly include a first storage area storing programs or instructions and a second storage area storing data, wherein the first storage area can store an operating system, application programs or instructions required by at least one function (such as a sound playing function, an image playing function, etc.), and the like. In addition, the memory 709 can include a volatile memory or a non-volatile memory, or the memory 709 can include both a volatile memory and a non-volatile memory. The non-volatile memory can be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically EPROM (EEPROM), or a flash memory. The volatile memory can be a Random Access Memory (RAM), a Static RAM (SRAM), a Dynamic RAM (DRAM), a Synchronous DRAM (SDRAM), a Double Data Rate SDRAM (DDR SDRAM), an Enhanced SDRAM (ESDRAM), a Synch link DRAM (SLDRAM), and a Direct Rambus RAM (DRRAM). The memory 709 in the embodiments of the present application includes but is not limited to these and any other suitable types of memory.

[0258] The processor 710 can include one or more processing units; optionally, the processor 710 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and an application program, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 710.

[0259] The embodiments of the present application also provide a readable storage medium, the readable storage medium stores programs or instructions, the programs or instructions are executed by a processor to realize various processes of the above edge detection method embodiments, and the same technical effects can be achieved. To avoid repetition, details are not described here.

[0260] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes a computer readable storage medium, such as a computer readable only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0261] The embodiment of the present application further provides a chip, which comprises a processor and a communication interface, the communication interface is coupled with the processor, the processor is used for running programs or instructions to realize the processes of the above edge detection method embodiments and achieve the same technical effects. To avoid repetition, details are not described herein.

[0262] It should be understood that the chip mentioned in the embodiment of the present application can also be referred to as a system chip, a system chip, a chip system or a system on chip, etc.

[0263] The embodiment of the present application provides a computer program product, which is stored in a storage medium, and the program product is executed by at least one processor to realize the processes of the above edge detection method embodiments and achieve the same technical effects. To avoid repetition, details are not described herein.

[0264] It should be noted that in this document, the term "comprise", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such a process, method, article or device. Without more limitations, the element defined by the statement "comprises a" does not exclude the presence of additional identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the method and device in the embodiment of the present application is not limited to the order of performing the functions as shown or discussed, but can also include performing the functions in a substantially simultaneous manner or in the opposite order, for example, the described method can be performed in an order different from that described, and various steps can also be added, omitted or combined. In addition, the features described with reference to certain examples can be combined in other examples.

[0265] Through the above description of the embodiments, those skilled in the art can clearly understand that the above-mentioned example methods can be realized by means of software and a necessary general hardware platform, and of course, can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a computer software product in essence or in the form of a part that contributes to the prior art, which is stored in a storage medium (such as a ROM / RAM, a magnetic disk, or an optical disk) and includes a plurality of instructions for causing a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application.

[0266] The embodiments of the present application are described above in combination with the drawings, but the present application is not limited to the above-mentioned specific embodiments, and the above-mentioned specific embodiments are only illustrative and not restrictive. Those skilled in the art can make many forms under the inspiration of the present application without departing from the scope of the present application and the scope protected by the claims.

Claims

1. A method of edge detection, characterized by, The method comprises: obtaining a texture image to be edge detected; extracting a fourth pixel adjacent to a first pixel in the texture image from a register front point, and determining a symmetric pixel of the first pixel based on the fourth pixel, wherein the symmetric pixel is adjacent to the fourth pixel, the first pixel is symmetric to the symmetric pixel about the fourth pixel, and the first pixel is a pixel to be calculated for edge detection; obtaining an edge detection result of the symmetric pixel of the first pixel based on the fourth pixel; obtaining an edge detection result corresponding to the first pixel based on the edge detection result of the symmetric pixel of the first pixel; the obtaining of the edge detection result corresponding to the first pixel based on the edge detection result of the symmetric pixel of the first pixel comprises: obtaining a third pixel adjacent to the first pixel in the texture image by scanning a global memory, and calculating a first part of the edge detection result corresponding to the first pixel based on the third pixel, wherein the third pixel is not stored in the register front point; obtaining, from the edge detection result of the symmetric pixel of the first pixel, a part calculated based on the fourth pixel as a second part of the edge detection result corresponding to the first pixel; obtaining the edge detection result corresponding to the first pixel based on the first part and the second part; wherein the fourth pixel is loaded into the register front point when calculating the edge detection result of the symmetric pixel, and an operator used in edge detection is a linear convolution operator with geometric symmetry.

2. The edge detection method according to claim 1, wherein the obtaining, from the edge detection result of the symmetric pixel of the first pixel, of the part calculated based on the fourth pixel comprises: obtaining, from the edge detection result based on the symmetric pixel of the first pixel, a second sum of image gray values calculated based on the fourth pixel.

3. The edge detection method of claim 1, wherein the calculating of the first part of the edge detection result corresponding to the first pixel based on the third pixel comprises: obtaining a first sum of image gray values calculated based on the third pixel as the first part; the obtaining of the edge detection result corresponding to the first pixel based on the first part and the second part comprises: obtaining the edge detection result corresponding to the first pixel according to a difference between the first sum and the second sum.

4. The edge detection method of claim 1, wherein The method comprises: obtaining an initial input image; preprocessing the initial input image based on a Gaussian filter function and a median filter function to obtain the texture image to be edge detected.

5. The edge detection method of claim 4, wherein, The preprocessing of the initial input image based on the Gaussian filter function and the median filter function to obtain the texture image to be edge detected comprises: obtaining a first weight and a second weight corresponding to each pixel point in the initial input image respectively, wherein the first weight is a weight corresponding to the Gaussian filter function, and the second weight is a weight corresponding to the median filter function; filtering all pixel points in the initial input image based on the first weight and the second weight corresponding to each pixel point respectively, the Gaussian filter function and the median filter function to obtain the texture image to be edge detected.

6. An edge detection device, characterized by The method comprises: The first obtaining module is configured to obtain a texture image to be edge detected; The second obtaining module is configured to extract a fourth texel adjacent to the first texel in the texture image from a register front point, and determine a symmetric texel of the first texel based on the fourth texel, wherein the symmetric texel is adjacent to the fourth texel, the first texel is symmetric to the symmetric texel about the fourth texel, and the first texel is a texel to be calculated for edge detection; The third obtaining module is configured to obtain an edge detection result of the symmetric texel of the first texel based on the fourth texel; The fourth obtaining module is configured to obtain an edge detection result corresponding to the first texel based on the edge detection result of the symmetric texel of the first texel; The fourth obtaining module is configured to: obtain a third texel adjacent to the first texel in the texture image by scanning a global memory, and calculate a first part of the edge detection result corresponding to the first texel based on the third texel, wherein the third texel is not stored in the register front point; obtain, from the edge detection result of the symmetric texel of the first texel, a part calculated based on the fourth texel as a second part of the edge detection result corresponding to the first texel; obtain the edge detection result corresponding to the first texel based on the first part and the second part; In the edge detection, an operator used is a linear convolution operator with geometric symmetry.

7. The edge detection device of claim 6, wherein, The fourth obtaining module is further configured to: obtain, from the edge detection result based on the symmetric texel of the first texel, a second sum of image gray scale values calculated based on the fourth texel.

8. The edge detection device of claim 6, wherein, The fourth obtaining module is further configured to: obtain a first sum of image gray scale values calculated based on the third texel as the first part. obtain the edge detection result corresponding to the first texel according to a difference between the first sum and the second sum.

9. The edge detection apparatus of claim 6, wherein The first obtaining module is further configured to: obtain an initial input image; perform preprocessing on the initial input image based on a Gaussian filter function and a median filter function to obtain the texture image to be edge detected.

10. The edge detection device of claim 9, wherein, The first obtaining module is further configured to: obtain a first weight and a second weight corresponding to each pixel point in the initial input image respectively, wherein the first weight is a weight corresponding to the Gaussian filter function, and the second weight is a weight corresponding to the median filter function; perform filter processing on all pixel points in the initial input image based on the first weight and the second weight corresponding to each pixel point respectively, the Gaussian filter function, and the median filter function to obtain the texture image to be edge detected.

11. An electronic device, comprising: A processor and a memory are included, the memory stores programs or instructions executable on the processor, and the programs or instructions are executed by the processor to implement the steps of the edge detection method according to any one of claims 1-5.

12. A readable storage medium, characterized by, The readable storage medium stores programs or instructions, and the programs or instructions are executed by the processor to implement the steps of the edge detection method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Detecting edges of a nucleus using image analysis

    CA2948226A1

  • Image edge detection method and device, electronic equipment and storage medium

    CN114998377A