Image processing method, terminal equipment and computer readable storage medium
By using pixel distance and relative angles to perform redundant processing in image processing, the problem of image edge jagging is solved, and a smoother edge processing effect and a clearer image is achieved.
Patent Information
- Application Number
- CN202411955591.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-11
AI Technical Summary
During image processing, jagged often occurs at the edge of the image, affecting the visual effect and the accuracy of subsequent tasks.
By acquiring the edge pixel points of the image to be processed, de-redundant processing is performed according to the pixel distance and relative angle, the target point set is obtained, and the image edges are smoothed.
It effectively reduces the jagging phenomenon at the edges of the image, improves the smoothing effect of the edges, while maintaining the sharpness and details of the image.
Smart Images

Figure CN119810131A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing technology, and in particular, relates to an image processing method, a terminal device, and a computer-readable storage medium. Background Art
[0002] In the process of image processing, jagged edges often appear. For example, when an image is enlarged or rotated, the original pixel information may be deviated or distorted during the resampling process, causing the edge of the image to appear jagged.
[0003] The aliasing phenomenon not only affects the visual effect of the image, but may also affect the accuracy of subsequent tasks such as object detection or image segmentation. Therefore, solving the aliasing phenomenon on the edge of the image is a key issue in image processing. Summary of the invention
[0004] The embodiments of the present application provide an image processing method, a terminal device, and a computer-readable storage medium, which can improve the smoothing effect of image edges.
[0005] In a first aspect, an embodiment of the present application provides an image processing method, comprising:
[0006] Obtain edge pixel points of the image to be processed to obtain a first point set;
[0007] According to the pixel distance and relative angle between every two pixels in the first point set, performing redundancy removal processing on the first point set to obtain a target point set;
[0008] The edge of the image to be processed is smoothed according to the target point set.
[0009] In the embodiment of the present application, the edge pixels are de-redundanted according to the pixel distance and relative angle between the edge pixels of the image to be processed, so that the processed edge pixels form a smooth edge curve. In this method, not only the pixel distance but also the relative angle is considered, so that the edge of the processed image becomes smooth while reducing the loss of details and maintaining the clarity of the image.
[0010] In a possible implementation manner of the first aspect, performing redundancy removal processing on the first point set according to a pixel distance and a relative angle between every two pixel points in the first point set to obtain a target point set includes:
[0011] Performing convex hull detection according to the first point set;
[0012] If the result of the convex hull detection indicates that the first point set does not conform to the convex hull, determining the first point set as the target point set;
[0013] If the result of the convex hull detection indicates that the first point set conforms to the convex hull, de-redundancy processing is performed on the first point set according to the pixel distance and relative angle between every two pixel points in the first point set to obtain a target point set.
[0014] In the embodiment of the present application, it is equivalent to performing redundancy removal processing on the edge pixels when the edge pixels conform to the convex hull. This helps the algorithm to better understand the edge shape of the image to be processed and is beneficial to improving the edge smoothing processing effect.
[0015] In a possible implementation manner of the first aspect, performing redundancy removal processing on the first point set according to a pixel distance and a relative angle between every two pixel points in the first point set to obtain a target point set includes:
[0016] Acquire a first group of pixel points from the first point set according to the order of the pixel distances from small to large;
[0017] Calculating a relative angle between two pixels in the first group of pixels;
[0018] If the relative angle between two pixels in the first group of pixels is less than a preset threshold, deleting any pixel in the first group of pixels to obtain a remaining second point set;
[0019] Continue to perform redundancy removal processing according to the second point set until the target point set is obtained.
[0020] In one implementation, a group of pixels can be randomly obtained from the first point set. However, due to the randomness of this method, it may take multiple traversals to perform the deletion operation, which increases the amount of calculation and the time for de-redundancy. In the embodiment of the present application, the pixels are obtained from the first point set in the order of pixel distance from small to large, which helps to reduce the number of traversals, thereby reducing the amount of calculation and the time for de-redundancy.
[0021] In a possible implementation manner of the first aspect, continuing to perform redundancy removal processing according to the second point set until the target point set is obtained includes:
[0022] Performing convex hull detection according to the second point set;
[0023] If the result of the convex hull detection indicates that the second point set does not conform to the convex hull, determining the second point set as the target point set;
[0024] If the result of the convex hull detection indicates that the second point set conforms to the convex hull, de-redundancy processing is performed on the second point set according to the pixel distance and relative angle between every two pixels in the second point set until the target point set is obtained.
[0025] In the embodiment of the present application, after each deletion is executed, the convex hull detection is re-performed, which helps the algorithm to remove redundancy while understanding the edge shape of the image to be processed, which is beneficial to improving the edge smoothing processing effect.
[0026] In a possible implementation manner of the first aspect, after calculating the relative angle between two pixel points in the first group of pixel points, the method further includes:
[0027] If the relative angle between two pixels in the first group of pixels is greater than or equal to a preset threshold, the next group of pixels is obtained from the first point set in ascending order of the pixel distance until the target point set is obtained.
[0028] In a possible implementation manner of the first aspect, continuing to acquire a next group of pixel points from the first point set in ascending order of the pixel distances until the target point set is obtained includes:
[0029] If the relative angle between every two pixel points in the first point set is greater than or equal to a preset threshold, the first point set is determined as the target point set.
[0030] In a possible implementation manner of the first aspect, the deleting any one pixel point in the first group of pixel points to obtain a remaining second point set includes:
[0031] Determine an inlier point from two pixel points of the first group of pixel points; wherein a distance between the inlier point and a center point of the image to be processed is smaller than a distance between a non-inlier point and the center point of the image to be processed;
[0032] The inner points in the first group of pixel points are deleted to obtain the remaining second point set.
[0033] Through the above method, it is equivalent to considering two pixel points that are close to each other and have a small relative angle as duplicate points, and deleting the redundant points close to the center point of the image to be processed. This can retain more edge details while achieving smooth edge processing.
[0034] In a possible implementation manner of the first aspect, calculating the relative angle between two pixel points in the first group of pixel points includes:
[0035] Obtaining a first vector for connecting two pixel points in the first group of pixel points;
[0036] The angle between the first vector and the coordinate axis of the image to be processed is calculated to obtain a relative angle between two pixel points in the first group of pixel points.
[0037] In a second aspect, an embodiment of the present application provides an image processing device, including:
[0038] The acquisition unit is used to acquire edge pixel points of the image to be processed to obtain a first point set.
[0039] The redundancy removal unit is used to perform redundancy removal processing on the first point set according to the pixel distance and relative angle between every two pixel points in the first point set to obtain a target point set.
[0040] A processing unit is used to smooth the edge of the image to be processed according to the target point set.
[0041] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, an image processing method as described in any one of the first aspects above is implemented.
[0042] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image processing method as described in any one of the first aspects above is implemented.
[0043] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the image processing method described in any one of the above-mentioned first aspects.
[0044] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0046] Figure 1 is a schematic diagram of a jagged edge provided in an embodiment of the present application;
[0047] Figure 2 is a flowchart of an image processing method provided in an embodiment of the present application;
[0048] Figure 3 is a schematic diagram of a binary image provided in an embodiment of the present application;
[0049] Figure 4 It is a flowchart of redundancy removal processing provided by an embodiment of the present application;
[0050] Figure 5 is a structural block diagram of an image processing device provided in an embodiment of the present application;
[0051] Figure 6 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0053] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0054] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0055] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0056] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0057] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.
[0058] In the process of image processing, jagged edges often appear. For example, when an image is enlarged or rotated, the original pixel information may be deviated or distorted during the resampling process, causing the edge of the image to appear jagged.
[0059] For example, in an application scenario, a local area in an image may be pasted into another image. During the pasting process, the local area to be pasted may be randomly enlarged or reduced by interpolation. Assuming that the position (x0, y0) in the local area is to be interpolated, first find the four vertices of the smallest rectangle containing (x0, y0), which are (x1, y1), (x2, y1), (x1, y2), and (x2, y2). Linearly interpolate the two points (x1, y1) and (x2, y1) with the constant y1 to obtain Perform linear interpolation on the two points (x1, y1) and (x2, y2) with constant x1, and we get Finally, perform linear difference on f1 and f2 to get the estimated value of f(x0,y0)
[0060] When a low-resolution local image is enlarged to a high-resolution image, jagged edges of the image may appear.
[0061] Jagged edges usually appear as a smooth straight line that becomes a staircase of stepped pixels. For example, see Figure 1 , is a schematic diagram of a jagged edge provided in an embodiment of the present application. Figure 1 As shown, the portion pointed by the arrow is a partial edge of the image, which appears jagged.
[0062] The aliasing phenomenon not only affects the visual effect of the image, but may also affect the accuracy of subsequent tasks such as object detection or image segmentation. Therefore, solving the aliasing phenomenon on the edge of the image is a key issue in image processing.
[0063] Based on this, an embodiment of the present application provides an image processing method. In the embodiment of the present application, according to the pixel distance and relative angle between the edge pixels of the image to be processed, the edge pixels are de-redundantly processed so that the processed edge pixels form a smooth edge curve. In this method, not only the pixel distance but also the relative angle is considered, so that the edge of the processed image becomes smooth while reducing the loss of details and maintaining the clarity of the image.
[0064] See also Figure 2 , is a flowchart of an image processing method provided in an embodiment of the present application. As an example but not a limitation, the method may include the following steps:
[0065] S201, acquiring edge pixel points of the image to be processed to obtain a first point set.
[0066] In some implementations, edge detection may be performed on the image to be processed to obtain the first point set. In the embodiment of the present application, the edge detection method is not specifically limited.
[0067] The first point set may include the position (such as pixel coordinates) of each edge pixel point.
[0068] In some implementations, in order to more accurately extract the image contour, the image to be processed may be first binarized to obtain a binary image, and then edge detection may be performed on the binary image to obtain a first point set.
[0069] For example, see Figure 3 , is a schematic diagram of a binary image provided in an embodiment of the present application. Figure 3 As shown, the white area represents the part of the image to be processed, and the black area represents the outside of the image to be processed.
[0070] It is understandable that in a binary image, edge pixels have the same color or intensity, such as Figure 3 The colors shown include white and black. For example, the process of edge detection may be: traversing the pixels in the binary image; for any pixel in the binary image, if the adjacent pixels of the pixel are of different colors, the pixel is determined as an edge pixel.
[0071] S202, performing redundancy removal processing on the first point set according to the pixel distance and relative angle between every two pixel points in the first point set to obtain a target point set.
[0072] In one embodiment, S202 may include:
[0073] Perform convex hull detection based on the first point set;
[0074] If the result of the convex hull detection indicates that the first point set does not conform to the convex hull, the first point set is determined as the target point set;
[0075] If the result of the convex hull detection indicates that the first point set conforms to the convex hull, the first point set is de-redundantly processed according to the pixel distance and relative angle between every two pixels in the first point set to obtain the target point set.
[0076] In a real vector space V, for a given set X, the intersection S of all convex sets containing X is called the convex hull of X. The convex hull of X can be constructed using the convex combination of all points (X1,...Xn) in X.
[0077] For example, the convex hull detection can use the Graham algorithm, whose idea is: first find the point with the smallest ordinate as the starting point, then calculate the vectors of other points and the starting point, and sort the point set according to the angle and modulus of the vector; then, starting from the first sorted point, connect the points in counterclockwise order to form a convex hull.
[0078] For another example, the convex hull detection can use the Andrew algorithm, whose idea is: first find the point with the smallest ordinate as the starting point, then sort according to the abscissa. Then, use the scanning line method to gradually construct the convex hull.
[0079] It should be noted that in practical applications, other convex hull detection algorithms may be used, and the convex hull detection algorithm is not specifically limited in the embodiments of the present application.
[0080] In the embodiment of the present application, it is equivalent to performing redundancy removal processing on the edge pixels when the edge pixels conform to the convex hull. This helps the algorithm to better understand the edge shape of the image to be processed and is beneficial to improving the edge smoothing processing effect.
[0081] In one embodiment, S202 may include:
[0082] S301, acquiring a first group of pixel points from a first point set according to the order of pixel distance from small to large.
[0083] In one implementation of calculating the pixel distance between every two pixels in the first point set, the calculation can be performed according to the following formula:
[0084]
[0085] Among them, (ix, iy) is the coordinate of the i-th pixel, (jx, jy) is the coordinate of the j-th pixel, and diff (i,j) is the pixel distance between the i-th pixel and the j-th pixel.
[0086] In one implementation, a group of pixels can be randomly obtained from the first point set. However, due to the randomness of this method, it may take multiple traversals to perform the deletion operation, which increases the amount of calculation and the time for de-redundancy. In the embodiment of the present application, the pixels are obtained from the first point set in the order of pixel distance from small to large, which helps to reduce the number of traversals, thereby reducing the amount of calculation and the time for de-redundancy.
[0087] For example, the first point set includes three pixel points a, b, and c. By calculating the pixel distance between every two pixel points, three pixel distances can be calculated. Assuming that the pixel distance between pixel points a and b is the smallest, the first group of pixel points obtained from the first point set is a and b.
[0088] It should be noted that the number of pixels in the above example is only for illustration. The embodiment of the present application does not specifically limit the number of pixels included in the first point set, and the number of pixels included in the first point set of different images to be processed is different.
[0089] S302: Calculate the relative angle between two pixel points in the first group of pixel points.
[0090] In one implementation, a first vector for connecting two pixel points in the first group of pixel points is obtained; and an angle between the first vector and a coordinate axis of the image to be processed is calculated to obtain a relative angle between the two pixel points in the first group of pixel points.
[0091] Optionally, the angle between the first vector and the horizontal axis of the image to be processed may be calculated, or the angle between the first vector and the vertical axis of the image to be processed may be calculated. However, it should be noted that in the same de-redundancy process, the coordinate axes involved in the calculation are the same.
[0092] Exemplarily, the relative angle can be calculated according to the following formula:
[0093]
[0094] Among them, θ ij is the relative angle between the i-th pixel and the j-th pixel. cos -1 () is the arccosine function.
[0095] S303, if the relative angle between two pixels in the first group of pixels is less than a preset threshold, delete any pixel in the first group of pixels to obtain the remaining second point set; continue to perform redundancy removal processing according to the second point set until the target point set is obtained.
[0096] Through the method described in S301-S303, one of the two pixels that are close to each other and have a small relative angle can be deleted, and while removing redundancy, the image edge details are retained, which is conducive to improving the smoothing effect of the image edge.
[0097] In one implementation, an inlier point is determined from two pixel points in the first set of pixel points, and the inlier point in the first set of pixel points is deleted to obtain a remaining second point set, wherein the distance between the inlier point and the center point of the image to be processed is smaller than the distance between the non-inlier point and the center point of the image to be processed.
[0098] For example, the first group of pixel points includes pixel points a and b. If the distance between point a and the center point of the image to be processed is less than the distance between point b and the center point of the image to be processed, then point a is an inner point in the first group of pixel points, point a in the first point set is deleted, and point b is retained.
[0099] Through the above method, it is equivalent to considering two pixel points that are close to each other and have a small relative angle as duplicate points, and deleting the redundant points close to the center point of the image to be processed. This can retain more edge details while achieving smooth edge processing.
[0100] S304, if the relative angle between two pixels in the first set of pixels is greater than or equal to a preset threshold, then continue to obtain the next set of pixels from the first point set in ascending order of pixel distance until the target point set is obtained.
[0101] In one case, the redundancy removal process is continued according to the second point set, and so on, until there are no pixels that can be deleted, and the remaining pixels are determined as the target point set.
[0102] In another case, if the relative angle between every two pixel points in the first point set is greater than or equal to a preset threshold, the first point set is determined as the target point set.
[0103] For example, the first point set includes three pixel points a, b, and c. By calculating the pixel distance between every two pixel points, three pixel distances can be calculated. Assume that the pixel distances are in ascending order: the pixel distance between pixel points a and b, the pixel distance between pixel points b and c, and the pixel distance between pixel points a and c. The first group of pixel points obtained from the first point set are a and b.
[0104] If the relative angle between point a and point b is greater than or equal to the preset threshold, indicating that point a and point b are not duplicate points, the second group of pixel points b and c are obtained, and the relative angle between point b and point c is calculated; if the relative angle between point b and point c is less than the preset threshold, the inner points in point b and point c are deleted to obtain the remaining third point set; and redundancy removal is performed based on the third point set.
[0105] If the relative angle between point b and point c is greater than or equal to the preset threshold, continue to obtain the third set of pixel points a and c, and calculate the relative angle between point a and point c; if the relative angle between point a and point c is less than the preset threshold, delete the inner points in point a and point c to obtain the remaining fourth point set. At this point, the traversal is completed, and the fourth point set is recorded as the target point set.
[0106] If the relative angle between point a and point c is greater than or equal to the preset threshold, the traversal is completed, and the relative angle between every two pixel points in the first point set is greater than or equal to the preset threshold, then the first point set is determined as the target point set.
[0107] In one implementation, the process of performing redundancy removal according to the second point set in S304 may include:
[0108] Perform convex hull detection based on the second point set;
[0109] If the result of the convex hull detection indicates that the second point set does not conform to the convex hull, the second point set is determined as the target point set;
[0110] If the result of the convex hull detection indicates that the second point set conforms to the convex hull, redundancy removal is performed on the second point set according to the pixel distance and relative angle between every two pixels in the second point set until the target point set is obtained.
[0111] In the embodiment of the present application, after each deletion is executed, the convex hull detection is re-performed, which helps the algorithm to remove redundancy while understanding the edge shape of the image to be processed, which is beneficial to improving the edge smoothing processing effect.
[0112] S203, smoothing the edge of the image to be processed according to the target point set.
[0113] In this step, each pixel point in the target point set can be connected in sequence to form a smooth curve, that is, the edge line of the image to be processed is obtained.
[0114] It is understandable that in actual applications, S201-S203 may be performed multiple times to achieve a better edge smoothing effect. In each execution of S201-S203, different thresholds of relative angles may be used to achieve different smoothing effects.
[0115] For example, see Figure 4 , is a flowchart of the redundancy removal process provided by the embodiment of the present application. As an example and not a limitation, Figure 4 As shown, the redundancy removal process may include the following steps:
[0116] S401, detecting edge pixels of an image to be processed.
[0117] S402, calculating the pixel distance between every two edge pixels.
[0118] S403, detecting whether the edge pixel point has a convex hull.
[0119] If it is a convex hull, execute S404; if it is not a convex hull, end and record the current edge pixel point as the target point set.
[0120] For steps S401-S403, reference may be made to the description of steps S201-S202 in the embodiment, which will not be repeated here.
[0121] S404: If the edge pixel point is a convex hull, determine whether the relative angle between two pixel points in the first group of pixel points is less than a preset threshold.
[0122] If it is less than the preset threshold, execute S405; if it is not less than the preset threshold, execute S406.
[0123] S405: If the value is less than the preset threshold, the interior points in the first group of pixels are deleted, and then redundancy removal is continued according to the remaining edge pixels.
[0124] S406, if it is not less than the preset threshold, continue to determine whether the relative angle between two pixels in the next group of pixels is less than the preset threshold, and so on, until the target point set is obtained, and then end.
[0125] For steps S404-S406, reference may be made to the description of steps S301-S303 in the embodiment, which will not be repeated here.
[0126] In the embodiment of the present application, the edge pixels are de-redundanted according to the pixel distance and relative angle between the edge pixels of the image to be processed, so that the processed edge pixels form a smooth edge curve. In this method, not only the pixel distance but also the relative angle is considered, so that the edge of the processed image becomes smooth while reducing the loss of details and maintaining the clarity of the image.
[0127] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0128] Corresponding to the image processing method described in the above embodiment, Figure 5 This is a structural block diagram of the image processing device provided in an embodiment of the present application. For the sake of convenience of explanation, only the parts related to the embodiment of the present application are shown.
[0129] Reference Figure 5 , the device 5 comprises:
[0130] The acquisition unit 51 is used to acquire edge pixel points of the image to be processed to obtain a first point set.
[0131] The redundancy removal unit 52 is used to perform redundancy removal processing on the first point set according to the pixel distance and relative angle between every two pixel points in the first point set to obtain a target point set.
[0132] The processing unit 53 is used to smooth the edge of the image to be processed according to the target point set.
[0133] Optionally, the redundancy removal unit 52 is further configured to:
[0134] Performing convex hull detection according to the first point set;
[0135] If the result of the convex hull detection indicates that the first point set does not conform to the convex hull, determining the first point set as the target point set;
[0136] If the result of the convex hull detection indicates that the first point set conforms to the convex hull, de-redundancy processing is performed on the first point set according to the pixel distance and relative angle between every two pixel points in the first point set to obtain a target point set.
[0137] Optionally, the redundancy removal unit 52 is further configured to:
[0138] Acquire a first group of pixel points from the first point set according to the order of the pixel distances from small to large;
[0139] Calculating a relative angle between two pixels in the first group of pixels;
[0140] If the relative angle between two pixels in the first group of pixels is less than a preset threshold, deleting any pixel in the first group of pixels to obtain a remaining second point set;
[0141] Continue to perform redundancy removal processing according to the second point set until the target point set is obtained.
[0142] Optionally, the redundancy removal unit 52 is further configured to:
[0143] Performing convex hull detection according to the second point set;
[0144] If the result of the convex hull detection indicates that the second point set does not conform to the convex hull, determining the second point set as the target point set;
[0145] If the result of the convex hull detection indicates that the second point set conforms to the convex hull, de-redundancy processing is performed on the second point set according to the pixel distance and relative angle between every two pixels in the second point set until the target point set is obtained.
[0146] Optionally, the redundancy removal unit 52 is further configured to:
[0147] If the relative angle between two pixels in the first group of pixels is greater than or equal to a preset threshold, the next group of pixels is obtained from the first point set in ascending order of the pixel distance until the target point set is obtained.
[0148] Optionally, the redundancy removal unit 52 is further configured to:
[0149] If the relative angle between every two pixel points in the first point set is greater than or equal to a preset threshold, the first point set is determined as the target point set.
[0150] Optionally, the redundancy removal unit 52 is further configured to:
[0151] Determine an inlier point from two pixel points of the first group of pixel points; wherein a distance between the inlier point and a center point of the image to be processed is smaller than a distance between a non-inlier point and the center point of the image to be processed;
[0152] The inner points in the first group of pixel points are deleted to obtain the remaining second point set.
[0153] Optionally, the redundancy removal unit 52 is further configured to:
[0154] Obtaining a first vector for connecting two pixel points in the first group of pixel points;
[0155] The angle between the first vector and the coordinate axis of the image to be processed is calculated to obtain a relative angle between two pixel points in the first group of pixel points.
[0156] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0157] in addition, Figure 5 The image processing device shown may be a software unit, a hardware unit, or a combination of software and hardware, which is built into an existing terminal device, or may be integrated into the terminal device as an independent accessory, or may exist as an independent terminal device.
[0158] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0159] Figure 6 Schematic diagram of the structure of the terminal device provided in the embodiment of the present application. Figure 6 As shown, the terminal device 6 of this embodiment includes: at least one processor 60 ( Figure 6 Only one is shown in the figure) a processor, a memory 61, and a computer program 62 stored in the memory 61 and executable on the at least one processor 60, wherein the processor 60 implements the steps in any of the above-mentioned image processing method embodiments when executing the computer program 62.
[0160] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 6 It is only an example of the terminal device 6 and does not constitute a limitation on the terminal device 6. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0161] The processor 60 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0162] In some embodiments, the memory 61 may be an internal storage unit of the terminal device 6, such as a hard disk or memory of the terminal device 6. In other embodiments, the memory 61 may also be an external storage device of the terminal device 6, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 6. Further, the memory 61 may also include both an internal storage unit and an external storage device of the terminal device 6. The memory 61 is used to store an operating system, an application program, a boot loader, data, and other programs, such as the program code of the computer program. The memory 61 may also be used to temporarily store data that has been output or is to be output.
[0163] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0164] An embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0165] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the device / terminal device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0166] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0167] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0168] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0169] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0170] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An image processing method, characterized in that: include: Obtain edge pixel points of the image to be processed to obtain a first point set; According to the pixel distance and relative angle between every two pixels in the first point set, performing redundancy removal processing on the first point set to obtain a target point set; The edge of the image to be processed is smoothed according to the target point set.
2. The image processing method according to claim 1, characterized in that: The performing redundancy removal processing on the first point set according to the pixel distance and the relative angle between every two pixel points in the first point set to obtain the target point set includes: Perform convex hull detection according to the first point set; If the result of the convex hull detection indicates that the first point set does not conform to the convex hull, determining the first point set as the target point set; If the result of the convex hull detection indicates that the first point set conforms to the convex hull, de-redundancy processing is performed on the first point set according to the pixel distance and relative angle between every two pixel points in the first point set to obtain a target point set.
3. The image processing method according to claim 1 or 2, characterized in that: The performing redundancy removal processing on the first point set according to the pixel distance and the relative angle between every two pixel points in the first point set to obtain the target point set includes: Acquire a first group of pixel points from the first point set according to the order of the pixel distances from small to large; Calculating a relative angle between two pixels in the first group of pixels; If the relative angle between two pixels in the first group of pixels is less than a preset threshold, deleting any pixel in the first group of pixels to obtain a remaining second point set; Continue to perform redundancy removal processing according to the second point set until the target point set is obtained.
4. The image processing method according to claim 3, characterized in that: The step of continuing to perform redundancy removal processing according to the second point set until the target point set is obtained includes: Perform convex hull detection according to the second point set; If the result of the convex hull detection indicates that the second point set does not conform to the convex hull, determining the second point set as the target point set; If the result of the convex hull detection indicates that the second point set conforms to the convex hull, de-redundancy processing is performed on the second point set according to the pixel distance and relative angle between every two pixels in the second point set until the target point set is obtained.
5. The image processing method according to claim 3, characterized in that: After calculating the relative angle between two pixels in the first group of pixels, the method further includes: If the relative angle between two pixels in the first group of pixels is greater than or equal to a preset threshold, the next group of pixels is obtained from the first point set in ascending order of the pixel distance until the target point set is obtained.
6. The image processing method according to claim 5, characterized in that: The step of continuing to obtain a next group of pixel points from the first point set according to the order of the pixel distances from small to large until the target point set is obtained includes: If the relative angle between every two pixel points in the first point set is greater than or equal to a preset threshold, the first point set is determined as the target point set.
7. The image processing method according to claim 3, characterized in that: The deleting any one pixel point in the first group of pixel points to obtain the remaining second point set includes: Determine an inlier point from two pixel points of the first group of pixel points; wherein a distance between the inlier point and a center point of the image to be processed is smaller than a distance between a non-inlier point and the center point of the image to be processed; The inner points in the first group of pixel points are deleted to obtain the remaining second point set.
8. The image processing method according to any one of claims 3 to 7, characterized in that: The calculating the relative angle between two pixel points in the first group of pixel points includes: Obtaining a first vector for connecting two pixel points in the first group of pixel points; The angle between the first vector and the coordinate axis of the image to be processed is calculated to obtain a relative angle between two pixel points in the first group of pixel points.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
10. A computer-readable storage medium storing 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 8 is implemented.