Image processing method, device, apparatus, and computer-readable storage medium
By obtaining neck correction parameters and positioning points during the ID photo change process, the problem of poor change effects caused by offset of the neck connection points is solved, achieving higher quality change effects.
Patent Information
- Application Number
- CN202210547209.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-17
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2042-05-17
AI Technical Summary
During the ID photo replacement process, the detection position of the neck connection point is offset, resulting in poor replacement results.
By obtaining the neck correction parameters of the image to be processed, the positioning points of the image to be changed are determined, and the changing operation is performed based on these positioning points, including determining the coordinates of the neck width and chin tip, and using positioning lines and facial area masks to accurately locate the points, reducing errors caused by neck deviation or occlusion.
The dressing effect of the photo is improved, the error between the neck connection point and the actual position is reduced, and the accuracy and quality of the dressing are enhanced.
Smart Images

Figure CN114926323B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to an image processing method, apparatus, device and computer-readable storage medium. Background Art
[0002] In modern society, with the rapid development of science and technology and the rapid popularization of mobile terminals, more and more people's needs have shifted from offline to online. The development of smart phones has met the needs of many users to take and modify various ID photos anytime, anywhere, conveniently and quickly.
[0003] ID photo costume replacement technology primarily uses a method to match the collar position of the clothing material with the neck position of the portrait, or to replace the portrait's neck with a generated neck to fit the clothing material. In actual ID photo costume replacement, the user's body may be tilted when taking the photo, resulting in a tilted neck, shifting left or right. This can cause the detected neck connection point to shift, resulting in poor costume replacement results. Summary of the Invention
[0004] The main purpose of the present invention is to provide an image processing method, device, equipment and computer-readable storage medium, aiming to solve the technical problem that the detection position offset of the neck connection point during the changing process leads to poor changing effect.
[0005] To achieve the above object, the present invention provides an image processing method, which includes the following steps:
[0006] If the neck of the person in the image to be processed is offset, obtaining the image to be changed corresponding to the image to be processed and the neck correction parameters corresponding to the person in the image to be processed;
[0007] Determining, based on the neck correction parameters, positioning points corresponding to the image to be changed, wherein the positioning points include a left positioning point and a right positioning point;
[0008] A dressing operation is performed based on the positioning point, the image to be dressed up, and the dressing material to obtain a target image.
[0009] Preferably, the neck correction parameters include a neck width corresponding to the person image and a first coordinate corresponding to a chin tip in the person image. The step of determining a positioning point corresponding to the image to be changed based on the neck correction parameters includes:
[0010] Determine a positioning line based on the central axis corresponding to the character image, the neck width, and the first coordinate, wherein the positioning line includes a left positioning line and a right positioning line;
[0011] Based on the positioning line and the facial region mask corresponding to the character image, positioning points are determined, wherein the positioning points include a left positioning point and a right positioning point.
[0012] Preferably, the step of determining the positioning line based on the central axis corresponding to the person image, the neck width, and the first coordinate includes:
[0013] Determining an offset point in the image to be processed based on the neck width and the first coordinate, wherein the offset point includes a left offset point and a right offset point;
[0014] The central axis corresponding to the character image is obtained, and the central axis is horizontally translated based on the offset point to obtain the positioning line.
[0015] Preferably, the step of determining the positioning point based on the positioning line and the facial region mask corresponding to the person image includes:
[0016] determining an intersection point between the positioning line and the face region mask;
[0017] The intersection point close to the chin tip among the intersection points on the left positioning line is used as the left positioning point, and the intersection point close to the chin tip among the intersection points on the right positioning line is used as the right positioning point.
[0018] Preferably, the process of obtaining the neck width includes:
[0019] Obtaining coordinate information of a pupil point in the person image, and obtaining a junction point between a chin and a neck in the person image, wherein the junction point includes a left junction point and a right junction point;
[0020] Determining the eye distance of the character image based on the coordinate information, and determining the intersection point distance between the left intersection point and the right intersection point;
[0021] Determining whether the junction point spacing is greater than the eye spacing;
[0022] If the intersection point distance is greater than the eye distance, determining the intersection point distance as the neck width;
[0023] If the intersection point distance is less than or equal to the eye distance, the distance between the left cheek point and the right cheek point in the person image is obtained, and the distance is used as the neck width.
[0024] Preferably, before the step of obtaining the image to be changed corresponding to the image to be processed and the neck correction parameters corresponding to the image to be processed if the neck of the person in the image to be processed is offset, the method further includes:
[0025] Obtaining a junction point between a chin and a neck in the person image, wherein the junction point includes a left junction point and a right junction point;
[0026] Determining a horizontal offset distance and a vertical offset distance based on a central axis corresponding to the character image and the intersection point;
[0027] Determine whether the lateral offset distance is greater than a preset value or whether the longitudinal offset distance is greater than a preset value, wherein if the lateral offset distance is greater than the preset value and / or the longitudinal offset distance is greater than the preset value, it is determined that the neck is offset.
[0028] Preferably, the step of determining the horizontal offset distance and the vertical offset distance based on the central axis corresponding to the character image and the intersection point includes:
[0029] Based on the coordinates of the left intersection point and the coordinates of the right intersection point, obtaining the difference in straight-line distances between the left intersection point and the right intersection point and the central axis;
[0030] The absolute value of the difference between the straight-line distances is used as the lateral offset distance, and the absolute value of the difference between the vertical coordinates of the left intersection point and the right intersection point is used as the vertical offset distance.
[0031] In addition, to achieve the above-mentioned object, the present invention further provides an image processing device, comprising:
[0032] an acquisition module, configured to acquire, if there is a neck offset in the image of the person in the image to be processed, an image to be changed corresponding to the image to be processed, and neck correction parameters corresponding to the image of the person in the image to be processed;
[0033] A determination module, configured to determine, based on the neck correction parameters, the positioning points corresponding to the image to be changed, wherein the positioning points include a left positioning point and a right positioning point;
[0034] The dressing-up module is used to perform a dressing-up operation based on the positioning point, the image to be dressed up, and the dressing-up material to obtain a target image.
[0035] In addition, to achieve the above-mentioned purpose, the present invention also provides an image processing device, which includes: a memory, a processor, and an image processing program stored in the memory and runnable on the processor, and when the image processing program is executed by the processor, the steps of the image processing method described above are implemented.
[0036] In addition, to achieve the above-mentioned purpose, the present invention further provides a computer-readable storage medium, on which an image processing program is stored. When the image processing program is executed by a processor, the steps of the above-mentioned image processing method are implemented.
[0037] The present invention obtains the image to be changed corresponding to the image to be processed and the neck correction parameters corresponding to the image to be processed if there is an offset in the neck of the person image in the image to be processed; then determines the positioning points corresponding to the image to be changed based on the neck correction parameters, wherein the positioning points include a left positioning point and a right positioning point; then performs a dressing operation based on the positioning points, the image to be changed and the dressing material to obtain a target image, and when there is an offset in the neck in the image, redetermines the positioning points in the image to be changed according to the neck correction parameters to perform dressing, and redetermines the neck connection point by performing left and right offset correction on the connection point between the face and neck of the person image. When the photo is changed, the error between the neck connection point and the actual value due to a crooked neck or an obstructed neck is reduced, thereby improving the dressing effect of the photo. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 is a schematic diagram of the structure of an image processing device in a hardware operating environment involved in an embodiment of the present invention;
[0039] Figure 2 1 is a flow chart of a first embodiment of an image processing method according to the present invention;
[0040] Figure 3 FIG. 1 is a schematic diagram of functional modules of an image processing device according to an embodiment of the present invention.
[0041] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0042] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0043] like Figure 1 As shown, Figure 1 It is a structural diagram of an image processing device in a hardware operating environment involved in an embodiment of the present invention.
[0044] The image processing device in the embodiment of the present invention can be a PC, or a mobile terminal device with a display function such as a smart phone, a tablet computer, an MP4 (Moving Picture Experts Group Audio Layer IV) player, or a portable computer.
[0045] like Figure 1 As shown, the image processing device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0046] Optionally, the image processing device may further include a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, etc. Sensors such as light sensors, motion sensors, and other sensors are not described in detail here.
[0047] Those skilled in the art will understand that Figure 1 The terminal structure shown in the figure does not constitute a limitation on the image processing device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0048] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an image processing program.
[0049] exist Figure 1 In the image processing device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; and the processor 1001 can be used to call the image processing program stored in the memory 1005.
[0050] In this embodiment, the image processing device includes: a memory 1005, a processor 1001, and an image processing program stored in the memory 1005 and executable on the processor 1001, wherein when the processor 1001 calls the image processing program stored in the memory 1005, it executes the steps of the image processing method in each of the following embodiments.
[0051] The present invention also provides an image processing method, referring to Figure 2 , Figure 2 FIG. 1 is a flow chart of the first embodiment of the image processing method of the present invention.
[0052] In this embodiment, the image processing method includes the following steps:
[0053] Step S101: If the neck of the person in the image to be processed is offset, obtain the image to be changed corresponding to the image to be processed and the neck correction parameters corresponding to the person in the image to be processed;
[0054] In this embodiment, after determining the image that needs to be changed, that is, the image to be processed, it is determined whether the neck of the person image in the image to be processed is offset, that is, it is determined whether the neck of the person image is offset or blocked. Specifically, it can be judged whether the neck is offset through the intersection of the chin and neck in the person image.
[0055] If the neck of the person image in the image to be processed is offset, then the image to be changed corresponding to the image to be processed and the neck correction parameters corresponding to the person image in the image to be processed are obtained, wherein the image to be changed can be an image of the human head above the neck in the person image (including the image of the neck), and the neck correction parameters can include the neck width and the first coordinate corresponding to the chin tip in the person image. Since the neck of the person image in the image to be processed is offset, the neck width is the corrected neck width.
[0056] For example, the image to be processed is a picture input by the user containing a person image. In the image coordinate system, the neck width corresponding to the person image and the first coordinate corresponding to the chin tip in the person image are obtained, wherein the image coordinate system is a coordinate system with the upper left corner of the picture as the origin, the x-axis direction from the origin to the right, and the y-axis direction from the origin downward.
[0057] Specifically, the character image can be divided into the face area and the neck area. Obtaining the intersection point of the chin and the neck is to obtain the intersection point of the left and right boundaries of the face area and the neck area. The intersection point includes a left intersection point and a right intersection point. In the image coordinate system, the coordinates of the intersection point and the coordinates of the chin tip are obtained, and the neck width is obtained according to the coordinates of the intersection point. For example, a large number of portrait images with intersection points marked are obtained in advance, and the model is trained by deep learning methods to obtain a trained model. The model can detect the image input by the user and determine the intersection point of the left and right boundaries of the face area and the neck area of the character image in the image, wherein the intersection point includes a left intersection point A and a right intersection point B. At the same time, the face area corresponding to the human face is determined. 6 key points, and then, obtain the coordinates of the left junction point A, the right junction point B and the 106 key points of the face in the image, and determine that the first coordinate corresponding to the chin tip is the coordinate of point 16 among the coordinates of the 106 key points of the face. Thereafter, calculate the distance between the two pupil points according to the coordinates of points 104 and 105 as the inter-eye distance, and calculate the distance between AB according to the coordinates of the left junction point A and the right junction point B as the junction point distance, and then compare the inter-eye distance with the junction point distance. If the junction point distance is greater than the eye distance, determine that the junction point distance is the neck width; if the junction point distance is less than or equal to the eye distance, obtain the distance between points 10 and 22 among the 106 key points of the face, and use this distance as the neck width.
[0058] Step S102: determining the positioning points corresponding to the image to be changed based on the neck correction parameters, wherein the positioning points include a left positioning point and a right positioning point;
[0059] In this embodiment, when the neck correction parameters are obtained, the positioning points corresponding to the image to be changed are determined, wherein the positioning points include a left positioning point and a right positioning point. The positioning points are used to locate the neck of the image to be changed when changing clothes. Specifically, the positioning line can be determined based on the neck width and the first coordinate, and the positioning line includes a left positioning line and a right positioning line, and then the positioning point is determined based on the positioning line.
[0060] Step S103 , performing a dressing operation based on the positioning point, the image to be dressed up, and the dressing material to obtain a target image.
[0061] In this embodiment, based on the coordinates of the left positioning point and the right positioning point, the image to be changed corresponding to the image to be processed and the changing material, the image to be changed is changed using the changing material to obtain a target image. For example, the image to be changed is extracted from the image to be processed based on a head area mask including the face area and the hair area, and the extracted image is superimposed with a preset background color to form an image. The changing material is an image material including clothes and a neck area. In the changing material, the left boundary point of the leftmost boundary of the upper end of the neck and the right boundary point of the rightmost boundary of the upper end of the neck can be determined. Then, the skin color of the face area in the image to be changed is extracted, and the skin color is transferred to the neck area in the changing material. Then, based on the point correspondence, the left boundary point in the changing material is fitted to the left positioning point in the image to be changed, and the right boundary point in the changing material is fitted to the right positioning point in the image to be changed, and the images are superimposed to obtain the target image.
[0062] It should be noted that when the above-mentioned left boundary points and right boundary points are aligned, the distance between the left and right boundary points needs to be the same as the distance between the left and right positioning points. That is, according to the ratio of the distance between the left and right boundary points to the distance between the left and right positioning points, the dressing material is appropriately enlarged or reduced to match the size of the image to be dressed up.
[0063] The image processing method proposed in this embodiment is as follows: if there is an offset in the neck of the person image in the image to be processed, the image to be changed corresponding to the image to be processed and the neck correction parameters corresponding to the person image in the image to be processed are obtained; then, based on the neck correction parameters, the positioning points corresponding to the image to be changed are determined, wherein the positioning points include a left positioning point and a right positioning point; then, based on the positioning points, the image to be changed and the changing material, a changing operation is performed to obtain a target image; when there is an offset in the neck in the image, the positioning points in the image to be changed are re-determined according to the neck correction parameters to perform the changing; the neck connection point is re-determined by performing left and right offset correction on the connection point between the face and neck of the person image; when the photo is changed, the error between the neck connection point and the actual value due to a crooked neck or an obstructed neck is reduced, thereby improving the changing effect of the photo.
[0064] Based on the first embodiment, a second embodiment of the image processing method of the present invention is proposed. In this embodiment, the neck correction parameters include the neck width corresponding to the person image and the first coordinate corresponding to the chin tip in the person image. Step S102 includes:
[0065] Step S201, determining a positioning line based on the central axis corresponding to the person image, the neck width, and the first coordinate, wherein the positioning line includes a left positioning line and a right positioning line;
[0066] In this embodiment, the positioning line is determined based on the central axis corresponding to the person image in the image to be processed, the above-mentioned neck width and the above-mentioned first coordinate, wherein the positioning line includes a left positioning line and a right positioning line, and the central axis is the straight line connecting 16 points and 43 points among the 106 key points of the face. The equation of the central axis in the image coordinate system can be calculated based on the coordinates of the 16 points and the 43 points.
[0067] Specifically, the offset point in the image to be processed can be determined according to the first coordinate and the neck width, wherein the offset point includes a left offset point and a right offset point. Then, according to the offset point and the central axis, the positioning line and the equation of the positioning line can be determined. For example, the point at a distance of half the neck width to the left of point 16 is taken as the left offset point, and the point at a distance of half the neck width to the right of point 16 is taken as the right offset point. Assuming the first coordinate is (facepoint
[16] .x, facepoint
[16] .y), and the neck width is Wneck, the coordinates of the left offset point pointL are (facepoint
[16] .x-Wneck / 2, fa cepoint
[16] .y), the coordinates of the right offset point are (facepoint
[16] .x+Wneck / 2, facepoint
[16] .y), and the equation of the central axis is y=f(x). The central axis is translated to the left to the position where it intersects with the left offset point, and is determined as the left positioning line. The central axis is translated to the right to the position where it intersects with the right offset point, and is determined as the right positioning line. That is, the central axis is translated to the left and right by a distance of Wneck / 2 respectively. Therefore, the equations of the left positioning line and the right positioning line can be obtained. The equation of the left positioning line is y=f(x-Wneck / 2), and the equation of the right positioning line is y=f(x+Wneck / 2).
[0068] In some other embodiments, straight lines can be drawn on the left offset point and the right offset point respectively, so that the two straight lines are parallel to the above-mentioned central axis, and the straight line on the left offset point is determined as the left positioning line, and the straight line on the right offset point is determined as the right positioning line.
[0069] Step S202: determining positioning points based on the positioning line and the facial region mask corresponding to the person image, wherein the positioning points include a left positioning point and a right positioning point;
[0070] In this embodiment, the positioning points are determined based on the positioning lines and the facial area mask corresponding to the person image, wherein the positioning points include a left positioning point and a right positioning point, and the facial area mask is a mask corresponding to the facial area of the person image in the image to be processed.
[0071] Specifically, respectively obtain the intersection of the left positioning line and the above-mentioned face mask area, and the intersection of the right positioning line and the above-mentioned face mask area, and use the intersection point close to 16 points among the intersection points on the left positioning line as the left positioning point, and use the intersection point close to 16 points among the intersection points on the right positioning line as the right positioning point. For example, the equation of the left positioning line is traversed from bottom to top, and the first point belonging to the face area mask that appears is the intersection point closest to 16 points among the intersection points of the left positioning line and the face mask area. It is used as the left positioning point, and the coordinates of the left positioning point are obtained; the equation of the right positioning line is traversed from bottom to top, and the first point belonging to the face area mask that appears is the intersection point closest to 16 points among the intersection points of the right positioning line and the face mask area. It is used as the right positioning point, and the coordinates of the right positioning point are obtained.
[0072] It should be noted that by labeling each pixel in the image to be processed and performing semantic segmentation on the image to be processed according to different labels, regional masks of different areas in the image to be processed can be obtained. For example, a face region mask containing only the face region and a head region mask containing the face region and the hair region can be obtained. Based on different region masks, an image containing only the corresponding area can be extracted from the image to be processed.
[0073] The image processing method proposed in this embodiment determines a positioning line based on the central axis corresponding to the character image, the neck width and the first coordinate, wherein the positioning line includes a left positioning line and a right positioning line; then determines a positioning point based on the positioning line and the facial area mask corresponding to the character image, wherein the positioning point includes a left positioning point and a right positioning point. The positioning point can be accurately obtained according to the neck width and the first coordinate, and the connection point between the face and neck of the character image is corrected for left and right offset through the positioning point, and the neck connection point is re-determined, thereby reducing the error between the neck connection point and the actual point due to a crooked neck or an obstructed neck, and further improving the dressing effect of the photo.
[0074] Based on the second embodiment, a third embodiment of the image processing method of the present invention is proposed. In this embodiment, step S201 includes:
[0075] Step S301: determining an offset point in the image to be processed based on the neck width and the first coordinate, wherein the offset point includes a left offset point and a right offset point;
[0076] Step S302: Acquire the central axis corresponding to the character image, and horizontally translate the central axis based on the offset point to obtain the positioning line.
[0077] In this embodiment, the offset points in the image to be processed can be determined based on the neck width and the first coordinate, wherein the offset points include a left offset point and a right offset point. The central axis corresponding to the character image is determined based on the coordinates of the 16 points and 43 points in the facial area, and the equation of the central axis is determined. Based on the offset points, the central axis is horizontally translated to determine the positioning line, and the equation of the positioning line is determined, wherein the positioning line includes a left positioning line and a right positioning line.
[0078] Specifically, the point at the left of the 16 points corresponding to the chin tip and half the width of the neck is used as the left offset point, and the point at the right of the 16 points and half the width of the neck is used as the right offset point. Let the first coordinate corresponding to the 16 points be (facepoint
[16] .x, facepoint
[16] .y), and the neck width be Wneck. Then the coordinates of the left offset point pointL can be obtained as (facepoint
[16] .x-Wneck / 2, facepoint
[16] .y), and the coordinates of the right offset point can be obtained as (facepoint
[16] .x+Wneck / 2, facepoint
[16] .y). nt
[16] .y), the equation of the central axis is obtained according to the coordinates of the 16 points and the 43 points, and the equation is set as y=f(x). The central axis is horizontally translated, and the central axis is translated to the left to the position where it intersects with the left offset point, and is determined as the left positioning line. The central axis is translated to the right to the position where it intersects with the right offset point, and is determined as the right positioning line. That is, the central axis is translated to the left and to the right by a distance of Wneck / 2, respectively. Therefore, the left positioning line and the right positioning line can be obtained, and the equations of the left positioning line and the right positioning line can be determined. The equation of the left positioning line is y=f(x-Wneck / 2), and the equation of the right positioning line is y=f(x+Wneck / 2).
[0079] The image processing method proposed in this embodiment determines the offset points in the image to be processed based on the neck width and the first coordinate, wherein the offset points include a left offset point and a right offset point; then obtains the central axis corresponding to the character image, and horizontally translates the central axis based on the offset points to obtain the positioning line. The left offset point and the right offset point are determined based on the coordinates of the chin tip, respectively, by a distance of half the neck width to the left and right, so that the distances from the left offset point and the right offset point to the chin tip are equal. Then, the straight lines parallel to the central axis on the left offset point and the right offset point are determined as positioning lines, so that when the connection point between the face and neck of the character image is subsequently corrected for left and right offsets based on the positioning lines, the obtained connection point positions are symmetrical about the central axis, thereby improving the accuracy and rationality of the connection point positions, thereby improving the subsequent dressing effect.
[0080] Based on the second embodiment, a fourth embodiment of the image processing method of the present invention is proposed. In this embodiment, step S202 includes:
[0081] Step S401, determining the intersection between the positioning line and the face region mask;
[0082] Step S402: Using the intersection point on the left positioning line that is close to the chin tip as the left positioning point, and using the intersection point on the right positioning line that is close to the chin tip as the right positioning point.
[0083] In this embodiment, a facial area mask corresponding to the above-mentioned character image is obtained, and the intersection points of the left positioning line and the facial area mask, as well as the intersection points of the right positioning line and the facial area mask, are determined respectively according to the equation of the positioning line. The intersection point on the left positioning line close to the tip of the chin is used as the left positioning point, and the intersection point on the right positioning line close to the tip of the chin is used as the right positioning point.
[0084] Specifically, each pixel in the image to be processed is labeled, and semantic segmentation is performed on the image to be processed according to different labels to obtain regional masks of different regions in the image to be processed. According to the label of the face region, the face region mask is obtained. Then, the equation of the left positioning line is traversed from bottom to top, and the first point belonging to the face region mask that appears is the intersection point closest to 16 points among the intersection points of the left positioning line and the face mask region. It is used as the left positioning point, and the coordinates of the left positioning point are obtained; the equation of the right positioning line is traversed from bottom to top, and the first point belonging to the face region mask that appears is the intersection point closest to 16 points among the intersection points of the right positioning line and the face mask region. It is used as the right positioning point, and the coordinates of the right positioning point are obtained.
[0085] The image processing method proposed in this embodiment determines the intersection between the positioning line and the facial region mask; then, among the intersection points on the left positioning line, the intersection point closest to the chin tip is used as the left positioning point, and among the intersection points on the right positioning line, the intersection point closest to the chin tip is used as the right positioning point. The left and right positioning points are determined in the facial region of the person's image based on the positioning line. The positioning points serve as the connection points between the neck of the costume-changing material and the face of the image to be changed during subsequent costume changes. Because the left and right positioning lines are symmetrical about the aforementioned central axis, the left and right positioning points are symmetrical about the aforementioned central axis, improving the accuracy and rationality of the positioning point positions and enhancing the subsequent costume change effect.
[0086] Based on the second embodiment, a fifth embodiment of the image processing method of the present invention is proposed. In this embodiment, the process of obtaining the neck width includes:
[0087] Step S501, obtaining the coordinate information of the pupil point in the person image, and obtaining the intersection point of the chin and the neck in the person image, wherein the intersection point includes a left intersection point and a right intersection point;
[0088] Step S502, determining the eye distance of the person image based on the coordinate information, and determining the intersection point distance between the left intersection point and the right intersection point;
[0089] Step S503, determining whether the junction point spacing is greater than the eye spacing;
[0090] Step S504: If the intersection point distance is greater than the eye distance, determine the intersection point distance as the neck width.
[0091] After step S503, the method further includes:
[0092] Step S501: If the intersection point distance is less than or equal to the eye distance, obtain the distance between the left cheek point and the right cheek point in the person image, and use the distance as the neck width.
[0093] In this embodiment, in the image coordinate system of the image to be processed, the coordinates of the two pupil points 104 and 105 among the 106 key points of the face are obtained, and the intersection point of the chin and the neck in the character image is obtained, which is the intersection point of the left and right boundaries of the face area and the neck area, wherein the intersection point includes a left intersection point and a right intersection point, and the coordinates of the left intersection point and the right intersection point are determined. The eye distance is determined according to the coordinates of points 104 and 105, and the intersection point distance is determined according to the coordinates of the left intersection point and the right intersection point. The eye distance is compared with the intersection point distance. If the intersection point distance is greater than the eye distance, the intersection point distance is determined to be the neck width; if the intersection point distance is less than or equal to the eye distance, the distance between the left cheek point and the right cheek point in the character image is obtained, and the distance is used as the neck width. For example, a person image can be divided into a face area and a neck area, and the intersection point is the intersection point of the left and right boundaries of the face area and the neck area. A large number of portrait images with the intersection points marked are obtained in advance, and the model is trained through deep learning methods to obtain a trained model. The model can detect the image to be processed and determine the intersection points of the left and right boundaries of the face area and the neck area of the person image in the image to be processed, where the intersection points include the left intersection point A and the right intersection point B. At the same time, the 106 key points of the face corresponding to the face area are determined, and the coordinates of the left intersection point A, the right intersection point B and the 106 key points of the face in the image are obtained. Suppose the coordinates of point 104 are (facepoint
[104] .x, facepoint
[104] .y), the coordinates of point 105 are (facepoint
[105] .x, facepoint
[105] .y), and the eye distance is eyesdis, then it can be determined:
[0094] eyesdis=sqrt[(facepoint
[105] .x-facepoint
[104] .x)*(facepoint
[105] .x-facepoint
[104] .x)+(facepoint
[105] .y-facepoint
[104] .y)*(facepoint
[105] .y-facepoint
[104] .y)], where sqrt is the square root.
[0095] In addition, let the coordinates of the left intersection point A be (pointA.x, pointA.y), the coordinates of the right intersection point B be (pointB.x, pointB.y), and the intersection point spacing be ABdis, then we can determine:
[0096] ABdis=sqrt[(pointB.x-pointA.x)*(pointB.x-pointA.x)+(pointB.y-pointA.y)*(pointB.y-pointA.y)], where sqrt is the square root.
[0097] Compare eyesdis with ABdis. If ABdis>eyesdis, the intersection point spacing ABdis is taken as the neck width Wneck. If ABdis≤eyesdis, the distance between the left cheek point and the right cheek point is taken as the neck width. The left cheek point is 10 points among the 106 key points of the human face, and the right cheek point is 22 points among the 106 key points of the human face. The distance between points 10 and 22 is taken as the neck width Wneck. Let the coordinates of point 10 be (facepoint
[10] .x, facepoint
[10] .y), and the coordinates of point 22 be (facepoint
[22] .x, facepoint
[22] .y). Therefore, if the intersection point spacing is less than or equal to the eye spacing, it can be determined:
[0098] Wneck=sqrt[(facepoint
[22] .x-facepoint
[10] .x)*(facepoint
[22] .x-facepoint
[10] .x)+(facepoint
[22] .y-facepoint
[10] .y)*(facepoint
[22] .y-facepoint
[10] .y)], where sqrt is the square root.
[0099] The image processing method proposed in this embodiment obtains the coordinate information of the pupil points in the person's image and the intersection points of the chin and neck in the person's image, wherein the intersection points include a left intersection point and a right intersection point. Based on the coordinate information, the image's inter-eye distance and the intersection point distance between the left intersection point and the right intersection point are then determined. The method then determines whether the intersection point distance is greater than the inter-eye distance. If the intersection point distance is greater than the inter-eye distance, the intersection point distance is determined as the neck width. If the intersection point distance is less than or equal to the inter-eye distance, the method then obtains the distance between the left and right cheek points in the person's image and uses this distance as the neck width. By comparing the inter-eye distance with the intersection point distance, the method determines whether the neck area in the person's image is obscured or incompletely displayed, and determines a more accurate neck width. This facilitates more accurate determination of offset points when subsequently correcting the neck connection point, thereby obtaining more accurate positioning points, improving the accuracy of the positioning point positions, and enhancing the subsequent costume change effect.
[0100] Based on the above embodiments, a sixth embodiment of the image processing method of the present invention is proposed. In this embodiment, before step S101, the image processing method further includes:
[0101] Step S601, obtaining the intersection points of the chin and the neck in the person image, wherein the intersection points include a left intersection point and a right intersection point;
[0102] Step S602: determining a horizontal offset distance and a vertical offset distance based on the central axis corresponding to the character image and the intersection point;
[0103] Step S603, determining whether the lateral offset distance is greater than a preset value or whether the longitudinal offset distance is greater than a preset value, wherein if the lateral offset distance is greater than the preset value and / or the longitudinal offset distance is greater than the preset value, it is determined that the neck is offset.
[0104] Wherein, step S602 includes:
[0105] Step S701, based on the coordinates of the left intersection point and the coordinates of the right intersection point, obtaining the difference in straight-line distances between the left intersection point and the right intersection point and the central axis;
[0106] Step S702: The absolute value of the difference between the straight-line distances is used as the lateral offset distance, and the absolute value of the difference between the vertical coordinates of the left intersection point and the right intersection point is used as the vertical offset distance.
[0107] In this embodiment, the intersection point of the chin and the neck in the character image is obtained. The intersection point is the intersection point of the left and right boundaries of the face area and the neck area in the character image, wherein the intersection point includes a left intersection point and a right intersection point, and the coordinates of the left intersection point and the right intersection point are determined.
[0108] Specifically, according to the coordinates of 16 points and 43 points among the 106 key points of the face, the central axis corresponding to the character image is determined, and the equation of the central axis is determined. According to the equation of the central axis, the coordinates of the left intersection point and the coordinates of the right intersection point, the horizontal offset distance diffX and the vertical offset distance diffY of the neck in the character image are determined. Then, according to whether the horizontal offset distance and / or the vertical offset distance are greater than the preset value, it is determined whether the neck is offset. For example, the coordinates of point 16 are (facepoint
[16] .x, facepoint
[16] .y), the coordinates of point 43 are (facepoint
[43] .x, facepoint
[43] .y), the coordinates of the left intersection point A are (pointA.x, pointA.y), and the coordinates of the right intersection point B are (pointB.x, pointB.y). If the equation of the central axis is y=f(x), the formula corresponding to y=f(x) can be obtained as follows:
[0109] (x-facepoint
[16] .x) / (facepoint
[43] .x-facepoint
[16] .x)=(y-facepoint
[16] .y) / (facepoint
[43] .y-facepoint
[16] .y).
[0110] Then, the straight-line distances disL and disR from the left and right intersection points to the central axis of the face are calculated respectively by the point-to-straight-line distance calculation formula. Then, the difference between disL and disL is taken as the absolute value, which is the horizontal offset distance diffX. We can get diffX=abs(disL-disR), where abs is the absolute value. Then, the difference between the ordinates of the left and right intersection points is taken as the absolute value, which is the longitudinal offset distance diffY. We can get diffY=abs(pointB.y-pointA.y). After that, according to the coordinates of 104 and 105 of the 106 key points of the face, we calculate and obtain the eye distance eyesdis. Let the coordinates of point 104 be (facepoint
[104] .x, facepoint
[104] .y) and the coordinates of point 105 be (facepoint
[105] .x, facepoint
[105] .y). The calculation formula is as follows:
[0111] eyesdis=sqrt[(facepoint
[105] .x-facepoint
[104] .x)*(facepoint
[105] .x-facepoint
[104] .x)+(facepoint
[105] .y-facepoint
[104] .y)*(facepoint
[105] .y-facepoint
[104] .y)], where sqrt is the square root.
[0112] Multiply eyesdis by 0.15 as a preset value, and compare the preset value with the lateral offset distance and the longitudinal offset distance. When diffX>eyesdis*0.15 or diffY>eyesdis*0.15, it is considered that there is an offset in the neck and should be corrected, and then step S101 is executed to correct the neck replacement connection point.
[0113] It should be noted that the above preset value is not necessarily eyesdis*0.15, and can be any other reasonable value, and can be a value that can be obtained by calculation or directly obtained.
[0114] In some other embodiments, if the lateral offset distance and the longitudinal offset distance are both smaller than the preset values, for example, diffX<eyesdis*0.15 and diffY<eyesdis*0.15, it can be determined that there is no offset in the neck. At this time, in the subsequent correction embodiments, the left intersection point A can be directly used as the left positioning point, and the right intersection point B can be used as the right positioning point.
[0115] The image processing method proposed in this embodiment obtains the intersection point of the chin and the neck in the character image, wherein the intersection point includes a left intersection point and a right intersection point; then determines the horizontal offset distance and the vertical offset distance based on the central axis corresponding to the character image and the intersection point; then determines whether the horizontal offset distance is greater than a preset value or whether the vertical offset distance is greater than a preset value, wherein if the horizontal offset distance is greater than the preset value and / or the vertical offset distance is greater than the preset value, it is determined that the neck is offset. By determining the horizontal offset distance and the vertical offset distance, and then judging whether the neck is offset based on whether the horizontal offset distance and / or the vertical offset distance exceeds the preset value, if the neck is offset, the positioning point can be re-determined later, and the left and right offset correction and neck width correction can be performed on the neck connection point. The positioning point is used as the final neck connection point for changing clothes, eliminating errors caused by a crooked neck or an obstructed neck, thereby achieving a better effect of subsequent changing clothes.
[0116] In addition, the present invention also provides an image processing device, referring to Figure 3 , the image processing device includes:
[0117] an acquisition module 10 for acquiring, if there is a neck offset in the image of the person in the image to be processed, an image to be changed corresponding to the image to be processed and neck correction parameters corresponding to the image of the person in the image to be processed;
[0118] A determination module 20 is configured to determine, based on the neck correction parameters, the positioning points corresponding to the image to be changed, wherein the positioning points include a left positioning point and a right positioning point;
[0119] The dressing-up module 30 is configured to perform a dressing-up operation based on the positioning point, the image to be dressed up, and the dressing-up material to obtain a target image.
[0120] Furthermore, the determination module 20 is further configured to:
[0121] Determine a positioning line based on the central axis corresponding to the character image, the neck width, and the first coordinate, wherein the positioning line includes a left positioning line and a right positioning line;
[0122] Based on the positioning line and the facial region mask corresponding to the character image, positioning points are determined, wherein the positioning points include a left positioning point and a right positioning point.
[0123] Furthermore, the determination module 20 is further configured to:
[0124] Determining an offset point in the image to be processed based on the neck width and the first coordinate, wherein the offset point includes a left offset point and a right offset point;
[0125] The central axis corresponding to the character image is obtained, and the central axis is horizontally translated based on the offset point to obtain the positioning line.
[0126] Furthermore, the determination module 20 is further configured to:
[0127] determining an intersection point between the positioning line and the face region mask;
[0128] The intersection point close to the chin tip among the intersection points on the left positioning line is used as the left positioning point, and the intersection point close to the chin tip among the intersection points on the right positioning line is used as the right positioning point.
[0129] Furthermore, the determination module 20 is further configured to:
[0130] Obtaining coordinate information of a pupil point in the person image, and obtaining a junction point between a chin and a neck in the person image, wherein the junction point includes a left junction point and a right junction point;
[0131] Determining the eye distance of the character image based on the coordinate information, and determining the intersection point distance between the left intersection point and the right intersection point;
[0132] Determining whether the junction point spacing is greater than the eye spacing;
[0133] If the intersection point distance is greater than the eye distance, determining the intersection point distance as the neck width;
[0134] If the intersection point distance is less than or equal to the eye distance, the distance between the left cheek point and the right cheek point in the person image is obtained, and the distance is used as the neck width.
[0135] Furthermore, the image processing device further includes:
[0136] Obtaining a junction point between a chin and a neck in the person image, wherein the junction point includes a left junction point and a right junction point;
[0137] Determining a horizontal offset distance and a vertical offset distance based on a central axis corresponding to the character image and the intersection point;
[0138] Determine whether the lateral offset distance is greater than a preset value or whether the longitudinal offset distance is greater than a preset value, wherein if the lateral offset distance is greater than the preset value and / or the longitudinal offset distance is greater than the preset value, it is determined that the neck is offset.
[0139] Furthermore, the image processing device further includes:
[0140] Based on the coordinates of the left intersection point and the coordinates of the right intersection point, obtaining the difference in straight-line distances between the left intersection point and the right intersection point and the central axis;
[0141] The absolute value of the difference between the straight-line distances is used as the lateral offset distance, and the absolute value of the difference between the vertical coordinates of the left intersection point and the right intersection point is used as the vertical offset distance.
[0142] In addition, an embodiment of the present invention also proposes an image processing device, which includes: a memory, a processor, and an image processing program stored in the memory and runnable on the processor, wherein the image processing program implements the steps of the image processing method described above when executed by the processor.
[0143] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which an image processing program is stored. When the image processing program is executed by a processor, the steps of the above-mentioned image processing method are implemented.
[0144] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or system comprising the element.
[0145] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0146] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0147] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. An image processing method, characterized in that: The image processing method comprises the following steps: If the neck of the person in the image to be processed is offset, obtaining the image to be changed corresponding to the image to be processed and the neck correction parameters corresponding to the person in the image to be processed; Determining, based on the neck correction parameters, positioning points corresponding to the image to be changed, wherein the positioning points include a left positioning point and a right positioning point; Perform a dressing operation based on the positioning point, the image to be dressed up, and the dressing material to obtain a target image; The neck correction parameters include the neck width corresponding to the person image and the first coordinate corresponding to the chin tip in the person image. The step of determining the positioning point corresponding to the image to be changed based on the neck correction parameters includes: Determining a positioning line based on the central axis corresponding to the person image, the neck width, and the first coordinate, wherein offset points in the image to be processed are determined based on the neck width and the first coordinate, wherein the offset points include a left offset point and a right offset point, obtaining the central axis corresponding to the person image, and horizontally translating the central axis based on the offset points to obtain the positioning lines, wherein the positioning lines include a left positioning line and a right positioning line; Based on the positioning line and the facial area mask corresponding to the person image, a positioning point is determined, wherein the positioning point includes a left positioning point and a right positioning point, and the intersection between the positioning line and the facial area mask is determined; the intersection point close to the tip of the chin among the intersection points on the left positioning line is used as the left positioning point, and the intersection point close to the tip of the chin among the intersection points on the right positioning line is used as the right positioning point.
2. The image processing method according to claim 1, wherein: The process of obtaining the neck width includes: Obtaining coordinate information of a pupil point in the person image, and obtaining a junction point between a chin and a neck in the person image, wherein the junction point includes a left junction point and a right junction point; Determining the eye distance of the character image based on the coordinate information, and determining the intersection point distance between the left intersection point and the right intersection point; Determining whether the junction point spacing is greater than the eye spacing; If the intersection point distance is greater than the eye distance, determining the intersection point distance as the neck width; If the intersection point distance is less than or equal to the eye distance, the distance between the left cheek point and the right cheek point in the person image is obtained, and the distance is used as the neck width.
3. The image processing method according to any one of claims 1 to 2, characterized in that: Before the step of obtaining the image to be changed corresponding to the image to be processed and the neck correction parameters corresponding to the image to be processed if the neck of the person in the image to be processed is offset, the method further includes: Obtaining a junction point between a chin and a neck in the person image, wherein the junction point includes a left junction point and a right junction point; Determining a horizontal offset distance and a vertical offset distance based on a central axis corresponding to the character image and the intersection point; Determine whether the lateral offset distance is greater than a preset value or whether the longitudinal offset distance is greater than a preset value, wherein if the lateral offset distance is greater than the preset value and / or the longitudinal offset distance is greater than the preset value, it is determined that the neck is offset.
4. The image processing method according to claim 3, wherein: The step of determining the horizontal offset distance and the vertical offset distance based on the central axis corresponding to the character image and the intersection point includes: Based on the coordinates of the left intersection point and the coordinates of the right intersection point, obtaining the difference in straight-line distances between the left intersection point and the right intersection point and the central axis; The absolute value of the difference between the straight-line distances is used as the lateral offset distance, and the absolute value of the difference between the vertical coordinates of the left intersection point and the right intersection point is used as the vertical offset distance.
5. An image processing device, characterized in that: The image processing device comprises: an acquisition module, configured to acquire, if there is a neck offset in the image of the person in the image to be processed, an image to be changed corresponding to the image to be processed, and neck correction parameters corresponding to the image of the person in the image to be processed; A determination module, configured to determine, based on the neck correction parameters, the positioning points corresponding to the image to be changed, wherein the positioning points include a left positioning point and a right positioning point; a dressing-up module, configured to perform a dressing-up operation based on the positioning point, the image to be dressed up, and the dressing-up material to obtain a target image; The neck correction parameter includes the neck width corresponding to the person image and the first coordinate corresponding to the chin tip in the person image. The determination module is further configured to: Determining a positioning line based on the central axis corresponding to the person image, the neck width, and the first coordinate, wherein offset points in the image to be processed are determined based on the neck width and the first coordinate, wherein the offset points include a left offset point and a right offset point, obtaining the central axis corresponding to the person image, and horizontally translating the central axis based on the offset points to obtain the positioning lines, wherein the positioning lines include a left positioning line and a right positioning line; Based on the positioning line and the facial area mask corresponding to the person image, a positioning point is determined, wherein the positioning point includes a left positioning point and a right positioning point, and the intersection between the positioning line and the facial area mask is determined; the intersection point close to the tip of the chin among the intersection points on the left positioning line is used as the left positioning point, and the intersection point close to the tip of the chin among the intersection points on the right positioning line is used as the right positioning point.
6. An image processing device, characterized in that The image processing device includes: a memory, a processor, and an image processing program stored in the memory and executable on the processor. When the image processing program is executed by the processor, the steps of the image processing method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium, characterized in that An image processing program is stored on the readable storage medium, and when the image processing program is executed by the processor, the steps of the image processing method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Figure image processing method and device
CN104484858A
Image generation method and device, electronic equipment and storage medium
CN112581564A