Image processing methods and related equipment
By identifying the first region in an image that is brighter than the surrounding area, and using binarization and fitting functions to determine the boundary, the problem of inaccurate region of interest caused by image edge offset or ripples is solved, achieving accurate region of interest localization and reducing hardware costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-26
- Publication Date
- 2026-03-10
AI Technical Summary
In existing technologies, image edge offset or ripples lead to inaccurate determination of regions of interest, and adding hardware is costly and space-consuming.
By acquiring the first region in the image to be processed that is brighter than the surrounding area, the range and boundary of the first region are determined using a binarization algorithm and a fitting function, thereby locating the region of interest.
It enables accurate determination of regions of interest even with image offset or ripple, reduces hardware costs, and the entire process is completed through program control.
Smart Images

Figure CN115393220B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to an image processing method and related equipment. Background Technology
[0002] In existing technologies, in order to perform detection or image processing based on acquired images, it is often necessary to determine the corresponding region of interest (ROI) in the image, and then perform detection or image processing based on the ROI. The determination of ROI in acquired images is generally done directly based on the location of data points.
[0003] If the edges of an image shift or become wavy, the determined area of interest will not be accurate. To reduce edge shifts or wavy patterns, additional hardware (such as a marble scanner) is typically added. However, this method is costly and consumes hardware configuration space. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide an image processing method and related equipment that can solve or partially solve the above-mentioned technical problems.
[0005] To achieve the above objectives, this application provides an image processing method, comprising:
[0006] Acquire an image to be processed, the image to be processed comprising: a first region and a second region, the first region being located at the edge of the second region, and the brightness of the first region being greater than the brightness of the second region;
[0007] Determine the range of the first region corresponding to the first region in the image to be processed;
[0008] The boundary of the first region is determined based on the scope of the first region;
[0009] The corners of the image to be processed are located based on the boundary of the first region, and the region of interest corresponding to the image to be processed is determined using the location result.
[0010] Based on the same inventive concept, a second aspect of this application provides an image processing apparatus, comprising:
[0011] The acquisition module is configured to acquire an image to be processed, the image to be processed including: a first region and a second region, the first region being located at the edge of the second region, and the brightness of the first region being greater than the brightness of the second region;
[0012] The region determination module is configured to determine the range of a first region corresponding to the first region in the image to be processed;
[0013] The boundary determination module is configured to determine the boundary of the first region based on the range of the first region.
[0014] The region of interest determination module is configured to locate the corners of the image to be processed based on the boundary of the first region, and use the location results to determine the region of interest corresponding to the image to be processed.
[0015] Based on the same inventive concept, a third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in the first aspect.
[0016] Based on the same inventive concept, a fourth aspect of this application provides a non-transitory computer-readable storage medium that stores computer instructions, wherein the computer instructions are used to cause a computer to perform the method described in the first aspect.
[0017] Based on the same inventive concept, the fifth aspect of this application provides a computer program product, including computer program instructions, wherein when the computer program instructions are run on a computer, the computer causes the computer to perform the method as described in the first aspect.
[0018] As can be seen from the above, the image processing method and related equipment provided in this application can obtain an image to be processed where the brightness of the edge region (i.e., the first region) is greater than that of the inner second region. Thus, the first region is the bright edge region of the image to be processed. The boundary of the bright edge region is determined based on the contour range corresponding to the bright edge region. Each corner is located from the boundary of the bright edge region, and the region of interest is determined based on the corner location results. Because the determined bright edge region is accurate, even if the image to be processed is shifted or has ripples, the region of interest can still be accurately determined based on the bright edge region. Furthermore, the entire region of interest determination process is completed through program control without the need for additional hardware, thus reducing costs. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in this application or related technologies, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart of an image processing method according to an embodiment of this application;
[0021] Figure 2A An example diagram showing the determination of the value of Δy in an embodiment of this application;
[0022] Figure 2B Example diagram showing the determination of the value of distance_from_CG in embodiments of this application;
[0023] Figure 2C-1 An example diagram showing the correction of the ROI region at the upper boundary of an embodiment of this application;
[0024] Figure 2C-2 This is an example diagram illustrating the correction of the ROI region at the lower boundary of an embodiment of this application.
[0025] Figure 2D-1 This is an example diagram of ROI region correction at the upper boundary of another embodiment of this application;
[0026] Figure 2D-2 This is an example diagram of ROI region correction at the lower boundary of another embodiment of this application;
[0027] Figure 2E This is an example diagram of ROI region correction in another embodiment of this application;
[0028] Figure 3 This is a structural block diagram of the image coloring processing method according to an embodiment of this application;
[0029] Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with specific embodiments and the accompanying drawings.
[0031] It should be noted that, unless otherwise defined, the technical or scientific terms used in the embodiments of this application should have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms "first," "second," and similar terms used in the embodiments of this application do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are only used to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0032] The terms used in this application are explained below:
[0033] Region of Interest (ROI): A region of interest is a specific area within an image that is selected as the region of interest.
[0034] Binarization algorithm: It is one of the simplest methods for image segmentation. It can convert a grayscale image into a binary image by setting the grayscale values of pixels greater than a certain threshold as grayscale maxima and the grayscale values of pixels less than this threshold as grayscale minima, thereby achieving binarization.
[0035] Circumscribed rectangle: also known as the minimum circumscribed rectangle, refers to the maximum extent of several two-dimensional shapes (such as points, lines, and polygons) represented by two-dimensional coordinates. In other words, it is the rectangle whose lower boundary is defined by the maximum and minimum x-coordinates, maximum and minimum y-coordinates of each vertex of a given two-dimensional shape.
[0036] Based on the above description, the image processing method proposed in the embodiments of this application can be applied to flat screens or curved screens, and the corresponding screens can be LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), AMOLED (Active-matrix organic light-emitting diode), etc.
[0037] like Figure 1 As shown, it includes:
[0038] Step 101: Obtain the image to be processed. The image to be processed includes a first region and a second region. The first region is located at the edge of the second region, and the brightness of the first region is greater than the brightness of the second region.
[0039] In practice, an optical solution can be used to illuminate the edges of the screen, resulting in an image to be processed consisting of two regions: a first region located at the illuminated edge and a second region located in the middle that is not illuminated. The first region can be the edges distributed on both sides of the second region.
[0040] For example, the optical solution involves adjusting the brightness of the screen edge to 255 (or another brightness value, which is not specifically limited here), thereby illuminating the first area of the edge of the image to be processed. The brightness of the second area is displayed according to the normal display method of the corresponding image.
[0041] Step 102: Determine the range of the first region corresponding to the first region in the image to be processed.
[0042] In some embodiments, step 102 includes:
[0043] Step 1021: Use a binarization algorithm to binarize each pixel in the image to be processed to obtain a binarized image. The grayscale values of each pixel in the binarized image include: a first value and a second value.
[0044] In practice, when using a binarization algorithm, a grayscale threshold can be set (e.g., any value from 1 to 254). During binarization, each pixel in the image to be processed is compared to this grayscale threshold. If the pixel's grayscale value is greater than or equal to the threshold, it is determined to have a first grayscale value (e.g., 255); if it is less than the threshold, it is determined to have a second grayscale value (e.g., 0). This process yields a binarized image.
[0045] Step 1022: Determine at least one region range in the binarized image whose grayscale value is the first value.
[0046] In practice, after obtaining the binarized image, the range of grayscale values belonging to the first value is determined, and one or more ranges of the obtained ranges belong to the bright spot regions.
[0047] Step 1023: Determine the area range whose area exceeds a predetermined area value from the at least one area range as the first area range.
[0048] The portion belonging to the first region in the obtained one or more regions should be a large area, while the portion belonging to the second region should be a small spot area. Therefore, the area of each region can be compared with a predetermined area value (which is set according to the edge area of different screen models). This allows the corresponding first region to be selected, which is the determined bright edge area of the image to be processed.
[0049] The above method makes it more accurate to find bright edge areas in the image to be processed.
[0050] In some embodiments, after step 1023, the method further includes:
[0051] Step 1024: Construct a first image with the same size as the image to be processed and a grayscale value of a third value, wherein the third value is different from the first value.
[0052] In practice, the third value can be the same as the second value, but it must not be the same as the first value. However, to better distinguish between them, the third value should be set to a grayscale value that differs significantly from the first value. For example, the first value is 255, and both the second and third values are 0.
[0053] Step 1025: Integrate the first region range in the binarized image with the first image to obtain a new image, wherein the new image includes the first region range.
[0054] In practice, after obtaining the newly created image, it can replace the image to be processed for subsequent processing. Based on the difference between the third and first values, the first region can be better located within the newly created image.
[0055] Then, a parent coordinate system is constructed based on the newly created image, with the lower left corner as the origin. The bounding rectangle of the first region in the newly created image is determined using the parent coordinate system. For example, the coordinates of the bounding rectangle are rec1(x,y,width,height). Determining the bounding rectangle facilitates the determination of boundary points in subsequent steps.
[0056] Step 103: Determine the boundary of the first region based on the range of the first region.
[0057] In practice, the first region is generally the edge area on the left and right sides of the newly created image. To facilitate calculation, the boundary line of the first region needs to be determined, and this boundary line is the boundary of the first region.
[0058] In some embodiments, step 103 includes:
[0059] Step 1031: Divide the image to be processed into multiple equal parts to obtain multiple equal parts images, and determine the sub-boundary rectangle of the first region range in each equal part image to obtain multiple sub-boundary rectangles.
[0060] In some embodiments, step 1031 includes:
[0061] Step 10311: Construct a parent coordinate system for the image to be processed, and divide the image to be processed into multiple equally divided images according to the coordinate values of the image to be processed in the parent coordinate system. The vertical axis value of each equally divided image is less than or equal to the maximum vertical axis value of the first region.
[0062] In practice, the newly created image replacing the image to be processed can be divided into equal parts based on the height of the bounding rectangle of the first region obtained above. The number of equal parts, n, can be set according to actual needs. After setting, the height of the bounding rectangle of the first region can be divided into n equal parts, thus dividing the newly created image into n equal parts, resulting in n equally sized images.
[0063] Step 10312: Reconstruct the corresponding sub-coordinate system for each equally divided image, and determine the sub-bound rectangle of the first region range in the equally divided image corresponding to the sub-coordinate system.
[0064] In practice, each equally divided image contains a portion of the first region, requiring the reconstruction of a sub-coordinate system using the lower left corner of the divided image as the origin. This gives each equally divided image a corresponding sub-coordinate system. Then, the sub-bounding rectangle corresponding to the first region in each equally divided image is determined based on its respective sub-coordinate system.
[0065] This allows for the quick and accurate determination of the boundary points of the first region based on the child circumscribed rectangle.
[0066] Step 10313: For each sub-bound rectangle determined based on the sub-coordinate system, determine the coordinate value of each sub-bound rectangle in the parent coordinate system according to the correspondence between the sub-coordinate system and the parent coordinate system.
[0067] In practice, after determining the child bounding rectangle, in order to facilitate the determination of subsequent boundary points, it is necessary to convert the coordinates of the child bounding rectangle into coordinate values in the parent coordinate system constructed above.
[0068] Step 1032: Determine the boundary points of each of the sub-boundary rectangles to obtain multiple boundary points.
[0069] In practice, the boundary points in each sub-boundary rectangle can be determined based on the boundary of the sub-outer rectangle corresponding to the range of the first region.
[0070] Step 1033: Fit the multiple boundary points using a fitting function to obtain the boundary of the first region.
[0071] In practice, in order to better determine the boundary based on the boundary points, it is necessary to use a fitting function to fit the boundary points into a boundary line. The resulting boundary line is the boundary of the first region.
[0072] The above method ensures that the determined boundary of the first region is more accurate.
[0073] In some embodiments, step 1033 includes:
[0074] Step 10331: Determine the coordinates of each boundary point according to the parent coordinate system of the constructed image to be processed.
[0075] Step 10332: Perform linear fitting on the coordinates of each boundary point using a linear fitting function to obtain a fitted line, and determine the boundary of the first region based on the fitted line.
[0076] In practice, the fitting function used is a straight line fitting function, which can fit the boundary points into a fitted straight line. This can better determine the boundary of the first region, making the determined boundary of the first region a straight line, and thus better locate the boundary of the first region.
[0077] In some embodiments, determining the boundary of the first region based on the fitted straight line in step 10332 includes:
[0078] Step 103321: Determine the bounding rectangle of the first region, and obtain the ordinate rec1.y of the bounding rectangle in the parent coordinate system, and the height rec1.height of the bounding rectangle.
[0079] Step 103322: Calculate the slope K of the fitted line.
[0080] Step 103323: Determine the x-coordinate point0.x of the intersection point of the fitted line with the x-axis of the parent coordinate system and the y-coordinate point0.y of the intersection point with the y-axis of the parent coordinate system.
[0081] Step 103324: Calculate the ordinate of the first endpoint of the first region: point1.y = rec1.y - Δy, where Δy is the boundary offset.
[0082] Step 103325, calculate the x-coordinate of the first endpoint: point1.x = (point1.y - point0.y) / K + point0.x.
[0083] Step 103326, calculate the ordinate of the second endpoint of the first region: point2.y = rec1.y + rec1.height + Δy.
[0084] Step 103327, calculate the x-coordinate of the second endpoint: point2.x = (point2.y - point0.y) / K + point0.x.
[0085] Step 103328: Determine the boundary of the first region based on the coordinates of the first endpoint and the coordinates of the second endpoint.
[0086] The above scheme can accurately determine the coordinates of the two endpoints (i.e., the first endpoint and the second endpoint) of the first region in the parent coordinate system constructed above, thereby accurately determining the position of the two endpoints. In this way, the boundary of the first region constructed based on the two endpoints is more accurate.
[0087] Step 104: Locate the corner of the image to be processed based on the boundary of the first region, and determine the region of interest corresponding to the image to be processed using the location result.
[0088] In specific implementation, the first region boundary is the bright edge boundary of both sides of the newly constructed image that replaces the image to be processed, as described above. The newly constructed image has at least four corners, which can be right angles or curved corners; in this implementation, curved corners are preferred. The coordinates of the corners are located in the constructed parent coordinate system based on the first region boundary, thus obtaining the corner location result. The range coordinates of the region of interest can then be determined based on the corner location coordinates, thereby determining the region of interest of the image to be processed. If the screen has already determined the region of interest using conventional methods, the region of interest determined by the above embodiment can be used to correct the region of interest determined by related technologies, thereby ensuring the accuracy of the region of interest determination.
[0089] Subsequently, this region of interest can be used for detecting cracks and defects in metal signal lines of LCDs, OLEDs, ICs (Integrated Circuit Chips), PCBs (Printed Circuit Boards), etc., or for further image detection or image repair processing of the region of interest.
[0090] In some embodiments, step 104 includes:
[0091] Step 1041: Determine the corner positions of at least four corners of the image to be processed based on the boundary of the first region. The at least four corners include: a first corner and a second corner at one end of the image to be processed, and a third corner and a fourth corner at the other end of the image to be processed.
[0092] In some embodiments, when all four corners are curved corners, each curved corner corresponds to two endpoints. Therefore, the first corner includes at least two endpoints as endpoint pt1 and endpoint pt2, the second corner includes at least two endpoints as endpoint pt3 and endpoint pt4, the third corner includes at least two endpoints as endpoint pt5 and endpoint pt6, and the fourth corner includes at least two endpoints as endpoint pt7 and endpoint pt8.
[0093] In practice, more points corresponding to each corner can be obtained for more precise positioning. No specific limitations are set here.
[0094] In some embodiments, step 1041 includes:
[0095] Step 10411: Determine the width W and height H of the pixel area corresponding to the corner of the image to be processed, wherein the pixel area is inside the second region.
[0096] Step 10412: Calculate the x-coordinate of endpoint pt1, pt1.x = point1.x + D, where D is the distance between the outer edge of the first region and the pixel region; calculate the y-coordinate of endpoint pt1, pt1.y = (pt1.x - point1.x) / K + point1.y.
[0097] Step 10413: Calculate the ordinate of endpoint pt2, pt2.y = pt1.y + H; calculate the abscissa of endpoint pt2, pt2.x = (pt2.y - pt1.y) / K + pt1.x.
[0098] Step 10414: Calculate the x-coordinate of endpoint pt3, pt3.x = pt2.x + W; calculate the y-coordinate of endpoint pt3, pt3.y = (pt2.x - pt3.x) / K + pt2.y.
[0099] Step 10415: Calculate the ordinate of endpoint pt4, pt4.y = pt3.yH; calculate the abscissa of endpoint pt4, pt4.x = (pt3.y - pt4.y) / K + pt3.x.
[0100] Step 10416: Calculate the x-coordinate of endpoint pt5 as point2.x+D; calculate the y-coordinate of endpoint pt5 as pt5.y = (pt5.x - point2.x) / K + point2.y.
[0101] Step 10417: Calculate the ordinate of endpoint pt6, pt6.y = pt5.yH; calculate the abscissa of endpoint pt6, pt6.x = (pt6.y - pt5.y) / K + pt5.x.
[0102] Step 10418: Calculate the x-coordinate of endpoint pt7: pt7.x = pt6.x + W; calculate the y-coordinate of endpoint pt7: pt7.y = (pt6.x - pt7.x) / K + pt6.y.
[0103] Step 10419: Calculate the ordinate of endpoint pt8: pt4.y = pt7.y + H; calculate the abscissa of endpoint pt8: pt8.x = (pt7.y - pt8.y) / K + pt7.x.
[0104] In practice, additional points can be added based on the eight endpoints obtained above for precise positioning of the region of interest. The specific number and location of the selected points are not limited here.
[0105] Step 1042: Connect at least four of the corner positions according to a predetermined connection method to obtain the region of interest.
[0106] In some embodiments, step 1042 includes: sequentially connecting the endpoints pt1, pt2, pt3 and pt4, and sequentially connecting the endpoints pt5, pt6, pt7 and pt8 to obtain the region of interest.
[0107] By using the above method, the two endpoints of the curve corresponding to each corner are calculated, and then the coordinate values of the above 8 endpoints in the parent coordinate system are obtained. This allows for precise positioning of these 8 endpoints in the parent coordinate system, thereby ensuring that the region of interest determined based on these 8 endpoints is more accurate.
[0108] The technical solution described in the above embodiments can obtain an image to be processed where the brightness of the edge region (i.e., the first region) is greater than that of the inner second region. Thus, the first region is the bright edge region of the image to be processed. The boundary of the bright edge region is determined based on its corresponding contour range. Each corner is located from the boundary of the bright edge region, and the region of interest is determined based on the corner location results. Because the determined bright edge region is accurate, even if the image to be processed is shifted or has ripples, the region of interest can still be accurately determined based on the bright edge region. Furthermore, the entire region of interest determination process is completed through program control without the need for additional hardware, thus reducing costs.
[0109] The implementation process of the image processing method is described below with a specific embodiment.
[0110] First, the edges of the original image (i.e., the image to be processed) are illuminated using an optical scheme (the specific illumination method can be setting the displayed grayscale value to 255, 254, or other grayscale values). After illumination, the original image will consist of two parts: one is the illuminated edge area (i.e., the first area) and the other is the normally displayed area in the middle (i.e., the second area). Then, the region of interest in the image to be processed is determined according to the following steps.
[0111] The first step is to find the bright edges.
[0112] The original image is binarized using a threshold of 1 (or any other threshold, which is not specifically limited here). Pixels with grayscale values greater than threshold 1 are set to 255, and pixels with grayscale values less than the threshold are set to 0. Then, all spot regions with grayscale values of 255 (i.e., at least one region) are compared with each other based on their size to find the spots in the bright edge region (i.e., the first region). The comparison method can be to compare the area, height, etc. of each spot region.
[0113] The second step is to reconstruct the image with bright edges (new image).
[0114] Create an image (Image 1) with the same size as the original image but with all pixels having a value of 0. Then, reconstruct the bright edge area on Image 1, so that the grayscale value of Image 1 is 255 except for the bright edge area, and the grayscale value of all other pixels is 0. Construct a coordinate system (i.e., the parent coordinate system) with the origin of Image 1 as the origin, and calculate the bounding rectangle rec1(x,y,width,height) of the bright edge area.
[0115] The third step is to obtain the bright edge boundary (i.e., the boundary of the first region).
[0116] Create n rectangles (x, y1, width, 1), (x, y2, width, 1), ..., (x, yn, width, 1) using the origin of image 1 as the origin. Then, crop n images of size width * 1 from image 1 using these rectangle coordinates. The values of y1 and yn are between y and y + height. Construct a coordinate system (i.e., a sub-coordinate system) using the origin of each width * 1 rectangle as the origin, and calculate the bounding rectangle of the bright area: (x1, 0, width1, 1), (x2, 0, width2, 1), ..., (xn, 0, width(n), 1). The boundary point p1 has coordinates of (x + x1, y1) on image 1, p2 has coordinates of (x + x2, y2) on image 1, ..., pn has coordinates of (x + xn, yn) on image 1.
[0117] The fourth step is boundary point fitting.
[0118] By using the fitting function fitline() to fit the boundary points p1, p2, ..., pn with a straight line, the fitted line line1 is obtained. line1 contains four elements: line1[0] represents the cosine of the angle between line1 and the X-axis, line1[1] represents the sine of the angle between line1 and the X-axis, and line1[2] and line1[3] represent the coordinates of a point (x0, y0) on line1.
[0119] Boundary line acquisition. After obtaining the fitted straight line line1, the boundary line can be accurately drawn based on the four elements of line1. The specific method is as follows: First, calculate the slope K of the boundary line, K = line1[0] / line1[1], and determine the upper and lower endpoints of the corresponding edge of the bright edge area as point1 (i.e., the first endpoint) and point2 (i.e., the second endpoint). The process of determining the coordinates of the two endpoints is as follows:
[0120] point1.y = rec1.y - Δy;
[0121] point1.x=(point1.y-point0.y) / K+point0.x;
[0122] point2.y=rec1.y+rec1.height+Δy;
[0123] point2.x=(point2.y-point0.y) / K+point0.x.
[0124] Where Δy is the offset (i.e., the distance between the lower boundary of the bright edge and the lower boundary of the detected screen sample). The magnitude of this offset is usually related to the characteristics of the detected screen sample. Figure 2A Taking edge detection of a mobile phone display screen as an example, there is a certain distance Δy between the lower boundary of its bright edge and the lower boundary of the screen sample. Usually, Δy is related to the curvature of the screen sample's corner. Δy can be set as an adjustable parameter to cope with the difference in offset between different products.
[0125] Step 5: Obtaining ROI boundary points.
[0126] Here, the height H and width W of the pixel area near the top and bottom corners of the screen sample (corners are usually high-incidence areas for defects such as bubbles, foreign objects, and abnormal points) are used to illustrate the ROI boundary point description. For example, a 900*1200 area is used as the detection ROI area.
[0127] The boundary points of the ROI region at the top corner of the screen sample are: pt1, pt2, pt3, pt4. Then:
[0128] pt1.x=point1.x+distance_from_CG;
[0129] pt1.y=(pt1.x-point1.x) / K+point1.y;
[0130] pt2.y = pt1.y + 900;
[0131] pt2.x=(pt2.y-pt1.y) / K+pt1.x;
[0132] pt3.x = pt2.x + 1200;
[0133] pt3.y=(pt2.x-pt3.x) / K+pt2.y;
[0134] pt4.y = pt3.y - 900;
[0135] pt4.x=(pt3.y-pt4.y) / K+pt3.x.
[0136] The boundary points of the ROI region at the corner below the product are: pt5, pt6, pt7, pt8. Then:
[0137] pt5.x=point2.x+distance_from_CG;
[0138] pt5.y=(pt5.x-point2.x) / K+point2.y;
[0139] pt6.y = pt5.y - 900;
[0140] pt6.x=(pt6.y-pt5.y) / K+pt5.x;
[0141] pt7.x = pt6.x + 1200;
[0142] pt7.y=(pt6.x-pt7.x) / K+pt6.y;
[0143] pt8.y = pt7.y + 900;
[0144] pt8.x=(pt7.y-pt8.y) / K+pt7.x.
[0145] Where distance_from_CG (i.e., the distance D between the outer edge of the first region and the pixel region) is the distance between the pixel region and the bright edge boundary. Its size is usually related to the characteristics of the screen sample. Figure 2B Taking mobile phone display edge detection as an example, the bright edge boundary has a certain distance (distance_from_CG) from the pixel area. Usually, distance_from_CG is related to the width of the ink area of the screen sample. Distance_from_CG can be set as an adjustable parameter to cope with the differences of different screen samples.
[0146] Then, connect pt1, pt2, pt3, pt4 and pt5, pt6, pt7, pt8 in sequence to form the desired ROI region. Use this ROI region to correct the original ROI region.
[0147] Correction amount explanation: As shown in Figure 2C, when the slope of the bright edge boundary is large (slope K is 1244), the corrected ROI area (e.g.) Figure 2C-1 He Ru Figure 2C-2 The box shown in Figure 1) and the ROI region obtained by the conventional method (e.g.) Figure 2C-1 He Ru Figure 2C-2 The boxes shown in Figure 2) almost overlap. Figure 2C-1 Correction for the ROI region at the upper boundary. Figure 2C-2The correction is applied to the ROI region at the lower boundary. However, as the slope of the bright edge gradually decreases, the correction effect becomes more and more obvious. Figure 2D shows the correction effect of the ROI region with a bright edge slope of 50. Figure 2D-1 This is the corrected map of the ROI region at the upper boundary. Figure 2D-2 The image shows the corrected ROI region at the lower boundary. Figure 2D-1 The correction effect in the ROI area was not obvious, but Figure 2D-2 The ROI area correction effect is significant. Figure 2D-2 The ROI correction rate (correction area / ROI area) can reach 25%.
[0148] Similarly, when the bright edge tilt is not high, but the bright edge of the line scan image is wavy due to vibration or other reasons, the ROI area obtained using conventional methods (such as...) Figure 2E The boundary of box 2) will be offset to the left, such as Figure 2E As shown, although the slope of the bright edge is 4000 at this time, the ROI region obtained by this method (such as...) Figure 2E The box 1) also has good correction results.
[0149] It should be noted that the method in this embodiment can be executed by a single device, such as a computer or server. The method can also be applied in a distributed scenario, where multiple devices cooperate to complete the task. In such a distributed scenario, one of these devices may execute only one or more steps of the method in this embodiment, and the multiple devices will interact with each other to complete the method described.
[0150] It should be noted that the above description describes some embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in a different order than that shown in the above embodiments and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0151] Based on the same inventive concept, corresponding to any of the above embodiments, this application also provides an image processing apparatus.
[0152] refer to Figure 3 The device includes:
[0153] The acquisition module 31 is configured to acquire an image to be processed, the image to be processed including: a first region and a second region, the first region being located at the edge of the second region, and the brightness of the first region being greater than the brightness of the second region;
[0154] The region determination module 32 is configured to determine the range of a first region corresponding to the first region in the image to be processed;
[0155] Boundary determination module 33 is configured to determine the boundary of the first region based on the range of the first region;
[0156] The region of interest determination module 34 is configured to locate the corner of the image to be processed based on the boundary of the first region, and use the location result to determine the region of interest corresponding to the image to be processed.
[0157] In some embodiments, the region determination module 32 includes:
[0158] The binarization processing unit is configured to perform binarization processing on each pixel in the image to be processed using a binarization algorithm to obtain a binarized image. The grayscale values of each pixel in the binarized image include: a first value and a second value.
[0159] The range determination unit is configured to determine at least one region range in the binarized image whose grayscale value is the first value;
[0160] The first region range determination unit is configured to determine a region range whose area exceeds a predetermined area value from the at least one region range as the first region range.
[0161] In some embodiments, the region determination module 32 further includes:
[0162] The image reconstruction unit is configured to construct a first image with the same size as the image to be processed and a grayscale value of a third value, wherein the third value is different from the first value; and to integrate a first region range in the binarized image with the first image to obtain a new image, wherein the new image includes the first region range.
[0163] In some embodiments, the boundary determination module 33 includes:
[0164] The equal division processing unit is configured to perform equal division processing on the image to be processed to obtain multiple equal division images, and to determine the sub-bound rectangle of the first region range in each equal division image to obtain multiple sub-bound rectangles.
[0165] The boundary point determination unit is configured to determine the boundary points of each of the sub-boundary rectangles, thereby obtaining multiple boundary points;
[0166] The boundary determination unit is configured to perform fitting processing on the plurality of boundary points using a fitting function to obtain the boundary of the first region.
[0167] In some embodiments, the equal division processing unit is further configured to:
[0168] A parent coordinate system for the image to be processed is constructed. The image to be processed is divided into multiple equally divided images according to its coordinate values in the parent coordinate system. The vertical axis value of each equally divided image is less than or equal to the maximum vertical axis value of the first region. A corresponding sub-coordinate system is reconstructed for each equally divided image, and the sub-boundary rectangle of the first region in the equally divided image corresponding to the sub-coordinate system is determined according to the sub-coordinate system. The coordinate values of each sub-boundary rectangle determined according to the sub-coordinate system are determined in the parent coordinate system according to the correspondence between the sub-coordinate system and the parent coordinate system.
[0169] In some embodiments, the boundary determination unit includes:
[0170] The boundary point coordinate determination subunit is configured to determine the coordinates of each of the boundary points based on the parent coordinate system of the constructed image to be processed;
[0171] The line fitting subunit is configured to perform line fitting processing on the coordinates of each of the boundary points using a line fitting function to obtain a fitted line, and determine the boundary of the first region based on the fitted line.
[0172] In some embodiments, the line fitting subunit is further configured as follows:
[0173] Determine the bounding rectangle of the first region, and obtain the ordinate rec1.y of the bounding rectangle in the parent coordinate system, and the height rec1.height of the bounding rectangle;
[0174] Calculate the slope K of the fitted line;
[0175] Determine the x-coordinate point0.x of the intersection point of the fitted line with the x-axis of the parent coordinate system and the y-coordinate point0.y of the intersection point with the y-axis of the parent coordinate system;
[0176] Calculate the ordinate of the first endpoint of the first region: point1.y = rec1.y - Δy, where Δy is the boundary offset;
[0177] Calculate the x-coordinate of the first endpoint: point1.x = (point1.y - point0.y) / K + point0.x;
[0178] Calculate the ordinate of the second endpoint of the first region: point2.y = rec1.y + rec1.height + Δy;
[0179] Calculate the x-coordinate of the second endpoint: point2.x = (point2.y - point0.y) / K + point0.x;
[0180] The boundary of the first region is determined based on the coordinates of the first endpoint and the coordinates of the second endpoint.
[0181] In some embodiments, the region of interest determination module 34 includes:
[0182] The corner positioning unit is configured to determine the corner positions of at least four corners of the image to be processed based on the boundary of the first region, the at least four corners including: a first corner and a second corner at one end of the image to be processed, and a third corner and a fourth corner at the other end of the image to be processed;
[0183] The connection unit is configured to connect at least four of the corner positions in a predetermined connection manner to obtain the region of interest.
[0184] In some embodiments, the first corner includes at least two endpoints as endpoint pt1 and endpoint pt2, the second corner includes at least two endpoints as endpoint pt3 and endpoint pt4, the third corner includes at least two endpoints as endpoint pt5 and endpoint pt6, and the fourth corner includes at least two endpoints as endpoint pt7 and endpoint pt8.
[0185] The corner positioning unit is also configured as follows:
[0186] Determine the width W and height H of the pixel region corresponding to the corner of the image to be processed, wherein the pixel region is inside the second region;
[0187] Calculate the x-coordinate of endpoint pt1: pt1.x = point1.x + D, where D is the distance between the outer edge of the first region and the pixel region;
[0188] Calculate the ordinate of endpoint pt1: pt1.y = (pt1.x - point1.x) / K + point1.y;
[0189] Calculate the ordinate of endpoint pt2: pt2.y = pt1.y + H;
[0190] Calculate the x-coordinate of endpoint pt2: pt2.x = (pt2.y - pt1.y) / K + pt1.x;
[0191] Calculate the x-coordinate of endpoint pt3: pt3.x = pt2.x + W;
[0192] Calculate the ordinate of endpoint pt3: pt3.y = (pt2.x - pt3.x) / K + pt2.y;
[0193] Calculate the ordinate of endpoint pt4: pt4.y = pt3.yH;
[0194] Calculate the x-coordinate of endpoint pt4: pt4.x = (pt3.y - pt4.y) / K + pt3.x;
[0195] Calculate the x-coordinate of endpoint pt5 as point2.x+D
[0196] Calculate the ordinate of endpoint pt5: pt5.y = (pt5.x - point2.x) / K + point2.y;
[0197] Calculate the ordinate of endpoint pt6: pt6.y = pt5.yH;
[0198] Calculate the x-coordinate of endpoint pt6: pt6.x = (pt6.y - pt5.y) / K + pt5.x;
[0199] Calculate the x-coordinate of endpoint pt7: pt7.x = pt6.x + W;
[0200] Calculate the ordinate of endpoint pt7: pt7.y = (pt6.x - pt7.x) / K + pt6.y;
[0201] Calculate the ordinate of endpoint pt8: pt4.y = pt7.y + H;
[0202] Calculate the x-coordinate of endpoint pt8: pt8.x = (pt7.y - pt8.y) / K + pt7.x;
[0203] The connection unit is also configured as follows:
[0204] The region of interest is obtained by sequentially connecting the endpoints pt1, pt2, pt3 and pt4, and sequentially connecting the endpoints pt5, pt6, pt7 and pt8.
[0205] For ease of description, the above devices are described in terms of function, divided into various modules. Of course, in implementing this application, the functions of each module can be implemented in one or more software and / or hardware.
[0206] The apparatus of the above embodiments is used to implement the corresponding method in any of the foregoing embodiments and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0207] Based on the same inventive concept, corresponding to the methods of any of the above embodiments, this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the methods described in any of the above embodiments.
[0208] Figure 4 This embodiment illustrates a more specific hardware structure of an electronic device, which may include a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, memory 1020, input / output interface 1030, and communication interface 1040 are interconnected internally via the bus 1050.
[0209] The processor 1010 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0210] The memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program code is stored in the memory 1020 and is called and executed by the processor 1010.
[0211] The input / output interface 1030 is used to connect input / output modules to realize information input and output. Input / output modules can be configured as components within the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touchscreens, microphones, various sensors, etc., while output devices may include displays, speakers, vibrators, indicator lights, etc.
[0212] The communication interface 1040 is used to connect a communication module (not shown in the figure) to enable communication between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0213] Bus 1050 includes a pathway for transmitting information between various components of the device, such as processor 1010, memory 1020, input / output interface 1030, and communication interface 1040.
[0214] It should be noted that although the above-described device only shows the processor 1010, memory 1020, input / output interface 1030, communication interface 1040, and bus 1050, in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the embodiments of this specification, and not necessarily all the components shown in the figures.
[0215] The electronic devices described above are used to implement the corresponding methods in any of the foregoing embodiments and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0216] Based on the same inventive concept, corresponding to the methods of any of the above embodiments, this application also provides a non-transitory computer-readable storage medium that stores computer instructions for causing the computer to perform the methods described in any of the above embodiments.
[0217] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.
[0218] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to perform the methods described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0219] Based on the same inventive concept, corresponding to the methods of any of the above embodiments, this disclosure also provides a computer program product, which includes a computer program. In some embodiments, the computer program is executable by one or more processors to cause the processors to perform the method. Corresponding to the execution entity for each step in each embodiment of the method, the processor performing the corresponding step may belong to the corresponding execution entity.
[0220] The computer program products of the above embodiments are used to cause a processor to execute the methods described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0221] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of this application (including the claims) is limited to these examples; within the framework of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of the embodiments of this application as described above, which are not provided in the details for the sake of brevity.
[0222] Additionally, to simplify the description and discussion, and to avoid obscuring the embodiments of this application, the well-known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided drawings. Furthermore, the apparatus may be shown in block diagram form to avoid obscuring the embodiments of this application, and this also takes into account the fact that the details of the implementation of these block diagram apparatuses are highly dependent on the platform on which the embodiments of this application will be implemented (i.e., these details should be fully understood by those skilled in the art). While specific details (e.g., circuits) have been set forth to describe exemplary embodiments of this application, it will be apparent to those skilled in the art that the embodiments of this application can be implemented without these specific details or with variations thereof. Therefore, these descriptions should be considered illustrative rather than restrictive.
[0223] Although this application has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may be used with the embodiments discussed.
[0224] The embodiments of this application are intended to cover all such substitutions, modifications, and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the embodiments of this application should be included within the protection scope of this application.
Claims
1. An image processing method, comprising: obtaining a to-be-processed image, the to-be-processed image comprising a first region and a second region, the first region being located at an edge of the second region, the first region having a brightness greater than that of the second region, wherein the first region highlights the edge of the second region in the to-be-processed image, and the brightness of the second region is displayed according to a normal display mode of the to-be-processed image; determining a first region range corresponding to the first region in the to-be-processed image; determining a first region boundary according to the first region range; positioning a corner of the to-be-processed image according to the first region boundary, and determining a region of interest corresponding to the to-be-processed image by using a positioning result.
2. The method of claim 1, wherein, The determination of the first region range corresponding to the first region in the to-be-processed image comprises: performing binaryzation processing on each pixel in the to-be-processed image by using a binaryzation algorithm to obtain a binaryzation processing image, the gray scale value of each pixel in the binaryzation processing image comprising a first value and a second value; determining at least one region range in the binaryzation processing image with the gray scale value being the first value; determining, from the at least one region range, a region range with an area exceeding a predetermined area value as the first region range.
3. The method of claim 2, wherein, After the region range with the area exceeding the predetermined area value is determined from the at least one region range as the first region range, the method further comprises: constructing a first image with the same size as the to-be-processed image and a gray scale value being a third value, the third value being different from the first value; integrating the first region range in the binaryzation processing image with the first image to obtain a newly constructed image, the newly constructed image comprising the first region range.
4. The method of claim 1, wherein, The determination of the first region boundary according to the first region range comprises: performing equal division processing on the to-be-processed image to obtain a plurality of equal division images, determining a sub-enclosing rectangle of the first region range in each equal division image to obtain a plurality of sub-enclosing rectangles; determining boundary points of each sub-enclosing rectangle to obtain a plurality of boundary points; performing fitting processing on the plurality of boundary points by using a fitting function to obtain the first region boundary.
5. The method of claim 4, wherein, The equal division processing on the to-be-processed image to obtain a plurality of equal division images, the determination of a sub-enclosing rectangle of the first region range in each equal division image to obtain a plurality of sub-enclosing rectangles, comprises: constructing a parent coordinate system of the to-be-processed image, performing equal division processing on the to-be-processed image according to coordinate values of the to-be-processed image in the parent coordinate system to obtain a plurality of equal division images, the vertical axis value of each equal division image being less than or equal to the maximum vertical axis value of the first region range; reconstructing a corresponding sub-coordinate system for each equal division image, and determining a sub-enclosing rectangle of the first region range in the equal division image corresponding to the sub-coordinate system according to the sub-coordinate system; determining the coordinate values of each sub-enclosing rectangle in the parent coordinate system according to the corresponding relationship between the sub-coordinate system and the parent coordinate system.
6. The method of claim 4 or 5, wherein, The fitting processing on the plurality of boundary points by using a fitting function to obtain the first region boundary comprises: Determine coordinates of each of the boundary points according to the parent coordinate system of the to-be-processed image constructed; Determine the first region boundary according to the fitting straight line by performing straight line fitting processing on the coordinates of each of the boundary points through a straight line fitting function.
7. The method of claim 6, wherein, The determination of the first region boundary according to the fitting straight line comprises: Determine an outer rectangle of the first region range, and obtain a longitudinal coordinate rec1.y of the outer rectangle in the parent coordinate system and a height rec1.height of the outer rectangle; Calculate a slope K of the fitting straight line; Determine a horizontal coordinate point0.x of an intersection point of the fitting straight line and a horizontal axis of the parent coordinate system and a longitudinal coordinate point0.y of an intersection point of the fitting straight line and a longitudinal axis of the parent coordinate system; Calculate a longitudinal coordinate point1.y of a first end point of the first region range: point1.y = rec1.y - Δy, where Δy is a boundary offset; Calculate a horizontal coordinate point1.x of the first end point: point1.x = (point1.y - point0.y) / K + point0.x; Calculate a longitudinal coordinate point2.y of a second end point of the first region range: point2.y = rec1.y + rec1.height + Δy; Calculate a horizontal coordinate point2.x of the second end point: point2.x = (point2.y - point0.y) / K + point0.x; Determine the first region boundary according to the coordinates of the first end point and the coordinates of the second end point.
8. The method of claim 7, wherein, The positioning of the corners of the to-be-processed image according to the first region boundary and the determination of the region of interest corresponding to the to-be-processed image according to the positioning result comprise: Determine corner positions of at least four corners of the to-be-processed image according to the first region boundary, wherein the at least four corners comprise a first corner and a second corner at one end of the to-be-processed image and a third corner and a fourth corner at the other end of the to-be-processed image; Connect the at least four corner positions in a predetermined connection manner to obtain the region of interest.
9. The method of claim 8, wherein, The first corner comprises at least two end points, namely an end point pt1 and an end point pt2, the second corner comprises at least two end points, namely an end point pt3 and an end point pt4, the third corner comprises at least two end points, namely an end point pt5 and an end point pt6, and the fourth corner comprises at least two end points, namely an end point pt7 and an end point pt8. The determination of the corner positions of the at least four corners of the to-be-processed image according to the first region boundary comprises: Determine a width W and a height H of a pixel area corresponding to the corner of the to-be-processed image, wherein the pixel area is inside the second region; Calculate a horizontal coordinate pt1.x of the end point pt1: pt1.x = point1.x + D, where D is a distance between an outer side edge of the first region and the pixel area; Calculate a longitudinal coordinate pt1.y of the end point pt1: pt1.y = (pt1.x - point1.x) / K + point1.y; Calculate a longitudinal coordinate pt2.y of the end point pt2: pt2.y = pt1.y + H; Calculate a horizontal coordinate pt2.x of the end point pt2: pt2.x = (pt2.y - pt1.y) / K + pt1.x; calculating the horizontal coordinate of the endpoint pt3, pt3.x = pt2.x + W; calculating the vertical coordinate of the endpoint pt3, pt3.y = (pt2.x - pt3.x) / K + pt2.y; calculating the vertical coordinate of the endpoint pt4, pt4.y = pt3.y - H; calculating the horizontal coordinate of the endpoint pt4, pt4.x = (pt3.y - pt4.y) / K + pt3.x; calculating the horizontal coordinate of the endpoint pt5, pt5.x = point2.x + D; calculating the vertical coordinate of the endpoint pt5, pt5.y = (pt5.x - point2.x) / K + point2.y; calculating the vertical coordinate of the endpoint pt6, pt6.y = pt5.y - H; calculating the horizontal coordinate of the endpoint pt6, pt6.x = (pt6.y - pt5.y) / K + pt5.x; calculating the horizontal coordinate of the endpoint pt7, pt7.x = pt6.x + W; calculating the vertical coordinate of the endpoint pt7, pt7.y = (pt6.x - pt7.x) / K + pt6.y; calculating the vertical coordinate of the endpoint pt8, pt8.y = pt7.y + H; calculating the horizontal coordinate of the endpoint pt8, pt8.x = (pt7.y - pt8.y) / K + pt7.x; the connecting of the at least four corner positions in a predetermined connection mode to obtain the region of interest, comprising: connecting the endpoint pt1, the endpoint pt2, the endpoint pt3 and the endpoint pt4 in sequence, and connecting the endpoint pt5, the endpoint pt6, the endpoint pt7 and the endpoint pt8 in sequence to obtain the region of interest. 10.An image processing apparatus, comprising: an acquisition module configured to acquire a to-be-processed image, the to-be-processed image comprising a first region and a second region, the first region being located at an edge of the second region, and the first region having a brightness greater than that of the second region, wherein the first region highlights the edge of the second region in the to-be-processed image, and the brightness of the second region is displayed according to a normal display mode of the to-be-processed image; a region determination module configured to determine a first region range corresponding to the first region in the to-be-processed image; a boundary determination module configured to determine a first region boundary according to the first region range; a region of interest determination module configured to locate a corner of the to-be-processed image according to the first region boundary, and determine a region of interest corresponding to the to-be-processed image by using a locating result.
11. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein, The processor implements the method of any one of claims 1-9 when executing the program.
12. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to make the computer execute the method of any one of claims 1-9. 13.A computer program product, comprising computer program instructions which, when executed on a computer, cause the computer to perform the method of any one of claims 1-9.
Citation Information
Patent Citations
Screen visual positioning method and positioning equipment and storage medium
CN111563883A
Applying corrections to regions of interest in image data
US9659355B1