Image Edge Padding Method and Device
By using edge pixel normals to fill image edges, the method reduces computational complexity and improves efficiency in image edge filling processes.
Patent Information
- Application Number
- CN202210449831.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-27
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2042-04-27
AI Technical Summary
In the prior art, the image edge filling method requires calculating the distance between each pixel point in the image to the edge, resulting in a high time complexity.
By determining that the edge pixel points are based on the tangent and normals of the image edge, the image edge is filled with normals to reduce the calculation amount.
Reduces the time complexity of image edge filling, improves filling efficiency, and improves filling effect.
Smart Images

Figure CN114913193B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to an image edge filling method and apparatus. Background Art
[0002] In the prior art, the filling area is determined in sequence by calculating the distance between each pixel point in the image and the edge, and the image edge is filled to achieve the edge tracing effect of regular or irregular image edges. This method of image edge filling requires calculating the distance from each pixel point in the image to the edge, and the time complexity required for the calculation is relatively high. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide an image edge filling method and apparatus, which can reduce the amount of calculation in the process of image edge filling and reduce the time complexity of image edge filling by using edge pixel points to expand the image based on the normal line of the image edge.
[0004] In a first aspect, an embodiment of the present invention provides an image edge filling method, including:
[0005] Obtain an original image and determine the image edge of the original image;
[0006] For an edge pixel point in the image edge: determine the tangent of the edge pixel point based on the image edge; determine the normal line of the edge pixel point based on the image edge according to the tangent; use the normal line to perform filling processing on the image edge;
[0007] Determine a supplementary filling area on the image edge after the filling processing, and perform supplementary filling processing on the supplementary filling area.
[0008] Optionally, the determining the image edge of the original image includes:
[0009] Determine the transparency channel value of the original image;
[0010] Construct an edge convolution kernel according to the transparency channel value;
[0011] Use the edge convolution kernel to perform convolution processing on the original image to determine the image edge of the original image.
[0012] Optionally, the determining the tangent of the edge pixel point based on the image edge includes:
[0013] In the image edge, determine a first adjacent pixel point and a second adjacent pixel point of the edge pixel point, and the edge pixel point is located between the first adjacent pixel point and the second adjacent pixel point;
[0014] Based on the first adjacent pixel and the second adjacent pixel, determine the tangent line of the edge pixel based on the image edge.
[0015] Optionally, the determining the normal line of the edge pixel based on the image edge according to the tangent line includes:
[0016] According to the tangent line, determine the slope of the normal line of the edge pixel based on the image edge;
[0017] According to the slope of the normal line and the edge pixel, determine the normal line of the edge pixel based on the image edge.
[0018] Optionally, the filling process of the image edge using the normal line includes:
[0019] According to the transparency channel values of the pixels on both sides of the tangent line in the original image, determine the filling direction;
[0020] According to the filling direction and the filling pixel span, determine at least one pixel point to be filled on the normal line;
[0021] Set the at least one pixel point to be filled to the filling color.
[0022] Optionally, the determining the supplementary filling area on the image edge after the filling process includes:
[0023] From the at least one pixel point to be filled on the normal line, determine the outer layer pixel points of the edge pixel;
[0024] According to the outer layer pixel points of the edge pixel, determine the boundary of the supplementary filling area of the original image;
[0025] According to the boundary of the supplementary filling area and the image edge, determine the supplementary filling area.
[0026] Optionally, the determining the boundary of the supplementary filling area of the original image according to the outer layer pixel points of the edge pixel includes:
[0027] Determine the outer layer pixel points of the current edge pixel;
[0028] Determine the outer layer pixel points of the previous edge pixel of the current edge pixel;
[0029] Determine whether the outer layer pixel points of the current edge pixel and the outer layer pixel points of the previous edge pixel are adjacent;
[0030] In the case where the outer pixels of the current edge pixel are not adjacent to the outer pixels of the previous edge pixel, determine the connecting line pixels between the outer pixels of the current edge pixel and the outer pixels of the previous edge pixel, and determine the connecting line pixels as the boundary of the filling area.
[0031] Optionally, the filling process for the filling area includes:
[0032] Construct a Gaussian convolution kernel, where the center point of the Gaussian convolution kernel corresponds to the pixel to be filled in the filling area;
[0033] Set the filling color of the pixel to be filled according to the valid color pixels in the filling area corresponding to the Gaussian convolution kernel.
[0034] In a second aspect, an embodiment of the present invention provides an image edge filling device, including:
[0035] An edge determination module, configured to obtain an original image and determine the image edge of the original image;
[0036] A filling module, configured to, for the edge pixels in the image edge: determine the tangent of the edge pixel based on the image edge; determine the normal of the edge pixel based on the tangent; and use the normal to perform a filling process on the image edge;
[0037] A filling supplement module, configured to determine a filling area on the image edge after the filling process and perform a filling process on the filling area.
[0038] In a third aspect, an embodiment of the present invention provides an electronic device, including:
[0039] One or more processors;
[0040] A storage device, configured to store one or more programs,
[0041] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.
[0042] In a fourth aspect, an embodiment of the present invention provides a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, the method described in any of the above embodiments is implemented.
[0043] One embodiment of the above invention has the following advantages or beneficial effects: determining the image edge of the original image, determining the edge pixel points in the image edge based on the tangent of the image edge, further determining the normal of the edge pixel point based on the image edge, and using the normal to perform filling processing on the image edge. Compared with the method of calculating the distance from each pixel point in the image to the image edge for edge filling, it can reduce the calculation amount in the process of image edge filling, improve the efficiency of the image edge filling process, and reduce the time complexity of image edge filling.
[0044] In addition, after performing filling processing on the image edge, determining the supplementary filling area on the image edge after filling processing and performing supplementary filling processing on the supplementary filling area can make the effect of image edge filling better.
[0045] The further effects of the above non-conventional optional manner will be described below in combination with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention. Among them:
[0047] Figure 1 is a schematic diagram of the flow of an image edge filling method provided by an embodiment of the present invention;
[0048] Figure 2 is a schematic diagram of the flow of an image edge detection implemented by performing convolution processing on an image provided by an embodiment of the present invention;
[0049] Figure 3 is a schematic diagram of the image edge obtained by the method provided by the embodiment of the present invention;
[0050] Figure 4 is a schematic diagram of the architecture of an image edge filling system provided by an embodiment of the present invention;
[0051] Figure 5a is a schematic diagram of the process of determining the normal of an edge pixel point provided by an embodiment of the present invention;
[0052] Figure 5b is a schematic diagram of determining the normal of an edge pixel point by using two adjacent pixel points provided by an embodiment of the present invention;
[0053] Figure 6 is a schematic diagram of the effect of image edge filling by applying the image edge filling method provided by the embodiment of the present invention;
[0054] Figure 7 is a schematic diagram of the structure of an image edge filling device provided by an embodiment of the present invention;
[0055] Figure 8 It is a schematic structural diagram of a computer system of a terminal device or a server suitable for implementing the embodiments of the present invention. Detailed implementation manners
[0056] The following describes exemplary embodiments of the present invention with reference to the accompanying drawings. Various details of the embodiments of the present invention are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0057] The embodiments of the present invention provide an image edge filling method, which is mainly used to expand an image of regular or irregular transparent edges by using edge colors or specified colors. The method of the embodiments of the present invention can also be implemented based on a GPU (graphics processing unit) to utilize the hardware acceleration of the graphics card to achieve parallel processing of algorithms and improve processing efficiency. Figure 1 It is a schematic diagram of the process of an image edge filling method provided by an embodiment of the present invention. As Figure 1 shown, the method includes:
[0058] Step 101: Obtain an original image and determine the image edge of the original image.
[0059] Step 101 can be used to detect the transparent edge of an image. Through the transparent edge feature, a suitable edge convolution kernel is constructed to perform convolution on the image to detect the transparent edge and generate a texture with only the edge. The detection of the transparent edge of the image can be achieved by performing convolution processing on the image. Figure 2 It is a schematic diagram of the process of implementing image edge detection by performing convolution processing on an image provided by an embodiment of the present invention. As Figure 2 shown, first determine the transparent channel value of the original image; according to the transparent channel value, construct an edge convolution kernel; use the edge convolution kernel to perform convolution processing on the original image to determine the image edge of the original image.
[0060] The transparent channel can also be referred to as the A channel, Alpha channel, etc. According to the characteristics of the transparent edge of the image, when the original image has a transparent channel, the original image contains four pixel channels of RGBA (R red, G green, B blue, and A transparent). The value of the transparent pixel point corresponding to the A (Alpha) channel is 0, and the value of the opaque pixel point is 255. An edge convolution kernel is constructed using the A channel and convolution is performed on the entire original image to generate the image edge of the original image.
[0061] For a 3x3 edge convolution kernel, the following conditions need to be met:
[0062]
[0063] Among them, i and j are the coordinates of the edge convolution kernel. For a 3x3 edge convolution kernel, there are a total of 9 elements, (i, j = 0), (i, j = 1)... (i, j = 8), where (i, j = 4) is the center point of the edge convolution kernel. f(i, j) is the value of the edge convolution kernel corresponding to the coordinate, A is the value of the transparency channel, and n is the size of the convolution kernel. For a 3x3 edge convolution kernel, n is 9.
[0064] It should be noted that edge convolution kernels with dimensions such as 2x2, 4x4, and 5x5 can also be constructed to generate image edges. However, a 2x2 edge convolution kernel cannot determine whether the current pixel point is located on the image edge at one time and requires multiple convolution processes to determine the image edge. For edge convolution kernels with dimensions such as 4x4 and 5x5, although they can satisfy the determination of whether the current pixel point is located on the image edge at one time, unnecessary calculations are added during the convolution process compared to a 3x3 edge convolution kernel.
[0065] Through the convolution calculation of the original image, the transparent image edge of the original image is obtained and generated into a GPU texture map for use in step 102. Figure 3 It is a schematic diagram of obtaining the image edge by the method provided in the embodiment of the present invention. As Figure 3 shown, Figure 3 The left figure is the original image, Figure 3 The right figure is the texture map containing the transparent edge obtained by performing convolution processing on the original image using the edge convolution kernel.
[0066] As Figure 3 shown, according to the image edge obtained in step 101, a texture map of the original image is generated. The texture map stores a single continuous image edge. Assuming that multiple continuous edge pixel points on the image edge are regarded as a continuous curve, by obtaining the tangent of a certain point on the curve and then finding the corresponding normal according to the tangent, the image edge can be filled outward or inward with this normal and the edge pixel points. Step 102: For the edge pixel points in the image edge: determine the tangent of the edge pixel point based on the image edge; determine the normal of the edge pixel point based on the tangent; use the normal to perform filling processing on the image edge.
[0067] A texture map of the original image can be generated according to the image edge obtained in step 101. The texture map stores a single continuous image edge. Connect all the edge pixel points, obtain the tangent of each edge pixel point on the curve, so as to obtain the normal passing through this edge pixel point, and use this normal and the edge pixel point to expand the image with an outward normal vector or an inward normal vector.
[0068] Determine each edge pixel point in the image edge based on the tangent of the image edge; then, according to the tangent, determine the slope of the edge pixel point based on the normal of the image edge; according to the slope of the normal and the edge pixel point, determine the normal of the edge pixel point based on the image edge. Select at least one continuous pixel point on the normal corresponding to the edge pixel point, and set these pixel points to the filling color to implement the filling process of the image edge. The filling color can be a pre-specified color, or the filling color can be determined according to the RGBA value of the current edge pixel point.
[0069] Step 103: Determine the supplementary filling area on the image edge after the filling process, and perform supplementary filling processing on the supplementary filling area.
[0070] After the original image is filled through Step 102, there may be some pixel points on the image edge after the filling process that are not covered by filling. To improve the effect of image edge filling, after the image edge is filled, determine the supplementary filling area on the image edge after the filling process, and perform supplementary filling processing on the supplementary filling area. Specifically, perform convolution on the supplementary filling area to find the pixel points to be filled, and fill the pixel points to be filled according to the surrounding pixel points.
[0071] In the embodiment of the present invention, determine the image edge of the original image, determine the edge pixel point in the image edge based on the tangent of the image edge, and then determine the normal of the edge pixel point based on the image edge, and use the normal to perform filling processing on the image edge. Compared with the method of calculating the distance from each pixel point in the image to the image edge for edge filling, it can reduce the calculation amount in the process of image edge filling, improve the efficiency of the image edge filling process, and reduce the time complexity of image edge filling.
[0072] Figure 4 It is a schematic diagram of the architecture of an image edge filling system provided by an embodiment of the present invention. As Figure 4 shown, the image edge filling system of the embodiment of the present invention mainly includes three processing stages: transparent edge detection, edge normal filling, and pixel completion.
[0073] Stage 1, transparent edge detection. In this stage, mainly detect the transparent edge of the image, construct a suitable convolution kernel according to the transparent edge feature to perform convolution on the image, detect the transparent edge, and generate a texture with only edges.
[0074] Stage 2, normal filling. According to the output of Stage 1, the texture stores a single continuous edge image. Link all continuous pixel points, obtain the tangent of each pixel point on the curve, so as to obtain the normal passing through this pixel point, and expand the image with this normal and the pixel point for the outward normal vector or the inward normal vector.
[0075] In the third stage, pixel completion is performed. In the area where the normal vectors are extended in the second stage, there are pixel points that are not fully covered. These are completed by convolving the filled area to find the unfilled pixel points and filling them based on the surrounding pixels.
[0076] The edge pixel points based on the tangent of the image edge can be determined in the following way: In the image edge, determine the first adjacent pixel point and the second adjacent pixel point of the edge pixel point, where the edge pixel point is located between the first adjacent pixel point and the second adjacent pixel point; based on the first adjacent pixel point and the second adjacent pixel point, determine the tangent of the edge pixel point based on the image edge.
[0077] Both the first adjacent pixel point and the second adjacent pixel point are pixel points in the image edge. On the image edge, the first adjacent pixel point and the second adjacent pixel point are on both sides of the edge pixel point. The line passing through the first adjacent pixel point and the second adjacent pixel point is used as the tangent of the edge pixel point.
[0078] The pixel data corresponding to the edge pixel points is discrete. The normal vector of the edge pixel point can be determined by two edge pixel points adjacent to the edge pixel point on the image edge. Specifically, the vector determined by the coordinates of the two adjacent pixel points of the edge pixel point approximates the tangent direction of the edge pixel point in the image edge, and then the normal vector passing through the edge pixel point can be obtained.
[0079] After determining the normal vector of the edge pixel point, determine the filling direction according to the transparency channel values of the pixel points on both sides of the tangent of the original image; determine at least one pixel point to be filled on the normal vector according to the filling direction and the filling pixel span; set the at least one pixel point to be filled to the filling color to complete the filling of the image edge.
[0080] As an implementable manner, the first adjacent pixel point and the second adjacent pixel point can be the two pixel points on the image edge closest to the edge pixel point to make the determined tangent more accurate. The transparent image edge of the original image consists of continuous single pixel points. The normal vector of the edge pixel point is confirmed using the "nine - grid", and the specific steps are as follows:
[0081] Step S1: Figure 5a is a schematic diagram of the process for determining the normal vector of an edge pixel point provided by an embodiment of the present invention. As Figure 5a shown, for the original image containing the image edge, a Cartesian coordinate system is constructed, and the coordinates of the pixel point in the coordinate system are determined according to the position of the pixel point in the image.
[0082] Step S2: Take the coordinates of the edge pixel point whose normal vector needs to be determined currently as the central coordinates (x center , ycenter ).
[0083] Step S3: Figure 5b It is a schematic diagram of determining the normal line of an edge pixel using two adjacent pixel points provided by an embodiment of the present invention. As Figure 5b shown, the image edge is a continuous single pixel point. The coordinate positions (x0, y0) and (x1, y1) of the first adjacent pixel point and the second adjacent pixel point adjacent to the current edge pixel point can be determined through the "nine-square grid".
[0084] Step S4: The two coordinates (x0, y0) and (x1, y1) determine the approximate tangent direction of the current edge pixel point, and accordingly determine the normal line and the corresponding slope k of the current edge pixel point. The calculation formula of the slope k is as follows:
[0085]
[0086] Step S5: Determine the filling direction according to the normal line and the A-channel values of each pixel point on both sides of the tangent line in the current image.
[0087] As Figure 5b shown, the A-channel values of the pixel points inside and outside the image edge are different, so the direction of the normal line pointing to the outside of the edge can be determined as the filling direction. Figure 5b The arrow direction in
[0088] is the filling direction.
[0089] According to the required effect, the RGBA value of the current edge pixel point can be selected as the RGBA value of the pixel point to be filled, or a specified color can be used as the filling color.
[0090] Taking the current edge pixel point as the starting point, according to the determined filling direction, a preset number of pixel points to be filled are determined on the normal line of the current edge pixel point. The preset number is the filling pixel span. As an implementable manner, for regular or irregular image edges, the pixel points to be filled can meet the following conditions:
[0091]
[0092] where x and y are the coordinates of the pixel points to be filled, and n is the filling pixel span (the number of pixel points to be filled determined on each normal line). The " " in the formula is determined by the normal line direction and the coordinate system quadrant.
[0093] In the edge region filled by the normal line, there are pixel points that are not completely covered, and these pixel points are filled in. Convolve the filled region to find the unfilled pixel points, and fill them according to the surrounding pixels or a specified color.
[0094] The supplementary filling region on the image edge after the filling process can be determined in the following way: From at least one pixel point to be filled on the normal line, determine the outer-layer pixel points of the edge pixel points; according to the outer-layer pixel points of the edge pixel points, determine the boundary of the supplementary filling region of the original image; according to the boundary of the supplementary filling region and the image edge, determine the supplementary filling region. Among at least one pixel point to be filled on the normal line, along the filling direction, the outermost pixel point to be filled is the outer-layer pixel point of the edge pixel point.
[0095] The boundary of the supplementary filling region can be determined in the following way: Determine the outer-layer pixel points of the current edge pixel point; determine the outer-layer pixel points of the previous edge pixel point of the current edge pixel point; determine whether the outer-layer pixel points of the current edge pixel point and the outer-layer pixel points of the previous edge pixel point are adjacent; in the case where the outer-layer pixel points of the current edge pixel point and the outer-layer pixel points of the previous edge pixel point are not adjacent, determine the connecting line pixel points between the outer-layer pixel points of the current edge pixel point and the outer-layer pixel points of the previous edge pixel point, and determine the connecting line pixel points as the boundary of the supplementary filling region.
[0096] During the process of filling the image edge using the normal line, record all pixel points of the filling region boundary, including: Determine the outer-layer pixel points of the normal line filling of the previous edge pixel point and the outer-layer pixel points of the normal line filling of the current edge pixel point, judge whether the two pixel points are adjacent in the coordinate system, if not adjacent, calculate the connecting line pixel points between the two pixel points, and save the connecting line pixel points as the filling region boundary.
[0097] Determine the supplementary filling region according to the boundary of the supplementary filling region and the image edge. Convolve in the supplementary filling region (image edge and filling region boundary) to perform the supplementary filling process, which can include two situations.
[0098] Situation 1: Determine the supplementary filling color according to the pixel color of the image edge. Take a Gaussian convolution kernel for convolution operation. The center point of the Gaussian convolution kernel corresponds to the pixel point to be filled in the supplementary filling region; set the supplementary filling color of the pixel point to be filled according to the valid color pixel points corresponding to the Gaussian convolution kernel in the supplementary filling region.
[0099] The valid color pixel points are the pixel points with determined colors in the supplementary filling region. Use the sum of the pixel values of each valid color pixel point within the range of the Gaussian convolution kernel multiplied by the weights, and then the normalized value as the pixel value of the pixel point to be filled corresponding to the center point of the Gaussian convolution kernel.
[0100] Case 2: Fill in the supplementary filling area according to the specified color. Just set the pixels to be filled in the supplementary filling area to the specified color.
[0101] The method of the embodiment of the present invention can perform edge filling on regular and irregular transparent edges according to the colors of the image edge pixels; construct a Cartesian coordinate system with the graph, use the "nine-square grid" to determine the normal of the edge pixels, and complete the filling of the image edge using the normal.
[0102] Figure 6 It is a schematic diagram of the effect of performing image edge filling using the image edge filling method provided by the embodiment of the present invention. As Figure 6 shown, the first image is the original image. The second image is the effect diagram after filling the edge of the original image using the normal of the edge pixels. It can be seen that there are some discontinuous points in the image edge of the second image. The third image is the effect diagram after filling the supplementary filling area on the edge of the image after filling processing. Among them, the filling pixel span is taken as 3, and both the filling color and the supplementary filling color are the specified color. From Figure 6 it can be seen that applying the image edge filling method provided by the embodiment of the present invention for image edge filling can achieve a good edge filling effect.
[0103] Figure 7 It is a schematic structural diagram of an image edge filling device provided by an embodiment of the present invention. As Figure 7 shown, the device includes:
[0104] An edge determination module 701, configured to obtain an original image and determine the image edge of the original image;
[0105] A filling module 702, configured to, for the edge pixels in the image edge: determine the tangent of the edge pixel based on the image edge; determine the normal of the edge pixel based on the image edge according to the tangent; and use the normal to perform filling processing on the image edge;
[0106] A supplementary filling module 703, configured to determine the supplementary filling area on the image edge after filling processing and perform supplementary filling processing on the supplementary filling area.
[0107] Optionally, the edge determination module 701 is specifically configured to:
[0108] Determine the transparency channel value of the original image;
[0109] Construct an edge convolution kernel according to the transparency channel value;
[0110] Using the edge convolution kernel, perform convolution processing on the original image to determine the image edge of the original image.
[0111] Optionally, the filling module 702 is specifically configured to:
[0112] In the image edge, determine the first adjacent pixel point and the second adjacent pixel point of the edge pixel point, where the edge pixel point is located between the first adjacent pixel point and the second adjacent pixel point;
[0113] According to the first adjacent pixel point and the second adjacent pixel point, determine the tangent line of the edge pixel point based on the image edge.
[0114] Optionally, the filling module 702 is specifically configured to:
[0115] According to the tangent line, determine the slope of the normal line of the edge pixel point based on the image edge;
[0116] According to the slope of the normal line and the edge pixel point, determine the normal line of the edge pixel point based on the image edge.
[0117] Optionally, the filling module 702 is specifically configured to:
[0118] According to the alpha channel values of the pixel points on both sides of the tangent line in the original image, determine the filling direction;
[0119] According to the filling direction and the filling pixel span, determine at least one pixel point to be filled on the normal line;
[0120] Set the at least one pixel point to be filled to the filling color.
[0121] Optionally, the filling-up module 703 is specifically configured to:
[0122] Determine the outer layer pixel points of the edge pixel point from the at least one pixel point to be filled on the normal line;
[0123] According to the outer layer pixel points of the edge pixel point, determine the boundary of the filling-up area of the original image;
[0124] According to the boundary of the filling-up area and the image edge, determine the filling-up area.
[0125] Optionally, the filling-up module 703 is specifically configured to:
[0126] Determine the outer layer pixel points of the current edge pixel point;
[0127] Determine the outer layer pixel points of the previous edge pixel point of the current edge pixel point;
[0128] Determine whether the outer pixels of the current edge pixel are adjacent to the outer pixels of the previous edge pixel;
[0129] In the case where the outer pixels of the current edge pixel are not adjacent to the outer pixels of the previous edge pixel, determine the connecting line pixels between the outer pixels of the current edge pixel and the outer pixels of the previous edge pixel, and determine the connecting line pixels as the boundary of the filling area.
[0130] Optionally, the filling module 703 is specifically configured to:
[0131] Construct a Gaussian convolution kernel, where the center point of the Gaussian convolution kernel corresponds to the pixel to be filled in the filling area;
[0132] Set the filling color of the pixel to be filled according to the valid color pixels in the filling area corresponding to the Gaussian convolution kernel.
[0133] An embodiment of the present invention provides an electronic device, including:
[0134] One or more processors;
[0135] A storage device for storing one or more programs,
[0136] When the one or more programs are executed by the one or more processors, the one or more processors implement the method of any of the above embodiments.
[0137] Next, refer to Figure 8 , which shows a schematic structural diagram of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8 The terminal device shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present invention.
[0138] As Figure 8 shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 802 or the program loaded from the storage section 808 into the random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, ROM 802, and RAM 803 are connected to each other through a bus 804. The input / output (I / O) interface 805 is also connected to the bus 804.
[0139] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as required. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is mounted on the drive 810 as required so that a computer program read therefrom is installed into the storage section 808 as required.
[0140] Specifically, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 809, and / or installed from the removable medium 811. When the computer program is executed by a central processing unit (CPU) 801, the above-described functions defined in the system of the present invention are executed.
[0141] It should be noted that the computer-readable medium shown in the present invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, in which the computer-readable program code is carried. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0142] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the above module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, and the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0143] The modules involved in the embodiments of the present invention can be implemented in software or in hardware. The described modules can also be provided in a processor. For example, they can be described as: an edge determination module, a filling module, and a supplementary filling module. Among them, the names of these modules do not constitute a limitation to the module itself in some cases. For example, the edge determination module can also be described as "a module that acquires an original image and determines the image edge of the original image".
[0144] As another aspect, the present invention also provides a computer-readable medium, which can be included in the device described in the above embodiments; or can exist alone without being assembled into the device. The above computer-readable medium carries one or more programs. When the one or more programs are executed by the device, the device includes:
[0145] Acquire an original image and determine the image edge of the original image;
[0146] For the edge pixel points in the image edge: determine the tangent of the edge pixel point based on the image edge; according to the tangent, determine the normal of the edge pixel point based on the image edge; use the normal to perform a filling process on the image edge;
[0147] Determine the supplementary filling area on the image edge after the filling process, and perform a supplementary filling process on the supplementary filling area.
[0148] According to the technical solution of the embodiments of the present invention, the image edge of the original image is determined, the tangent of the edge pixel point in the image edge based on the image edge is determined, and then the normal of the edge pixel point based on the image edge is determined, and the normal is used to perform a filling process on the image edge. Compared with the method of calculating the distance from each pixel point in the image to the image edge for edge filling, it can reduce the calculation amount in the process of image edge filling, improve the efficiency of the image edge filling process, and reduce the time complexity of image edge filling.
[0149] In addition, after performing a filling process on the image edge, determining the supplementary filling area on the image edge after the filling process and performing a supplementary filling process on the supplementary filling area can make the effect of image edge filling better.
[0150] The above specific embodiments do not constitute a limitation to the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims
1. An image edge filling method, characterized in that, Including: Obtain an original image and determine the image edge of the original image; For the edge pixel points in the image edge: Determine the tangent line of the edge pixel point based on the image edge; According to the tangent line, determine the normal line of the edge pixel point based on the image edge; Use the normal line to perform a filling process on the image edge; The using the normal line to perform a filling process on the image edge includes: Determine a filling direction according to the transparency channel values of the pixel points on both sides of the tangent line of the original image; Determine at least one pixel point to be filled on the normal line according to the filling direction and the filling pixel span; Set the at least one pixel point to be filled to a filling color; Determine a supplementary filling area on the image edge after the filling process, and perform a supplementary filling process on the supplementary filling area.
2. The method according to claim 1, wherein The determining the image edge of the original image includes: Determine the transparency channel value of the original image; Construct an edge convolution kernel according to the transparency channel value; Use the edge convolution kernel to perform a convolution process on the original image to determine the image edge of the original image.
3. The method according to claim 1, wherein The determining the tangent line of the edge pixel point based on the image edge includes: In the image edge, determine a first adjacent pixel point and a second adjacent pixel point of the edge pixel point, and the edge pixel point is located between the first adjacent pixel point and the second adjacent pixel point; Determine the tangent line of the edge pixel point based on the image edge according to the first adjacent pixel point and the second adjacent pixel point.
4. The method according to claim 1, wherein The according to the tangent line, determining the normal line of the edge pixel point based on the image edge includes: Determine the slope of the normal line of the edge pixel point based on the image edge according to the tangent line; Determine the normal line of the edge pixel point based on the image edge according to the slope of the normal line and the edge pixel point.
5. The method according to claim 1, characterized in that, The determining the supplementary filling area on the image edge after the filling process includes: Determine the outer layer pixel points of the edge pixel point from at least one pixel point to be filled on the normal line; Determine the boundary of the supplementary filling area of the original image according to the outer layer pixel points of the edge pixel point; Determine the supplementary filling area according to the boundary of the supplementary filling area and the image edge.
6. The method according to claim 5, wherein The according to the outer layer pixel points of the edge pixel point, determining the boundary of the supplementary filling area of the original image includes: Determine the outer layer pixel points of the current edge pixel point; Determine the outer layer pixel points of the previous edge pixel point of the current edge pixel point; Determine whether the outer layer pixel points of the current edge pixel point are adjacent to the outer layer pixel points of the previous edge pixel point; In the case where the outer layer pixel points of the current edge pixel point are not adjacent to the outer layer pixel points of the previous edge pixel point, determine the connecting line pixel points between the outer layer pixel points of the current edge pixel point and the outer layer pixel points of the previous edge pixel point, and determine the connecting line pixel points as the boundary of the supplementary filling area.
7. The method according to claim 1, characterized in that, The performing a supplementary filling process on the supplementary filling area includes: Construct a Gaussian convolution kernel, and the center point of the Gaussian convolution kernel corresponds to the pixel point to be filled in the supplementary filling area; Set the filling color of the pixel to be filled according to the Gaussian convolution kernel corresponding to the valid color pixel points in the filling area.
8. An image edge filling device, characterized in that, Comprising: An edge determination module, configured to obtain an original image and determine the image edge of the original image; A filling module, configured to, for the edge pixel points in the image edge: determine the tangent of the edge pixel points based on the image edge; according to the tangent, determine the normal of the edge pixel points based on the image edge; use the normal to perform filling processing on the image edge; Specifically, the filling module is configured to: determine the filling direction according to the transparency channel values of the pixel points on both sides of the tangent of the original image; determine at least one pixel point to be filled on the normal according to the filling direction and the filling pixel span; set the at least one pixel point to be filled to the filling color; A filling and patching module, configured to determine a patching area on the image edge after filling processing and perform patching processing on the patching area.
9. An electronic device, characterized in that, Comprising: One or more processors; A storage device, configured to store one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-7.
10. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, the method according to any one of claims 1-7 is implemented.
Citation Information
Patent Citations
Method for automatically filling structure information and texture information of hole area of image scene
CN102324102A