Image edge fitting method, electronic device and storage medium

By setting the region of interest and filtering fitting points in the image, the problem of low accuracy and efficiency of image edge fitting in the prior art is solved, and a more efficient edge fitting effect is achieved.

CN116894958BActive Publication Date: 2025-01-14深圳市维谱科技有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310857214.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-12
Publication Date
2025-01-14
Estimated Expiration
2043-07-12

AI Technical Summary

Technical Problem

The prior art has poor accuracy and low efficiency when fitting linear structures in images, requiring a large amount of data processing, resulting in low fitting efficiency.

Method used

By setting multiple areas of interest in the target image, filter out edge points and fit points, use user-set line segments to generate areas of interest, reduce search range, and filter out fit points through contrast and distance, improving edge fitting efficiency and quality.

Benefits of technology

It improves the accuracy and efficiency of image edge fitting, reduces the processing requirements for data, and enhances the reliability and efficiency of edge fitting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116894958B_ABST
    Figure CN116894958B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image processing, and provides an image edge fitting method, an electronic device and a storage medium. A user sets a line segment close to an edge of an object in an image to determine an image edge processing area, and generates an area of ​​interest according to the line segment set by the user, thereby eliminating interference from unnecessary areas; by filtering out edge points in the area of ​​interest, the search range for finding edge points can be effectively reduced, thereby improving the efficiency of edge fitting; by re-filtering the edge points to obtain fitting points, the influence of interference points is further eliminated, so that the edge fitting algorithm only needs to process meaningful data, thereby further improving the efficiency and quality of edge fitting, and finally by edge fitting the fitting points, a line segment for characterizing the edge of the object in the target image is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image edge fitting method, electronic equipment and storage medium. Background Art

[0002] In computer vision image processing, the straight line fitting technique is often used to process linear structures that often appear in images (such as image edges, straight lines, object contours, etc.). Compared with the curve fitting technique, the straight line fitting technique can approximate the linear structures in the image with straight line segments, thereby realizing the abstraction and representation of these structures for image analysis, recognition and processing.

[0003] Existing straight line fitting technologies, such as those based on least squares method, broken line fitting, curve fitting, least squares cubic spline method, and machine learning-based methods, all have high requirements for data (such as requiring data to conform to normal distribution, linear distribution, etc.), otherwise the fitting effect will be affected and the fitting accuracy will be poor. In addition, data processing (such as outlier processing, smoothing, interpolation, etc.) is required, and data processing requires a lot of time and effort, resulting in low fitting efficiency. Summary of the invention

[0004] In view of this, the present application provides an image edge fitting method, an electronic device and a storage medium to solve the technical problems existing in the prior art of poor accuracy and low efficiency when performing straight line fitting on linear structures in an image.

[0005] A first aspect of the present application provides an image edge fitting method, the method comprising:

[0006] Setting multiple regions of interest in the target image;

[0007] Filtering edge points from a plurality of pixel points in each of the regions of interest;

[0008] Filtering out fitting points from the plurality of edge points;

[0009] The fitting points are fitted to obtain line segments used to characterize the edges of objects in the target image.

[0010] Optionally, setting a plurality of regions of interest in the target image includes:

[0011] Displaying an editing interface corresponding to the target image;

[0012] Receiving, through the editing interface, an original line segment drawn by a user on the target image according to the edge of the object;

[0013] Dividing the original line segment equally to obtain a plurality of equally divided line segments;

[0014] Taking the center point of each of the equally divided line segments as the center, multiple rectangular areas are generated according to the defined length and width, and each of the rectangular areas is a region of interest.

[0015] Optionally, dividing the original line segment equally to obtain a plurality of equally divided line segments comprises:

[0016] Acquire edge quality of the target image;

[0017] Determining the number of equal divisions according to the edge quality and a preset edge quality threshold segmentation interval;

[0018] Divide the original line segment equally according to the number of equal divisions to obtain a plurality of equally divided line segments;

[0019] The preset edge quality threshold segmentation interval includes multiple edge quality threshold intervals, and each edge quality threshold interval corresponds to an equal division quantity.

[0020] Optionally, filtering out edge points from a plurality of pixel points in each of the regions of interest includes:

[0021] Obtaining the contrast of each pixel in the region of interest;

[0022] A first target pixel point with the largest absolute value of contrast is filtered out from the multiple pixel points as the edge point.

[0023] Optionally, filtering out edge points from a plurality of pixel points in each of the regions of interest includes:

[0024] A first distance between each pixel point and the corresponding designated point of the region of interest is obtained, a shortest first distance is filtered out from a plurality of the first distances, and a pixel point corresponding to the shortest first distance is determined as the edge point.

[0025] Optionally, filtering out fitting points from the plurality of edge points includes:

[0026] Obtaining the overall center points of the plurality of regions of interest;

[0027] An average distance is calculated based on the second distance between each edge point and the overall center point;

[0028] Filtering out target second distances smaller than the average distance from the plurality of second distances;

[0029] An edge point corresponding to the second distance of the target is determined as the fitting point.

[0030] Optionally, filtering out fitting points from the plurality of edge points includes:

[0031] Obtaining the overall center lines of the plurality of regions of interest;

[0032] Dividing the plurality of regions of interest into a first side region of interest and a second side region of interest according to the overall center line; comparing the number of edge points in the first side region of interest with the number of edge points in the second side region of interest;

[0033] The edge points in the region of interest on one side with a larger number are determined as the fitting points.

[0034] Optionally, before determining the region of interest in the grayscale image, the method further includes:

[0035] Performing denoising processing on the target image; and / or

[0036] Performing contrast enhancement processing on the target image.

[0037] A second aspect of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the image edge fitting method when executing the computer program.

[0038] A third aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the image edge fitting method when executed by a processor.

[0039] The present application provides an image edge fitting method, electronic device and storage medium. The user sets a line segment close to the edge of an object and approximately parallel in the image to determine the image edge processing area, generates a region of interest according to the line segment set by the user, and can exclude interference from unnecessary areas; obtains edge points by filtering pixel points in each region of interest, and can effectively reduce the search range for edge points, thereby improving the efficiency of edge fitting; further excludes the influence of interference points by re-filtering the edge points to obtain fitting points, so that the edge fitting algorithm only needs to process meaningful data, thereby further improving the efficiency and quality of edge fitting, and finally obtains a line segment for characterizing the edge of the object in the target image by performing edge fitting on the fitting points. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, 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 work.

[0041] Figure 1 is a flow chart of an image edge fitting method provided in an embodiment of the present application;

[0042] Figure 2 is a schematic diagram of setting multiple regions of interest on a target image provided by an embodiment of the present application;

[0043] Figure 3 is a schematic diagram of a direction indicating line segment in a region of interest provided by an embodiment of the present application;

[0044] Figure 4 is a schematic diagram of filtering out fitting points by average distance provided in an embodiment of the present application;

[0045] Figure 5 is a schematic diagram of filtering out fitting points by regional division provided in an embodiment of the present application;

[0046] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0048] Figure 1 This is a flow chart of an image edge fitting method shown in an embodiment of the present application.

[0049] Before executing the image edge fitting method provided in the embodiment of the present application, a target image of an object with edges may be first captured by an image capture device.

[0050] In some implementations, a suitable image acquisition device may be selected based on the size of the object, the shooting distance, the required accuracy, etc. For example, assuming that the size of the object is 50*40mm and the accuracy requirement is 0.019mm / pix, an image acquisition device with 500w and a pixel size of 2592*1944 may be selected.

[0051] Before acquiring the target image, you need to ensure that there is a stable light source in the acquisition area, adjust the brightness and color temperature of the light source as needed, and then adjust the shooting position and shooting parameters (exposure time, gamma and gain, etc.) of the image acquisition device.

[0052] It should be understood that the target image captured by the image acquisition device is a color digital image, and the digital image needs to be converted into a grayscale digital image.

[0053] In an optional implementation, in order to improve the quality of edge fitting, after the target image is acquired, a denoising process is performed on the target image; and / or a contrast enhancement process is performed on the target image.

[0054] Image noise refers to some random or irregular pixels in an image. The presence of these pixels will make the image look blurry, distorted or grainy. In order to eliminate or reduce the noise in the target image, the target image can be de-noised by median filtering. By setting a target neighborhood of size s*t and performing a median filter formula calculation on the target area, the median grayscale value f(x,y) of the target neighborhood pixels is obtained, and the f(x,y) is used as the grayscale value of the target neighborhood matrix s*t, thereby filtering each pixel in the target image to achieve noise removal.

[0055] The calculation process of the median filter is as follows:

[0056] f(x,y)=median{z(i,j);i=1,2,...,s;j=1,2,...,t};

[0057] Among them, Z(i, y) is the grayscale value of the pixel corresponding to the coordinate (i, j) in the neighborhood s*t.

[0058] In other embodiments, calculation methods such as mean filtering and Gaussian filtering may be used to remove noise from the target image to achieve the purpose of smoothing the image.

[0059] In this example, a low-pass filtering process may be used to further enhance the target image.

[0060] The image edge fitting method is executed by an electronic device. The image edge fitting method specifically includes the following steps. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted.

[0061] S11: setting a plurality of regions of interest in the target image.

[0062] The user can set multiple regions of interest in the target image. By setting the regions of interest and searching for fitting points for edge fitting in the regions of interest, the interference of unnecessary regions can be eliminated. At the same time, the search range for finding fitting points can be effectively reduced, and the search time can be reduced, thereby improving the efficiency of finding fitting points, and further improving the efficiency of edge fitting.

[0063] In an optional implementation, setting a plurality of regions of interest in the target image includes:

[0064] Displaying an editing interface corresponding to the target image;

[0065] Receiving, through the editing interface, an original line segment drawn by a user on the target image according to the edge of the object;

[0066] Dividing the original line segment equally to obtain a plurality of equally divided line segments;

[0067] Taking the center point of each of the equally divided line segments as the center, multiple rectangular areas are generated according to the defined length and width, and each of the rectangular areas is a region of interest.

[0068] In this embodiment, the electronic device may provide a display interface, and the display interface is used to synchronously display the target image captured by the image capture device and receive the original line segment drawn by the user on the target image.

[0069] When the user finds the edge of an object in the target image displayed on the display interface, the user can touch the display interface with a finger, a stylus, or any other suitable object to draw a line segment close to the edge of the object on the display interface, so that the electronic device generates multiple regions of interest based on the drawn line segment. The length of the original line segment can be set or adjusted by the user according to the edge of the target image to be edited. The number of segments into which the original line segment is divided can also be set or adjusted by the user.

[0070] In some embodiments, since the line drawn by the user with his finger on the display interface is not a regular or standard straight line, the electronic device can fit the original line segment after receiving the rough line drawn by the user in the target image, and support the user to drag, scale, translate and other operations on the fitted original line segment, so that the original line segment can be closer to the edge of the object in the target image and approximately parallel to the edge of the target image.

[0071] After the original line segment is determined, the original line segment can be equally divided according to the preset number of equally divided points to obtain multiple equally divided line segments. Then the center point of each equally divided line segment is determined, and a rectangular area is generated with the center point of each equally divided line segment as the center. Multiple equally divided line segments correspond to multiple rectangular areas, and each rectangular area is defined as a region of interest.

[0072] See also Figure 2 , which is a schematic diagram of a region of interest set on an image provided in an embodiment of the present application.

[0073] Figure 2 The image in the image includes an image edge. When the user draws an original line segment according to the image edge, the electronic device can divide the original line segment into equal parts, for example, into three equal parts. Figure 2 The direction of the horizontal line in is taken as the horizontal axis direction of the coordinate system of the target image. With each equally divided line segment center point as the center, a rectangular area is generated according to the predefined length and width, and each of the rectangular areas is a region of interest. The center point of the equally divided line segment is the center of the rectangular area.

[0074] In some implementations, the electronic device may further provide a function for the user to set a direction indication line segment on the display interface, and the direction indication line segment may be set along the direction in which the grayscale value increases. Figure 3 As shown, the user sets a direction indicating line segment with an arrow along the symmetry axis in the vertical direction of the rectangular area, and the direction indicating line segment points from the end point to the start point. It should be understood that the center point of the direction indicating line segment is the center point of the rectangular area, the start point of the direction indicating line segment is the midpoint of one side of the rectangular area, and the end point of the direction indicating line segment is the midpoint of another parallel side of the rectangular area.

[0075] In an optional implementation manner, dividing the original line segment into equal parts to obtain a plurality of equally divided line segments comprises:

[0076] Acquire edge quality of the target image;

[0077] Determining the number of equal divisions according to the edge quality and a preset edge quality threshold segmentation interval;

[0078] The original line segment is equally divided according to the number of equally divided lines to obtain a plurality of equally divided line segments.

[0079] The edge quality of the target image may be determined by calculating a gradient value using an edge detection operator, such as a Sobel operator.

[0080] The preset edge quality threshold segmentation interval includes multiple edge quality threshold intervals, and each edge quality threshold interval corresponds to an equal division quantity.

[0081] The higher the edge quality of the target image, the smoother the edge of the target image, and the smaller the number of equal divisions. Fewer equal division line segments mean fewer regions of interest. Finding fitting points for edge fitting in a small number of regions of interest will speed up the fitting process. The lower the edge quality of the target image, the rougher the edge of the target image, and the larger the number of equal divisions. More equal division line segments mean more regions of interest. Finding fitting points for edge fitting in more regions of interest will result in more fitting points being found for edge fitting, which will result in better edge fitting results.

[0082] In an optional embodiment, the size of the region of interest can also be determined according to the edge quality of the target image. When the edge quality of the target image is higher, the region of interest is set smaller, that is, the shorter and narrower the region of interest is set, and the fitting point for edge fitting is found in the smaller region of interest, which will speed up the fitting speed. When the edge quality of the target image is worse, the region of interest is set larger, that is, the longer and wider the region of interest is set, and more fitting points can be found in the larger region of interest to perform edge fitting, which will make the edge fitting effect better.

[0083] The above optional implementation manner, by obtaining the edge quality of the target image, dynamically sets the number and / or size of the regions of interest according to the edge quality. When the edge quality is high, fewer regions of interest and / or smaller regions of interest are set, which helps to improve the efficiency of edge fitting. When the edge quality is low, more regions of interest and / or larger regions of interest are set, which helps to improve the quality of edge fitting.

[0084] S12: Filter out edge points from a plurality of pixel points in each of the regions of interest.

[0085] After the regions of interest are determined, edge points may be filtered out from each region of interest for subsequent edge fitting.

[0086] In an optional implementation, filtering out edge points from a plurality of pixel points in each of the regions of interest includes:

[0087] Obtaining the contrast of each pixel in the region of interest;

[0088] A first target pixel point with the largest absolute value of contrast is filtered out from the multiple pixel points as the edge point.

[0089] Electronic devices can obtain the contrast of each pixel by calculating the grayscale value difference between adjacent pixels. The edge is usually the area with the largest brightness change in the image. Through the contrast of each pixel, the edge of the image can be extracted, and the position (X / Y coordinate value) and direction information (contrast value) of the edge can be obtained. The greater the contrast of the edge pixel, the more obvious the edge in the image, and the smaller the contrast of the edge pixel, the more blurred or less obvious the edge in the image.

[0090] Since the contrast of a pixel can be positive or negative (the edge is positive when it changes from black to white, and negative when it changes from white to black), it is necessary to take the absolute value of the contrast and select the pixel corresponding to the maximum absolute value of the contrast as the edge point for output. The edge point with the maximum absolute value of the contrast is the first target pixel.

[0091] In the above optional implementation, since each region of interest includes multiple pixels with grayscale differences, at least one edge point can be filtered out from each region of interest by contrast, thereby providing a data basis for the subsequent determination of the pixel point that can be used as the optimal fitting point.

[0092] In another optional implementation, filtering out edge points from a plurality of pixel points in each of the regions of interest comprises:

[0093] Acquire a first distance between each pixel point and a corresponding area designated point of the area of ​​interest;

[0094] The shortest first distance is filtered out from the multiple first distances, and a pixel point corresponding to the shortest first distance is determined as the edge point.

[0095] The region designation point may be any one of the region center point, region start point, and region end point. The region center point is the geometric center point of the region of interest, that is, the center point of the corresponding equally divided line segment. The region start point is the geometric center point of a side of the region of interest, that is, the start point of the corresponding direction indicating line segment. The region end point is the geometric center point of a side of the region of interest, that is, the end point of the corresponding direction indicating line segment.

[0096] For each region of interest, a first distance (which may be a Euclidean distance or a Hamming distance) between each pixel point in the region of interest and the region designation point of the region of interest may be obtained. When the region designation point is the region center point, the first distance is the distance between the pixel point and the region center point of the corresponding region of interest. When the region designation point is the region start point, the first distance is the distance between the pixel point and the region start point of the corresponding region of interest. When the region designation point is the region end point, the first distance is the distance between the pixel point and the region end point of the corresponding region of interest.

[0097] The shorter the first distance is, the closer the pixel point is to the designated point of the region of interest, and the greater the possibility that the pixel point can be used as a fitting point. The longer the first distance is, the farther the pixel point is from the designated point of the region of interest, and the less likely the pixel point can be used as a fitting point.

[0098] After obtaining multiple first distances, the multiple first distances may be sorted from large to small, or from small to large, so as to determine the shortest first distance, and determine the pixel point corresponding to the shortest first distance as the edge point.

[0099] The above optional implementation method filters out edge points that can be used for edge fitting from each region of interest by calculating the distance between the pixel point and the region designated point. Since the region designated point can be any one of the region center point, region starting point, and region ending point, three distance acquisition methods are provided, which can be used to arbitrarily set or adjust a distance acquisition method according to actual conditions, such as image quality. The operability is strong and the user experience is improved.

[0100] Each region of interest includes a plurality of pixels. The edge points can be filtered out from the plurality of pixels in each region of interest by using the above-mentioned contrast-based method, or by using the above-mentioned distance-based method. Whether the contrast method or the distance method is used, the purpose is to filter out the edge points from the pixels. When the edge contrast is relatively clear, the edge points can be filtered out by using the contrast method. When the edge contrast is relatively close, the edge points can be filtered out by using the distance method.

[0101] S13: Filter out fitting points from the plurality of edge points.

[0102] Since there are some interference points among the multiple edge points filtered out, using these interference points for edge fitting will affect the effect of edge fitting. Therefore, it is necessary to filter out fitting points from the multiple edge points and use the filtered fitting points for edge fitting.

[0103] In an optional implementation, filtering out fitting points from the plurality of edge points comprises:

[0104] Obtaining the overall center points of the plurality of regions of interest;

[0105] An average distance is calculated based on the second distance between each edge point and the overall center point;

[0106] Filtering out target second distances smaller than the average distance from the plurality of second distances;

[0107] An edge point corresponding to the second distance of the target is determined as the fitting point.

[0108] The overall center point refers to the overall center point when multiple regions of interest are regarded as a whole region.

[0109] like Figure 4 As shown, the fitting points are filtered by using the average distance method.

[0110] The above optional implementation method filters the fitting points from the edge points by means of the average distance. When the second distance between the edge point and the overall center point is less than the average distance, it indicates that the edge point is closer to the overall center point. When the edge point close to the overall center point is used as the fitting point for edge fitting, the fitting line segment is closer to the real edge of the object. When the second distance between the edge point and the overall center point is greater than the average distance, it indicates that the edge point is far away from the overall center point. When the edge point far away from the overall center point is used as the fitting point for edge fitting, part of the fitting line segment is close to the real edge of the object, and the other part is far away from the real edge of the object.

[0111] In another optional implementation, filtering out fitting points from the plurality of edge points comprises:

[0112] Obtaining the overall center lines of the plurality of regions of interest;

[0113] Dividing the plurality of regions of interest into a first side region of interest and a second side region of interest according to the overall center line; comparing the number of edge points in the first side region of interest with the number of edge points in the second side region of interest;

[0114] The edge points in the region of interest on one side with a larger number are determined as the fitting points.

[0115] The overall center line refers to a horizontal dividing line when multiple regions of interest are regarded as a whole region, and the overall center line can be a horizontal symmetry axis of the whole region.

[0116] The overall area can be divided into upper and lower areas of interest according to the overall center line, that is, area division.

[0117] like Figure 5 As shown in Figure 1, these are the fitting points filtered out by using the regional division method.

[0118] The above optional implementation method filters the fitting points from the edge points by dividing the regions into sides. When the number of edge points in the region of interest on one side is large, it indicates that there are more edge points in the region of interest on the other side. When more edge points are used as fitting points for edge fitting, the effect of fitting the line segment is better, so that it is closer to the real edge of the object. When the number of edge points in the region of interest on one side is small, it indicates that there are fewer edge points in the region of interest on the other side. When fewer edge points are used as fitting points for edge fitting, the effect of fitting the line segment is poor.

[0119] S14: Fitting the fitting points to obtain line segments used to characterize the edges of objects in the target image.

[0120] After filtering out the fitting points from the edge points, the existence of the interference points has been accurately excluded, so by using the filtered fitting points for fitting, it is possible to obtain line segments for representing the edges of objects in the target image.

[0121] In an optional implementation, the fitting points may be substituted into the fitting points using the least square method to obtain the fitting line segments of the image edges.

[0122] The principle of least squares method for edge fitting is:

[0123] Select n sets of fitting points (x1,y1),(x2,y2),...,(x i ,y i );

[0124] Substitute the n groups of fitting points into the following least squares calculation formula to obtain the slope (k) and intercept (b) of the fitting line; Slope (k) calculation formula: Intercept (b) calculation formula: in, and are respectively the average values ​​of the coordinates of the n groups of fitting points;

[0125] According to the slope (k) and the intercept (b), the best fitting straight line formula (y=kx+b) is obtained.

[0126] Since interference points reduce the quality and clarity of the image and require the algorithm to process more data, the presence of interference points will not only affect the accuracy and stability of edge fitting, but also reduce the processing speed and affect the efficiency of edge fitting. The present application can eliminate interference from unnecessary areas by setting multiple regions of interest in the target image; by filtering out edge points in the region of interest, the search range for finding edge points can be effectively reduced, thereby improving the efficiency of edge fitting, and the filtered edge points remove interference points, which can reduce noise and errors and improve the accuracy and reliability of edge fitting; then, the fitting points used for edge fitting are filtered out from the edge points, further eliminating the influence of interference points, so that the edge fitting algorithm only needs to process meaningful data, thereby further improving the efficiency and quality of edge fitting.

[0127] In addition, after filtering out edge points from the region of interest and filtering out fitting points from edge points, non-fitting points can be deleted, because interference points usually cover up some useful information. Deleting non-fitting points from the target image can remove the influence of interference points on the target image, thereby improving the visual effect and image quality of the target image, and facilitating subsequent processing and analysis of the target image. For example, when performing feature extraction processing on the target image, image features can be better identified and extracted.

[0128] See also Figure 6 FIG. 1 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. In a preferred embodiment of the present invention, the electronic device 6 may include, but is not limited to: a memory 61 , at least one processor 62 and at least one communication bus 63 .

[0129] Those skilled in the art should understand that Figure 6 The structure of the image edge fitting device shown does not constitute a limitation of the embodiment of the present invention, and the electronic device 6 may also include more or less other hardware or software than that shown in the figure, or a different arrangement of components.

[0130] In some embodiments, the electronic device 6 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors and embedded devices.

[0131] It should be noted that the electronic device 6 is only an example, and other existing or future electronic products that are suitable for the present application should also be included in the protection scope of the present application and included here by reference.

[0132] In some embodiments, the memory 61 stores a computer program, and when the computer program is executed by the at least one processor 62, all or part of the steps in the device balance control method as described above are implemented. The memory 61 includes a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc memory, magnetic disk memory, magnetic tape memory, or any other computer-readable medium that can be used to carry or store data. Further, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, and the like.

[0133] In some embodiments, the at least one processor 62 is the control core (ControlUnit) of the electronic device 6, and uses various interfaces and lines to connect various components of the entire electronic device 6, and executes various functions and processes data of the electronic device 6 by running or executing programs or modules stored in the memory 61, and calling data stored in the memory 61. For example, when the at least one processor 62 executes the computer program stored in the memory, it implements all or part of the steps of the image edge fitting method described in the embodiment of the present application; or implements all or part of the functions of the image edge fitting device. The at least one processor 62 can be composed of an integrated circuit, for example, it can be composed of a single packaged integrated circuit, or it can be composed of multiple integrated circuits with the same function or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips.

[0134] When the at least one processor 62 executes the computer program stored in the memory 61, it is used to implement:

[0135] Setting multiple regions of interest in the target image;

[0136] Filtering edge points from a plurality of pixel points in each of the regions of interest;

[0137] Filtering out fitting points from the plurality of edge points;

[0138] The fitting points are fitted to obtain line segments used to characterize the edges of objects in the target image.

[0139] Optionally, the at least one processor 62 sets a plurality of regions of interest in the target image, including:

[0140] Displaying an editing interface corresponding to the target image;

[0141] Receiving, through the editing interface, an original line segment drawn by a user on the target image according to the edge of the object;

[0142] Dividing the original line segment equally to obtain a plurality of equally divided line segments;

[0143] Taking the center point of each of the equally divided line segments as the center, multiple rectangular areas are generated according to the defined length and width, and each of the rectangular areas is a region of interest.

[0144] Optionally, the at least one processor 62 divides the original line segment into equal parts to obtain a plurality of equally divided line segments including:

[0145] Acquire edge quality of the target image;

[0146] Determining the number of equal divisions according to the edge quality and a preset edge quality threshold segmentation interval;

[0147] Divide the original line segment equally according to the number of equal divisions to obtain a plurality of equally divided line segments;

[0148] The preset edge quality threshold segmentation interval includes multiple edge quality threshold intervals, and each edge quality threshold interval corresponds to an equal division quantity.

[0149] Optionally, the at least one processor 62 filters out edge points from a plurality of pixel points in each of the regions of interest, including:

[0150] Obtaining the contrast of each pixel in the region of interest;

[0151] A first target pixel point with the largest absolute value of contrast is filtered out from the multiple pixel points as the edge point.

[0152] Optionally, the at least one processor 62 filters out edge points from a plurality of pixel points in each of the regions of interest, including:

[0153] A first distance between each pixel point and the corresponding designated point of the region of interest is obtained, a shortest first distance is filtered out from a plurality of the first distances, and a pixel point corresponding to the shortest first distance is determined as the edge point.

[0154] Optionally, the at least one processor 62 filters out fitting points from the plurality of edge points, including:

[0155] Obtaining the overall center points of the plurality of regions of interest;

[0156] An average distance is calculated based on the second distance between each edge point and the overall center point;

[0157] Filtering out target second distances smaller than the average distance from the plurality of second distances;

[0158] An edge point corresponding to the second distance of the target is determined as the fitting point.

[0159] Optionally, the at least one processor 62 filters out fitting points from the plurality of edge points, including:

[0160] Obtaining the overall center lines of the plurality of regions of interest;

[0161] Dividing the plurality of regions of interest into a first side region of interest and a second side region of interest according to the overall center line; comparing the number of edge points in the first side region of interest with the number of edge points in the second side region of interest;

[0162] The edge points in the region of interest on one side with a larger number are determined as the fitting points.

[0163] Optionally, before determining the region of interest in the grayscale image, when the at least one processor 62 executes the computer program stored in the memory 61, it is further configured to implement:

[0164] Performing denoising processing on the target image; and / or

[0165] Performing contrast enhancement processing on the target image.

[0166] In some embodiments, the at least one communication bus 63 is configured to realize connection and communication between the memory 61 and the at least one processor 62, etc. Although not shown, the electronic device 6 may also include a power supply (such as a battery) for powering each component. Preferably, the power supply may be logically connected to the at least one processor 62 through a power management device, so that the power management device can realize functions such as management of charging, discharging, and power consumption management. The power supply may also include any components such as one or more DC or AC power supplies, recharging power supply fault detection circuits, power converters or inverters, power status indicators, etc. The electronic device 6 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which are not repeated here.

[0167] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling an electronic device (which can be a personal computer, electronic device, or network device, etc.) or a processor to execute part of the method described in each embodiment of the present application.

[0168] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.

[0169] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, and may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0170] The above are all preferred embodiments of the present application, and the protection scope of the present application is not limited thereto. Therefore, any equivalent changes made according to the structure, shape, and principle of the present application should be included in the protection scope of the present application.

Claims

1. An image edge fitting method, characterized in that: The method comprises: Setting multiple regions of interest in the target image; Filtering edge points from a plurality of pixel points in each of the regions of interest; Filtering fitting points from the plurality of edge points; Fitting the fitting points to obtain line segments used to characterize the edges of objects in the target image; The filtering out the fitting points from the plurality of edge points comprises: Obtaining the overall center points of the plurality of regions of interest; An average distance is calculated based on the second distance between each edge point and the overall center point; Filtering out target second distances smaller than the average distance from the plurality of second distances; An edge point corresponding to the second distance of the target is determined as the fitting point.

2. The image edge fitting method according to claim 1, characterized in that: The step of setting a plurality of regions of interest in the target image comprises: Displaying an editing interface corresponding to the target image; Receiving, through the editing interface, an original line segment drawn by a user on the target image according to the edge of the object; Dividing the original line segment equally to obtain a plurality of equally divided line segments; Taking the center point of each of the equally divided line segments as the center, multiple rectangular areas are generated according to the defined length and width, and each of the rectangular areas is a region of interest.

3. The image edge fitting method according to claim 2, characterized in that: The step of equally dividing the original line segment to obtain a plurality of equally divided line segments comprises: Acquire edge quality of the target image; Determining the number of equal divisions according to the edge quality and a preset edge quality threshold segmentation interval; Divide the original line segment equally according to the number of equal divisions to obtain a plurality of equally divided line segments; The preset edge quality threshold segmentation interval includes multiple edge quality threshold intervals, and each edge quality threshold interval corresponds to an equal division quantity.

4. The image edge fitting method according to claim 3, characterized in that: The filtering out edge points from a plurality of pixel points in each of the regions of interest comprises: Obtaining the contrast of each pixel in the region of interest; A first target pixel point with the largest absolute value of contrast is filtered out from the multiple pixel points as the edge point.

5. The image edge fitting method according to claim 3, characterized in that: The filtering out edge points from a plurality of pixel points in each of the regions of interest comprises: A first distance between each pixel point and the corresponding designated point of the region of interest is obtained, a shortest first distance is filtered out from a plurality of the first distances, and a pixel point corresponding to the shortest first distance is determined as the edge point.

6. The image edge fitting method according to claim 4 or 5, characterized in that: The filtering out the fitting points from the plurality of edge points comprises: Obtaining the overall center lines of the plurality of regions of interest; Dividing the plurality of regions of interest into a first side region of interest and a second side region of interest according to the overall center line; comparing the number of the edge points in the first-side region of interest with the number of the edge points in the second-side region of interest; The edge points in the region of interest on one side with a larger number are determined as the fitting points.

7. The image edge fitting method according to claim 1, characterized in that: Before determining the region of interest in the grayscale image, the method further includes: Performing denoising on the target image; and / or Performing contrast enhancement processing on the target image.

8. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the image edge fitting method according to any one of claims 1 to 7 when executing the computer program.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the image edge fitting method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Ultrasonic imaging method and system, ultrasonic image measurement method and treatment system as well as medium

    CN109846513A

  • Edible mushroom image recognition method

    CN115760853A

  • Edge detection method, defect detection method and detection device

    CN115861351A