Image edge detection method and device

By performing color gamut division and edge pixel marking on the image to be detected, the problems of high image noise sensitivity and complexity in the prior art are solved, and efficient image edge detection is achieved.

CN119625008APending Publication Date: 2025-03-14BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411747530.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

The existing edge detection methods are sensitive to image noise, have high complexity, and take a long time to process.

Method used

By dividing the image to be detected in a color gamut, multiple color gamut regions are obtained; the edge pixels and their gradient amplitude in each color gamut region are determined, and the edge pixels whose gradient amplitude meet the preset conditions are marked as strong edge pixels; the edges of the image to be detected are determined based on the strong edge pixels of each color gamut region.

Benefits of technology

Effectively process image noise, reduce detection complexity and improve image processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119625008A_ABST
    Figure CN119625008A_ABST
Patent Text Reader

Abstract

The invention discloses an image edge detection method and device, and relates to the technical field of computers. A specific embodiment of the method comprises the following steps: performing color gamut division on a to-be-detected image to obtain a plurality of color gamut regions; edge pixels in each color gamut area and gradient amplitudes of the edge pixels are determined, and the edge pixels with the gradient amplitudes meeting preset conditions are marked as strong edge pixels of the color gamut areas; and determining the edge of the to-be-detected image based on the strong edge pixel of each color gamut region. According to the embodiment, the image noise can be effectively processed, the detection complexity is reduced, and the image processing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an image edge detection method and device. Background Art

[0002] Edge detection is an important step in computer vision. It can be used to identify objects or areas in images, thereby realizing applications such as target detection, object recognition, and image segmentation. For example, corporate users use it for financial bills and contract recognition, human resources resume recognition, and face recognition.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the related art:

[0004] Existing edge detection methods are sensitive to image noise, have high complexity, and take a long time to process. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides an image edge detection method and device, which can effectively process image noise, reduce detection complexity, and improve image processing efficiency.

[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for detecting an edge of an image is provided, comprising:

[0007] Divide the image to be detected into color gamut to obtain multiple color gamut areas;

[0008] Determine edge pixels and gradient magnitudes of edge pixels in each color gamut region, and mark edge pixels whose gradient magnitudes meet preset conditions as strong edge pixels of the color gamut region;

[0009] The edge of the image to be detected is determined based on the strong edge pixels in each color gamut area.

[0010] Optionally, before dividing the color gamut of the image to be detected, the method further includes:

[0011] Determine the row and column coordinates of each pixel in the image to be detected;

[0012] Obtaining the optical three primary color values ​​of each pixel based on the row coordinate and the column coordinate of each pixel;

[0013] A pixel matrix is ​​constructed according to the optical three primary color values ​​of each pixel, so as to divide the color gamut of the image to be detected according to the pixel matrix.

[0014] Optionally, the image to be detected is divided into color gamuts to obtain multiple color gamut regions, including:

[0015] Convert the optical three primary color values ​​of each pixel in the pixel matrix into a feature vector;

[0016] A clustering algorithm is used based on the feature vector to obtain multiple color gamut regions.

[0017] Optionally, determining edge pixels in each color gamut region includes:

[0018] The pixels in each color gamut area are traversed, and in response to the area value of the pixel being different from that of any neighboring pixel of the pixel, the pixel is determined to be an edge pixel of the color gamut area; wherein the area value is the optical three primary color value of the centroid of the color gamut area.

[0019] Optionally, marking edge pixels whose gradient amplitudes satisfy preset conditions as strong edge pixels of the color gamut area includes:

[0020] The grayscale value of each edge pixel is compared with the grayscale value of each neighboring pixel of the edge pixel, and in response to the grayscale value of the edge pixel being greater than the grayscale value of each neighboring pixel of the edge pixel, the edge pixel is marked as a strong edge pixel of the color gamut region.

[0021] Optionally, determining the edge of the image to be detected based on the strong edge pixels in each color gamut area includes:

[0022] Adjusting the optical three primary color values ​​of the strong edge pixels in each color gamut area to a first color value, and adjusting the optical three primary color values ​​of other pixels except the strong edge pixels to a second color value; wherein the first color value and the second color value are different;

[0023] A new pixel matrix is ​​constructed based on the adjusted pixels, and the edge of the image to be detected is determined according to the new pixel matrix.

[0024] According to a second aspect of an embodiment of the present invention, there is provided an image edge detection device, comprising:

[0025] A color gamut division module is used to divide the color gamut of the image to be detected into multiple color gamut areas;

[0026] A pixel marking module is used to determine the edge pixels and the gradient amplitude of the edge pixels in each color gamut area, and mark the edge pixels whose gradient amplitude meets the preset conditions as strong edge pixels of the color gamut area;

[0027] The edge determination module is used to determine the edge of the image to be detected based on the strong edge pixels in each color gamut area.

[0028] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, including:

[0029] one or more processors;

[0030] a memory for storing one or more programs,

[0031] When one or more programs are executed by one or more processors, the one or more processors are enabled to implement the method of any of the above embodiments.

[0032] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method of any of the above embodiments is implemented.

[0033] According to a fifth aspect of an embodiment of the present invention, there is provided a computer program product, including a computer program, which implements the method of any of the above embodiments when the computer program is executed by a processor.

[0034] An embodiment of the above invention has the following advantages or beneficial effects: by dividing the image to be detected into color gamuts, a plurality of color gamut areas are obtained; the edge pixels in each color gamut area and the gradient amplitude of the edge pixels are determined, and the edge pixels whose gradient amplitudes meet preset conditions are marked as strong edge pixels of the color gamut area; the edge of the image to be detected is determined based on the strong edge pixels in each color gamut area; thereby, image noise can be effectively processed, detection complexity is reduced, and image processing efficiency is improved.

[0035] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0037] Figure 1 is a schematic diagram of the main process of the image edge detection method according to an embodiment of the present invention;

[0038] Figure 2 is a schematic diagram of the main process of an image edge detection method according to a preferred embodiment of the present invention;

[0039] Figure 3 is a schematic diagram of the main process of clustering and dividing the image color gamut according to a preferred embodiment of the present invention;

[0040] Figure 4 is a schematic diagram of the main process of marking regional strong edge pixels according to a preferred embodiment of the present invention;

[0041] Figure 5 is a schematic diagram of main modules of an image edge detection device according to an embodiment of the present invention;

[0042] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0043] Figure 7It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0044] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0045] It should be noted that the acquisition, storage and application of personal information etc. involved in the embodiments of the present invention are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0046] Edge detection is an important step in computer vision. It can be used to identify objects or areas in an image, thereby realizing applications such as target detection, object recognition, and image segmentation. For example, enterprise users use it for bill and contract recognition in finance, resume recognition in human resources, and face recognition. At present, image edge detection methods are sensitive to image noise, have high complexity, and take a long time to process.

[0047] In view of this, according to one aspect of an embodiment of the present invention, a method for detecting an edge of an image is provided.

[0048] Figure 1 FIG. 1 is a schematic diagram of the main process of the image edge detection method according to an embodiment of the present invention. Figure 1 As shown, the image edge detection method according to the embodiment of the present invention includes the following steps S101 to S103.

[0049] Step S101, dividing the image to be detected into color gamuts to obtain multiple color gamut regions.

[0050] The image to be detected refers to the image that needs to be analyzed or processed, which can be any type of digital image. The digital image contains the visual information to be processed, such as color, shape, and texture. The color gamut area refers to the area obtained by grouping or classifying the color information in the image. Each color gamut area represents a class of pixel areas with similar color characteristics in the image. In color gamut division, the colors in the image are divided into multiple different groups or clusters, each group or cluster corresponds to a color gamut area, which simplifies the color information of the image.

[0051] The image to be detected is converted from its original color space to a color space suitable for color gamut division. Color spaces include RGB (red, green, blue) and HSV (hue, saturation, brightness), where each color space can provide a different perspective to understand the color composition of the image. After conversion to the target color space that is conducive to separating color regions, each pixel of the image will have a corresponding color value. Then, by setting the standard or algorithm for color gamut division, the color range in the color space is divided into multiple regions. For example, this can be achieved by setting a threshold. In the HSV color space, the hue can be divided into several intervals, each interval corresponds to a color gamut region. Similarly, the color region can be divided according to saturation and brightness, thereby further refining the color classification. In the process of color gamut division, clustering algorithms (such as K-means clustering) can also be used to group the colors in the color space and automatically determine the boundaries of the color gamut region. The colors in the color space can also be divided into preset regions by manually defined color ranges. Each divided color gamut region contains all the colors in the image that fall within the color gamut region. Finally, each pixel of the image is marked with a color region to obtain the color gamut division results of the image. These results can be used for further image processing or analysis, such as color matching, image segmentation, etc.

[0052] Step S102, determining edge pixels and gradient magnitudes of edge pixels in each color gamut region, and marking edge pixels whose gradient magnitudes meet preset conditions as strong edge pixels of the color gamut region.

[0053] Edge pixels refer to pixels in an image where the color or brightness changes significantly. These pixels are usually located at the edge or contour of the image and are important information for identifying objects or structures. The gradient amplitude of edge pixels represents the strength or significance of the edge, which can be obtained by calculating the degree of change in the color or brightness value of each pixel in the image. Specifically, the image can be subjected to gradient operation to measure the amount of change in the pixel value in the horizontal and vertical directions. The gradient amplitude is a combination of these changes and reflects the edge strength of the pixel. A high gradient amplitude indicates a more significant edge. Strong edge pixels in a color gamut area refer to edge pixels whose gradient amplitude meets specific standards within a certain color gamut area. These strong edge pixels are important marking points on the boundary of the color gamut area and can highlight the outline of the color gamut area.

[0054] Determine the edge pixels and their gradient amplitudes in each color gamut area. Perform edge detection on the color gamut area to find all possible edge pixels. Use the edge detection algorithm to filter the image to obtain the gradient amplitude of each edge pixel. Compare the gradient amplitude with the preset conditions to determine which edge pixels meet the criteria. The preset condition can be a gradient amplitude threshold, which means that only when the gradient amplitude exceeds this threshold, the edge pixel is marked as a strong edge pixel. These thresholds can be determined experimentally or set based on the needs of a specific application. In addition, the preset condition can also be a marking standard. When the gradient amplitude reaches the set standard, the edge pixel is marked as a strong edge pixel. Finally, the edge pixels that meet the conditions are marked as strong edge pixels in the color gamut area. In this way, those pixels with important edge features can be highlighted in the color gamut area, and the contours and boundaries in the image can be better identified and analyzed.

[0055] Step S103: determining the edge of the image to be detected based on the strong edge pixels in each color gamut area.

[0056] Specifically, all pixels marked as strong edge pixels can be extracted from each color gamut region, and the coordinate information of these strong edge pixels can be combined with the corresponding color gamut region to form a comprehensive edge marking data. In order to determine the edge of the entire image to be detected, the strong edge pixel information in each color gamut region can be merged. By combining the coordinate information of the strong edge pixels in all color gamut regions, a complete edge contour can be drawn in the image. For example, the strong edge pixels of each color gamut region are marked on the image to form a complete edge map. The edge map shows the boundaries of all color gamut regions in the image, which is conducive to highlighting the boundaries between different regions. The marked edges can also be further optimized. For example, image smoothing technology can be used to remove noise in the edge map, or morphological operations (such as expansion and corrosion) can be used to improve the connectivity and continuity of the edge. These processes can make the final edge map more accurately reflect the real boundaries of each color gamut region in the image, thereby achieving efficient image edge recognition and analysis.

[0057] The embodiment of the present invention divides the image to be detected into color gamuts to obtain multiple color gamut areas; determines edge pixels in each color gamut area and the gradient amplitude of the edge pixels, and marks edge pixels whose gradient amplitudes meet preset conditions as strong edge pixels of the color gamut area; determines the edge of the image to be detected based on the strong edge pixels in each color gamut area; thereby effectively processing image noise, reducing detection complexity, and improving image processing efficiency.

[0058] Optionally, before dividing the color gamut of the image to be detected, the method further includes: determining the row coordinates and column coordinates of each pixel in the image to be detected; obtaining the optical three primary color values ​​of each pixel based on the row coordinates and column coordinates of each pixel; and constructing a pixel matrix according to the optical three primary color values ​​of each pixel to divide the color gamut of the image to be detected according to the pixel matrix.

[0059] The image to be detected can be parsed to determine the row and column coordinates of each pixel. These row and column coordinates identify the specific position of each pixel in the image and can be used together with the color information of the pixel to construct the pixel matrix of the image. Specifically, the original data of the image is first read, and the row and column coordinates of each pixel are determined by traversing each row and column of the image. Based on the row and column coordinates of each pixel, the optical three primary color values ​​of the pixel, that is, the values ​​of the red, green, and blue (RGB) components, are obtained from the image. These color values ​​can be obtained by reading the RGB data of the image. The RGB value of each pixel represents the specific information of its color and can accurately describe the color characteristics of each pixel in the image.

[0060] After obtaining the RGB value of each pixel, you can use these RGB values ​​to construct a pixel matrix. You can create an empty matrix that matches the size of the image, map the row and column coordinates of each pixel to the corresponding position in the matrix, and fill the position with the RGB value of the pixel, that is, convert the color data of the image into a structured matrix form. The pixel matrix is ​​a two-dimensional array, in which each element contains the RGB value of the corresponding pixel. Each position in the matrix corresponds to a pixel position in the image, and the content of the matrix reflects the overall color information of the image. This matrix, as a digital representation of the image, provides basic data for further processing, for example, using the constructed pixel matrix for color gamut division. The pixel matrix organizes the color information of each pixel in the image in the form of a two-dimensional array, making the data easier to process and analyze.

[0061] Optionally, the image to be detected is divided into color gamuts to obtain multiple color gamut regions, including: converting the optical three primary color values ​​of each pixel in the pixel matrix into feature vectors; and obtaining multiple color gamut regions using a clustering algorithm based on the feature vectors.

[0062] In the process of color gamut division of the image to be detected, the color value of the three primary colors of each pixel in the image can be converted into a feature vector. The three primary colors refer to red, green and blue (RGB). The intensity value of each pixel on these color channels jointly defines the color characteristics of the pixel. The RGB value of each pixel is used to form a three-dimensional feature vector, which represents each pixel in the image as a vector reflecting its color information. Based on these feature vectors, clustering algorithms are applied to divide the color gamut area. The clustering algorithm can group the feature vectors into several clusters, each of which corresponds to a color gamut area. Specifically, clustering algorithms include K-means clustering and hierarchical clustering, etc. These algorithms calculate the similarity or distance between feature vectors, classify similar color features into the same group, and thus determine the boundaries of the color gamut area. Through the clustering process, all pixels in the image will be assigned to different color gamut areas, each of which represents a main color or color feature. These color gamut areas make the color distribution of the image easier to understand and provide a basis for further image processing and analysis.

[0063] Optionally, determining edge pixels in each color gamut area includes: traversing pixels in each color gamut area, and in response to a difference in area value between a pixel and any of its neighboring pixels, determining the pixel as an edge pixel of the color gamut area; wherein the area value is the optical three primary color value of the centroid of the color gamut area.

[0064] Traverse all pixels in each color gamut area and compare them with their neighboring pixels. Each color gamut area has a centroid, and the optical three primary colors of the centroid represent the central color of the area. During the traversal process, for each pixel, check whether its color value is different from the area value of any of its neighboring pixels, where the neighboring pixels refer to the pixels within a certain range around the pixel, for example, 4 neighborhoods or 8 neighborhoods, etc., that is, the pixels above, below, left, right, or the pixels above, below, left, right, and diagonal. When comparing the color value of the pixel with the color value of the centroid, the color difference between them can be calculated. If the color value of a pixel is significantly different from the color value of any pixel in its neighborhood, and this difference is obvious compared with the color value of the centroid, then the pixel is determined as an edge pixel. The edges in the image can be effectively identified, the boundaries of the color gamut area can be accurately found, and the parts with significant color changes in the area can be highlighted, thereby enhancing the structural features of the image, providing clear boundary information, and thus improving the accuracy and reliability of image processing.

[0065] Optionally, marking edge pixels whose gradient amplitudes satisfy preset conditions as strong edge pixels of the color gamut area includes: comparing the grayscale value of each edge pixel with the grayscale value of each neighboring pixel of the edge pixel, and in response to the grayscale value of the edge pixel being greater than the grayscale value of each neighboring pixel of the edge pixel, marking the edge pixel as a strong edge pixel of the color gamut area.

[0066] In order to determine the strong edge pixels, the grayscale value comparison can be performed, and a detailed grayscale analysis can be performed on each edge pixel to determine whether it is significantly higher than the surrounding neighborhood pixels, so as to determine whether it has strong edge features. The grayscale value comparison is achieved by comparing the grayscale value of each edge pixel with the grayscale values ​​of all pixels in its neighborhood. Neighborhood pixels refer to pixels within a certain range around the edge pixel, such as four neighborhoods or eight neighborhoods, etc., that is, the four neighborhood pixels are the pixels above, below, left, and right, and the eight neighborhood pixels are the pixels above, below, left, right, and diagonal directions. For each edge pixel, calculate whether its grayscale value is greater than the grayscale values ​​of all neighboring pixels. If the grayscale value of an edge pixel is greater than the grayscale values ​​of all its neighboring pixels, then the edge pixel is marked as a strong edge pixel in the color gamut area. Through this method, the marked strong edge pixel is visually represented as the core part of the edge, effectively highlighting the important edge features in the image, improving the accuracy of edge detection, and thus improving the overall image processing effect.

[0067] In addition, a threshold of edge strength can be set. When the gradient amplitude or grayscale difference exceeds this threshold, the pixel is marked as a strong edge pixel. That is, pixels above the threshold are determined as strong edge pixels, indicating the most significant edge feature in the image.

[0068] Optionally, the edge of the image to be detected is determined based on the strong edge pixels of each color gamut area, including: adjusting the optical three primary color values ​​of the strong edge pixels of each color gamut area to a first color value, and adjusting the optical three primary color values ​​of other pixels except the strong edge pixels to a second color value; wherein the first color value and the second color value are different; constructing a new pixel matrix based on the adjusted pixels, and determining the edge of the image to be detected according to the new pixel matrix.

[0069] Special processing is performed on the strong edge pixels in each color gamut area, and the optical three primary color values ​​of these strong edge pixels are adjusted to a unified first color value, and the first color value is a color that is significantly different from the colors of other pixels to highlight the edge features. Similarly, the optical three primary color values ​​of other pixels except these strong edge pixels are adjusted to a second color value, and the second color value should be significantly different from the first color value so that edge pixels and non-edge pixels can be clearly distinguished. For example, the RGB values ​​of strong edge pixels in all regions are set to pure white, and other pixels are set to pure black by default. A new pixel matrix is ​​constructed based on the coordinates and RGB values ​​of the adjusted pixels, which contains different color identifiers of edge pixels and non-edge pixels. According to the new pixel matrix, the edge of the image to be detected is constructed. In this new pixel matrix, all pixels marked with the first color value will be displayed as edge areas, while pixels with the second color value represent non-edge areas. By observing these different color areas, the edges in the image to be detected can be effectively identified and determined. By resaving the image based on the coordinates and color gamut in the new pixel matrix, the edge contour of the image can be identified. By enhancing the visibility of edge pixels, the edge features in the image are made more prominent and obvious, thereby improving the efficiency and accuracy of image edge analysis and processing.

[0070] Figure 2 FIG. 1 is a schematic diagram of the main process of an image edge detection method according to a preferred embodiment of the present invention. Figure 2As shown, first obtain the image to be detected. The image data can be loaded into the computer by reading the image file (such as JPEG, PNG and other formats). The image data can be stored in the form of a pixel matrix, which contains the color information (RGB value) of each pixel. Next, clustering is performed to divide the color gamut of the image. By analyzing the color features of each pixel in the image, the pixels are assigned to different color groups. Specifically, the K-means clustering algorithm can be used to convert the color features (RGB values) in the image into feature vectors, and then the pixels are assigned to a preset number of clusters according to these feature vectors. Each cluster represents a color gamut area. The result of clustering is that the image is divided into several color gamut areas, each of which contains pixels with similar color features. After the color gamut division is completed, the strong edge pixels of the area are marked. Strong edge pixels are those pixels with significant changes in color or brightness. These changes indicate the boundaries or contours of the image. Through the edge detection algorithm, the gradient amplitude of each pixel can be calculated, and those pixels with gradient amplitudes higher than a certain threshold are marked as strong edge pixels. These marks can highlight the edge parts in the image and make subsequent processing clearer. Finally, the whole process is completed by extracting the edge contour of the image to be detected. Based on the marked strong edge pixels, the positions of these pixels in the image are combined to form a complete edge contour. For example, the coordinate information of the strong edge pixels is summarized and the edge lines are drawn on the image. The extracted edge contour can be used for various image analysis tasks, such as object recognition, shape analysis or feature extraction, etc.

[0071] The clustering algorithm of the embodiment of the present invention has low complexity and fast calculation speed. By dividing the image by clustering, it can not only eliminate noise, but also divide the image into several areas according to the color gamut. After using this method, the block area formed by clustering can also ensure the continuity of the edge, eliminating the step of edge repair. Since the image area has been divided according to the color gamut in the previous step, it is only necessary to scan each pixel, identify the edge of the area and mark the pixel points on the side with higher grayscale as strong edge pixels of the area. Marking all strong edge pixels completes the edge recognition of the image. After dividing the color gamut, it is only necessary to calculate the grayscale values ​​of several centroids, and the grayscale value calculation of each pixel is omitted, which greatly reduces the amount of calculation. This method is simple and efficient in calculation, has low complexity, and can solve the double-pixel boundary problem.

[0072] Figure 3 FIG. 1 is a schematic diagram of the main process of clustering and dividing the image color gamut according to a preferred embodiment of the present invention. Figure 3As shown in the figure, in the process of clustering image color gamut, the horizontal coordinate value, vertical coordinate value and optical primary color value of each pixel in the image to be detected are first extracted. These data provide the specific position and color information of each pixel in the image. The horizontal coordinate value and vertical coordinate value determine the position of the pixel in the image, while the optical primary color value (i.e., red, green and blue components) describes the color characteristics of each pixel. This information is collected and organized into a pixel data set. Next, the number of centroids is selected, which determines the number of color gamut regions to be created when segmenting the image. The number of centroids can be selected based on the complexity of the image and the processing target. After the number of centroids is selected, the optical primary color value of each pixel is used as the feature value, and a clustering algorithm (such as the K-means algorithm) is applied for processing to assign the color features of the pixel to different clusters, each cluster representing a color gamut region. The clustering algorithm iteratively assigns pixels to the cluster closest to the centroid, and updates the position of the centroid at the same time, and finally divides all pixels in the image into the regions where the centroid is located, and calculates the centroid value of each region. These centroid values ​​represent the new optical three primary color values ​​of each color gamut area, which are used to represent the main color tone of the area. After the color gamut division is completed, each pixel of the image is assigned to a specific color gamut area, and the color of each area of ​​the image is updated to the color of the corresponding centroid. In this way, the complex color information in the original image is simplified into several main color gamut areas, each area has a unified color representation. This processed image shows the effect after the color gamut division, and the color of each area is more consistent, which helps to better analyze and understand the color structure in the image.

[0073] Figure 4 FIG. 1 is a schematic diagram of the main process of marking strong edge pixels in a region according to a preferred embodiment of the present invention. Figure 4 As shown, the identification of regional strong edge pixels is done by traversing each pixel to judge and mark. For each pixel, the regional value and grayscale value of the pixel are taken. If the regional value is the same as the regional value of the four neighboring pixels (upper, lower, left, and right pixels), it is not an edge pixel, and the next pixel is skipped and traversed; if the regional value is different from the regional value of any of the four neighboring pixels (upper, lower, left, and right pixels), it is marked as an edge pixel. After being marked as an edge pixel, in order to avoid the problem of double edges in the regional edge contour, continue to judge whether the grayscale value of the edge pixel is the largest compared with the grayscale value of its four neighboring pixels. If so, the pixel is determined as a strong edge pixel and marked. If not, continue to traverse the next pixel. Traverse and identify all regional strong edge pixels, set the RGB value of the regional strong edge pixel to pure white, and set other pixels to pure black by default. According to the pixel coordinates and the marked RGB value, a new pixel matrix is ​​obtained. The new pixel matrix is ​​saved as an image again according to the pixel coordinates and color gamut, and the edge contour of the image can be identified.

[0074] According to a second aspect of an embodiment of the present invention, an image edge detection device is provided.

[0075] Figure 5 FIG. 1 is a schematic diagram of the main modules of the image edge detection device according to an embodiment of the present invention. Figure 5 As shown, an image edge detection device 500 is provided, comprising:

[0076] The color gamut division module 501 is used to divide the color gamut of the image to be detected into multiple color gamut areas;

[0077] A pixel marking module 502 is used to determine edge pixels and gradient magnitudes of edge pixels in each color gamut region, and mark edge pixels whose gradient magnitudes meet a preset condition as strong edge pixels of the color gamut region;

[0078] The edge determination module 503 is used to determine the edge of the image to be detected based on the strong edge pixels in each color gamut area.

[0079] Optionally, the detection device 500 further includes a matrix construction module, and the matrix construction module is used to:

[0080] Determine the row and column coordinates of each pixel in the image to be detected;

[0081] Obtaining the optical three primary color values ​​of each pixel based on the row coordinate and the column coordinate of each pixel;

[0082] A pixel matrix is ​​constructed according to the optical three primary color values ​​of each pixel, so as to divide the color gamut of the image to be detected according to the pixel matrix.

[0083] Optionally, the color gamut division module 501 is further used for:

[0084] Convert the optical three primary color values ​​of each pixel in the pixel matrix into a feature vector;

[0085] A clustering algorithm is used based on the feature vector to obtain multiple color gamut regions.

[0086] Optionally, the pixel marking module 502 is further configured to:

[0087] The pixels in each color gamut area are traversed, and in response to the area value of the pixel being different from that of any neighboring pixel of the pixel, the pixel is determined to be an edge pixel of the color gamut area; wherein the area value is the optical three primary color value of the centroid of the color gamut area.

[0088] Optionally, the pixel marking module 502 is further configured to:

[0089] The grayscale value of each edge pixel is compared with the grayscale value of each neighboring pixel of the edge pixel, and in response to the grayscale value of the edge pixel being greater than the grayscale value of each neighboring pixel of the edge pixel, the edge pixel is marked as a strong edge pixel of the color gamut region.

[0090] Optionally, the edge determination module 503 is further configured to:

[0091] Adjusting the optical three primary color values ​​of the strong edge pixels in each color gamut area to a first color value, and adjusting the optical three primary color values ​​of other pixels except the strong edge pixels to a second color value; wherein the first color value and the second color value are different;

[0092] A new pixel matrix is ​​constructed based on the adjusted pixels, and the edge of the image to be detected is determined according to the new pixel matrix.

[0093] It should be noted that the specific implementation content of the image edge detection device of the present invention has been described in detail in the above image edge detection method, so the repeated content will not be described again here.

[0094] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, including:

[0095] one or more processors;

[0096] a storage device for storing one or more programs,

[0097] When one or more programs are executed by one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.

[0098] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.

[0099] According to a fifth aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.

[0100] Figure 6 An exemplary system architecture 600 to which the image edge detection method or image edge detection apparatus according to the embodiment of the present invention can be applied is shown.

[0101] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0102] The user can use the terminal devices 601, 602, 603 to interact with the server 605 through the network 604 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 601, 602, 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).

[0103] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0104] The server 605 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 601, 602, and 603. The backend management server may analyze and process the received image edge detection request and other data, and feed back the processing result (such as the image edge detection result - only an example) to the terminal device.

[0105] It should be noted that the image edge detection method provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the image edge detection device is generally disposed in the server 605 .

[0106] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0107] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0108] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can execute various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0109] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 runs a communication process via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.

[0110] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for running the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.

[0111] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0112] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually run basically in parallel, and they can sometimes run in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that runs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0113] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a color gamut division module, a pixel marking module and an edge determination module. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the color gamut division module may also be described as "a module for dividing the color gamut of the image to be detected to obtain multiple color gamut areas".

[0114] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: dividing the image to be detected into color gamuts to obtain multiple color gamut areas; determining edge pixels and gradient amplitudes of edge pixels in each color gamut area, marking edge pixels whose gradient amplitudes meet preset conditions as strong edge pixels of the color gamut area; and determining the edge of the image to be detected based on the strong edge pixels of each color gamut area.

[0115] The computer program product provided by the embodiment of the present invention includes a computer program. When the computer program is executed by a processor, the image edge detection method in the embodiment of the present invention is implemented.

[0116] The technical solution according to the embodiment of the present invention has the following advantages or beneficial effects: by dividing the image to be detected into color gamuts, a plurality of color gamut areas are obtained; the edge pixels and the gradient amplitude of the edge pixels in each color gamut area are determined, and the edge pixels whose gradient amplitudes meet preset conditions are marked as strong edge pixels of the color gamut area; the edge of the image to be detected is determined based on the strong edge pixels in each color gamut area; thereby, image noise can be effectively processed, detection complexity is reduced, and image processing efficiency is improved.

[0117] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

[0118] It should be noted that the acquisition, storage and application of user personal information involved in the technical solution of the present disclosure are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

Claims

1. A method for detecting an image edge, characterized in that: include: Divide the image to be detected into color gamut to obtain multiple color gamut areas; Determine edge pixels and gradient magnitudes of edge pixels in each of the color gamut regions, and mark edge pixels whose gradient magnitudes meet preset conditions as strong edge pixels of the color gamut region; The edge of the image to be detected is determined based on the strong edge pixels of each color gamut area.

2. The method according to claim 1, characterized in that: Before dividing the color gamut of the image to be detected, the following steps are also included: Determine the row coordinates and column coordinates of each pixel in the image to be detected; Acquire the optical three primary color values ​​of each pixel based on the row coordinates and column coordinates of each pixel; A pixel matrix is ​​constructed according to the color values ​​of the three optical primary colors of each pixel, so as to perform color gamut division on the image to be detected according to the pixel matrix.

3. The method according to claim 2, characterized in that The image to be detected is divided into color gamuts to obtain multiple color gamut regions, including: Converting the optical three primary color values ​​of each pixel in the pixel matrix into a feature vector; A plurality of color gamut regions are obtained by using a clustering algorithm based on the feature vector.

4. The method according to claim 1, characterized in that: Determining edge pixels in each of the color gamut regions comprises: The pixels in each color gamut area are traversed, and in response to the area value of the pixel being different from that of any neighboring pixel of the pixel, the pixel is determined to be an edge pixel of the color gamut area; wherein the area value is the optical three primary color value of the centroid of the color gamut area.

5. The method according to claim 1, characterized in that The edge pixels whose gradient magnitude meets the preset conditions are marked as strong edge pixels in the color gamut area, including: The grayscale value of each edge pixel is compared with the grayscale value of each neighboring pixel of the edge pixel, and in response to the grayscale value of the edge pixel being greater than the grayscale value of each neighboring pixel of the edge pixel, the edge pixel is marked as a strong edge pixel of the color gamut area.

6. The method according to claim 1, characterized in that Determining the edge of the image to be detected based on the strong edge pixels of each color gamut area includes: Adjusting the optical three primary color values ​​of the strong edge pixels of each of the color gamut regions to a first color value, and adjusting the optical three primary color values ​​of other pixels except the strong edge pixels to a second color value; wherein the first color value and the second color value are different; A new pixel matrix is ​​constructed based on the adjusted pixels, and the edge of the image to be detected is determined according to the new pixel matrix.

7. An image edge detection device, characterized in that: include: A color gamut division module is used to divide the color gamut of the image to be detected into multiple color gamut areas; A pixel marking module, used to determine edge pixels and gradient amplitudes of edge pixels in each color gamut area, and mark edge pixels whose gradient amplitudes meet preset conditions as strong edge pixels of the color gamut area; The edge determination module is used to determine the edge of the image to be detected based on the strong edge pixels in each color gamut area.

8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Hemolysis recognition method and device, electronic equipment and storage medium

    CN120976524A