Picture processing method and device, nonvolatile storage medium and electronic equipment

By determining the RGBA values ​​and distances of multiple pixels in the picture, the non-rectangular area can be quickly and accurately cropped, which solves the problem of poor cropping effect in the existing technology and improves the user experience.

CN118608549APending Publication Date: 2024-09-06AVIC GOLD NETWORK (BEIJING) TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410764589.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-13
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Existing technologies are difficult to quickly and accurately crop non-rectangular areas in images, especially when computing resources are limited, resulting in poor user experience.

Method used

By obtaining multiple pixels in the image to be processed, determining the RGBA value of each pixel, and determining the distance between the first target area and the second target area based on these values, and then determining the initial facial area and the target facial area, Achieve fast and accurate cutting.

Benefits of technology

It realizes the fast and accurate cropping of non-rectangular areas in pictures on the front end, solves the problem of poor cropping effect in the existing technology, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118608549A
    Figure CN118608549A
Patent Text Reader

Abstract

The invention discloses a picture processing method and device, a nonvolatile storage medium and electronic equipment. The method comprises the following steps: acquiring a to-be-processed picture; determining an RGBA value of each pixel point in the plurality of pixel points, and determining a first target area and a second target area in the to-be-processed picture according to the RGBA value of each pixel point; determining a first length and a second length between the first target area and the second target area; and determining an initial face area according to the first length and the second length, and determining a target face area in the initial face area according to the third pixel point and the fourth pixel point. According to the method and the device, the technical problem that the non-rectangular region in the picture cannot be quickly and accurately cut out in the process of cutting the picture at the front end in the related technology is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and more specifically, to an image processing method and device, a non-volatile storage medium, and an electronic device. Background Art

[0002] At present, the mainstream front-end cropping tools crop images based on rectangular selection, but human faces are non-rectangular, the cropping effect is not accurate enough, and the user experience is poor. With the development of artificial intelligence, although there are plug-ins such as Face-api, they may cause performance problems due to limited computer resources. In addition, the plug-in relies on the model, resulting in a large project size. Especially when the network is unstable or the bandwidth is low, it takes a long time to load the model for the first time.

[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0004] The embodiments of the present application provide a method and device for processing an image, a non-volatile storage medium, and an electronic device, so as to at least solve the technical problem that the related technology cannot quickly and accurately crop the non-rectangular area in the image during the front-end cropping of the image.

[0005] According to one aspect of an embodiment of the present application, a picture processing method is provided, including: obtaining a picture to be processed, wherein the picture to be processed includes a plurality of pixels; determining an RGBA value of each pixel in the plurality of pixels, and determining a first target area and a second target area in the picture to be processed according to the RGBA value of each pixel, wherein the pixel position information of the first target area is different from that of the second target area; determining a first length and a second length between the first target area and the second target area, wherein the first length is a distance between a first pixel in the first target area and a second pixel in the second target area, and the second length is a distance between a third pixel in the first target area and a fourth pixel in the second target area, the first pixel is a pixel farthest from the second target area, the second pixel is a pixel farthest from the first target area, the third pixel is a pixel closest to the second target area, and the fourth pixel is a pixel closest to the second target area; determining an initial facial area according to the first length and the second length, and determining a target facial area in the initial facial area according to the third pixel and the fourth pixel.

[0006] Optionally, the first target area includes: a first area and a second area, the second target area includes: a third area and a fourth area, the R values ​​of pixels in the first area and the third area are both within a first preset range, the G values ​​are both within a second preset range, the B values ​​are both within a third preset range, and the A values ​​are both within a fourth preset range, the R values ​​of pixels in the second area and the fourth area are both within a fifth preset range, the G values ​​are both within a sixth preset range, the B values ​​are both within a seventh preset range, and the A values ​​are both within an eighth preset range.

[0007] Optionally, the image to be processed includes n rows of pixels, where n is a positive integer greater than 2; determining the first target area and the second target area in the image to be processed according to the RGBA value of each pixel, including: for the first row of pixels, from left to right, performing a scanning operation on each pixel to determine the 11th sub-area and the 12th sub-area in the first row of pixels, wherein the pixel positions of the 11th sub-area and the 12th sub-area are different, and in the 11th sub-area and the 12th sub-area, continuous m1 pixels meet the first preset requirement, and the first preset requirement includes: the pixels The R value of the pixel is within the first preset range, the G value is within the second preset range, the B value is within the third preset range, and the A value is within the fourth preset range, or the R value of the pixel is within the fifth preset range, the G value is within the sixth preset range, the B value is within the seventh preset range, and the A value is within the eighth preset range, and m is a positive integer greater than 1; for the pixel points in the i-th row, from left to right, a scanning operation is performed on each pixel point to determine the i1-th sub-region and the i2-th sub-region of the pixel points in the i-th row, wherein the pixel positions of the i1-th sub-region and the i2-th sub-region are different, and within the i1-th sub-region and the i2-th sub-region, there are m consecutive sub-regions. i pixel points satisfy the first preset requirement, i is a positive integer greater than 1 and less than n; for the nth row of pixels, from left to right, a scanning operation is performed on each pixel point to determine the n1th sub-region and the n2th sub-region of the nth row of pixels, wherein the pixel positions of the n1th sub-region and the n2th sub-region are different, and within the n1th sub-region and the n2th sub-region, there are m consecutive n pixel points meet the first preset requirement; the 11th sub-region, the i1th sub-region and the n1th sub-region are spliced ​​to obtain the first target region; the 12th sub-region, the i2th sub-region and the n2th sub-region are spliced ​​to obtain the second target region.

[0008] Optionally, determining the first length and the second length between the first target area and the second target area includes: determining the leftmost pixel in the n first sub-areas as the first pixel; determining the rightmost pixel in the n second sub-areas as the second pixel; determining the rightmost pixel in the n first sub-areas as the third pixel; determining the leftmost pixel in the n second sub-areas as the fourth pixel; determining the first length based on the first pixel and the third pixel; and determining the second length based on the second pixel and the fourth pixel.

[0009] Optionally, determining the initial facial area according to the first length and the second length includes: determining the first midpoint of the line segment formed by the first pixel and the third pixel; determining the second midpoint of the line segment formed by the second pixel and the fourth pixel; taking the first midpoint as a base point, extending the first target area in the left-right direction by u times the first length and in the upward and downward direction by v times the second length to obtain a third target area, wherein u and v are positive numbers; taking the second midpoint as a base point, extending the second target area in the left-right direction by u times the first length and in the upward and downward direction by v times the second length to obtain a fourth target area; determining the initial facial area according to the third target area and the fourth target area.

[0010] Optionally, the initial facial area includes k rows of pixels, where k is a positive integer greater than 2; determining the facial area in the initial facial area according to the third pixel and the fourth pixel, including: determining a third midpoint of a line segment formed by the third pixel and the fourth pixel; generating a first circular area with the third midpoint as the center and a preset length as the radius; obtaining a range of RGBA values ​​of the pixels within the first circular area; for the first row of pixels, performing a scanning operation on y pixels from left to right to determine a plurality of first sub-areas of the first row of pixels, wherein, in each first sub-area, RGBA values ​​of a preset proportion of the y pixels are within a first range, wherein the first range is a first circular area. The range of RGBA values ​​of pixels in the j-shaped area is as follows: y is a positive integer; for the j-th row of pixels, a scanning operation is performed on y pixels from left to right to determine a plurality of j-th sub-areas of the j-th row of pixels, wherein in each j-th sub-area, RGBA values ​​of a preset proportion of pixels in the y pixels are within a first range; for the k-th row of pixels, a scanning operation is performed on y pixels from left to right to determine a plurality of k-th sub-areas of the k-th row of pixels, wherein in each k-th sub-area, RGBA values ​​of a preset proportion of pixels in the y pixels are within a first range; the plurality of first sub-areas, the plurality of j-th sub-areas and the plurality of k-th sub-areas are spliced ​​and drawn to obtain a facial area.

[0011] Optionally, after determining the facial area in the initial facial area, the method also includes: adjusting the size of the facial area to a target size to obtain a first facial image, wherein the target size is the size of a preset facial image in a preset model; replacing the preset facial image with the first facial image to obtain a target model; and displaying the target model.

[0012] Optionally, after displaying the target model, the method further includes: receiving the target object's selection result for the target model, and when the target object has not selected the target model, performing the following steps: obtaining a first image to be processed uploaded by the target object, wherein the first image to be processed includes a first facial area; determining pixel information of multiple pixel points in the first image to be processed; obtaining a first click behavior on the first image to be processed; determining a first point corresponding to the first click behavior, and determining and recording the pixel position of the first point; obtaining a mouse activity track on the first image to be processed, wherein the mouse activity track includes multiple second points; when the multiple second points include a second point that coincides with the first point, determining and recording the pixel position of each second point; drawing an image of the area enclosed by each second point based on the pixel information of multiple pixel points in the first image to be processed and the pixel position of each second point to obtain a first facial image; and displaying the first facial image.

[0013] Optionally, the first preset range includes: [200-255], the second preset range includes: [200-255], the third preset range includes: [200-255], the fourth preset range includes: 255, the fifth preset range includes: [0-50], the sixth preset range includes: [0-50], the seventh preset range includes: [0-50], and the eighth preset range includes: 255.

[0014] According to another aspect of the embodiment of the present application, there is further provided an image processing device, comprising: an acquisition module, configured to acquire an image to be processed, wherein the image to be processed includes a plurality of pixels; a first determination module, configured to determine an RGBA value of each pixel in the plurality of pixels, and determine a first target region and a second target region in the image to be processed according to the RGBA value of each pixel, wherein the pixel position information of the first target region is different from that of the second target region; a second determination module, configured to determine a first length and a second length between the first target region and the second target region, wherein the first length is a distance between a first pixel in the first target region and a second pixel in the second target region, and the second length is a distance between a third pixel in the first target region and a fourth pixel in the second target region, wherein the first pixel is a pixel farthest from the second target region, the second pixel is a pixel farthest from the first target region, the third pixel is a pixel closest to the second target region, and the fourth pixel is a pixel closest to the second target region; a third determination module, configured to determine an initial facial region according to the first length and the second length, and determine a target facial region in the initial facial region according to the third pixel and the fourth pixel.

[0015] According to another aspect of the embodiments of the present application, a non-volatile storage medium is further provided, the storage medium including a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the above image processing method.

[0016] According to another aspect of the embodiments of the present application, an electronic device is provided, including: a memory and a processor, the processor being used to run a program stored in the memory, wherein the above image processing method is executed when the program is run.

[0017] According to another aspect of the embodiments of the present application, a computer program is further provided, wherein the above image processing method is implemented when the computer program is executed by a processor.

[0018] According to another aspect of the embodiments of the present application, a computer program product is also provided, the computer program product comprising a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above image processing method is implemented.

[0019] In an embodiment of the present application, a to-be-processed image is obtained, wherein the to-be-processed image includes a plurality of pixels; an RGBA value of each pixel in the plurality of pixels is determined, and a first target area and a second target area are determined in the to-be-processed image according to the RGBA value of each pixel, wherein the pixel position information of the first target area is different from the pixel position information of the second target area; a first length and a second length between the first target area and the second target area are determined, wherein the first length is the distance between the first pixel in the first target area and the second pixel in the second target area, and the second length is the distance between the third pixel in the first target area and the fourth pixel in the second target area. The distance between the points, the first pixel point is the pixel point farthest from the second target area, the second pixel point is the pixel point farthest from the first target area, the third pixel point is the pixel point closest to the second target area, and the fourth pixel point is the pixel point closest to the second target area; according to the first length and the second length, the initial facial area is determined, and according to the third pixel point and the fourth pixel point, the target facial area is determined in the initial facial area, thereby achieving the technical effect of quickly and accurately cropping out the non-rectangular area in the picture, thereby solving the technical problem that the related technology cannot quickly and accurately crop out the non-rectangular area in the picture during the front-end cropping of the picture. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0021] Figure 1 is a flow chart of a picture processing method according to an embodiment of the present application;

[0022] Figure 2 is a flowchart of another image processing method according to an embodiment of the present application;

[0023] Figure 3 is a structural diagram of a picture processing device according to an embodiment of the present application;

[0024] Figure 4 It is a hardware structure block diagram of a computer terminal according to an image processing method of an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0027] According to an embodiment of the present application, a method embodiment of a method for processing an image is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0028] Figure 1 is a flowchart of a method for processing an image according to an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:

[0029] Step S102, obtaining a picture to be processed, wherein the picture to be processed includes a plurality of pixel points.

[0030] It is worth noting that the image to be processed includes facial areas and non-facial areas.

[0031] Step S104, determining the RGBA value of each pixel in the plurality of pixels, and determining a first target area and a second target area in the image to be processed according to the RGBA value of each pixel, wherein the pixel position information of the first target area is different from that of the second target area.

[0032] For example, the getImageData method of Canvas may be used to determine the RGBA value of each pixel in a plurality of pixels.

[0033] Among them, getImageData is a method in HTML5 Canvas API, which is used to get pixel data from the canvas. This method returns an ImageData object containing the pixel data of the specified area.

[0034] Following is the basic syntax of the getImageData method:

[0035] ```javascript

[0036] context.getImageData(sx,sy,sw,sh);

[0037] ```

[0038] Parameter description: `sx`: the x coordinate of the upper left corner of the rectangular area. `sy`: the y coordinate of the upper left corner of the rectangular area. `sw`: the width of the rectangular area. `sh`: the height of the rectangular area.

[0039] The returned `ImageData` object contains the following properties: `width`: the width of the rectangular area. `height`: the height of the rectangular area. `data`: a one-dimensional array containing the RGBA (red, green, blue, transparency) values ​​of each pixel in the rectangular area.

[0040] For example, the following code demonstrates how to get pixel data of a 100x100 rectangular area from the canvas:

[0041] ```javascript

[0042] var canvas=document.getElementById('myCanvas');

[0043] var context=canvas.getContext('2d');

[0044] var imageData=context.getImageData(10,10,100,100).

[0045] The RGBA value of a pixel is a combination of four channel values ​​that describe the color of the pixel, namely red, green, blue, and alpha. RGBA values ​​are often used in digital images and graphic design to represent the color and transparency of each pixel in the image. The range of RGBA values ​​is as follows: 1. Red: The value range is 0 to 255, indicating the brightness of the red channel. 0 means no red, and 255 means the brightest red. 2. Green: The value range is 0 to 255, indicating the brightness of the green channel. 0 means no green, and 255 means the brightest green. 3. Blue: The value range is 0 to 255, indicating the brightness of the blue channel. 0 means no blue, and 255 means the brightest blue. 4. Alpha: The value range is 0 to 255, indicating the transparency of the pixel. 0 means completely transparent, and 255 means completely opaque. For example, a pure red pixel can be represented by an RGBA value of (255, 0, 0, 255). This means that the brightness of the red channel is 255, while the brightness of the green and blue channels is 0, and the transparency is 255 (completely opaque).

[0046] For example, the first target area is the left eye area in the face area, and the second target area is the right eye area in the face area.

[0047] Step S106, determine the first length and the second length between the first target area and the second target area, wherein the first length is the distance between the first pixel point in the first target area and the second pixel point in the second target area, and the second length is the distance between the third pixel point in the first target area and the fourth pixel point in the second target area, the first pixel point is the pixel point farthest from the second target area, the second pixel point is the pixel point farthest from the first target area, the third pixel point is the pixel point closest to the second target area, and the fourth pixel point is the pixel point closest to the second target area.

[0048] It can be understood that the first pixel is the leftmost point in the left eye, the second pixel is the rightmost point in the right eye, the third pixel is the rightmost point in the left eye, and the fourth pixel is the leftmost point in the right eye. Then the first length is the length between the two eyes, and the second length is the distance between the two eyes.

[0049] Step S108: determining an initial facial region according to the first length and the second length, and determining a target facial region in the initial facial region according to the third pixel and the fourth pixel.

[0050] It can be understood that the initial facial region is a rough facial region inferred based on the left eye region and the right eye region, and the target facial region includes fewer non-facial pixels than the initial facial region.

[0051] According to the above steps, a picture to be processed is obtained, wherein the picture to be processed includes a plurality of pixels; an RGBA value of each pixel in the plurality of pixels is determined, and a first target area and a second target area are determined in the picture to be processed according to the RGBA value of each pixel, wherein the pixel position information of the first target area is different from that of the second target area; a first length and a second length between the first target area and the second target area are determined, wherein the first length is a distance between a first pixel in the first target area and a second pixel in the second target area, and the second length is a distance between a third pixel in the first target area and a fourth pixel in the second target area, the first pixel is a pixel farthest from the second target area, the second pixel is a pixel farthest from the first target area, the third pixel is a pixel closest to the second target area, and the fourth pixel is a pixel closest to the second target area; an initial facial area is determined according to the first length and the second length, and a target facial area is determined in the initial facial area according to the third pixel and the fourth pixel, thereby achieving a technical effect of quickly and accurately cutting out a non-rectangular area in a picture.

[0052] Preferably, the first target area includes: a first area and a second area, the second target area includes: a third area and a fourth area, the R values ​​of pixels in the first area and the third area are both within a first preset range, the G values ​​are both within a second preset range, the B values ​​are both within a third preset range, the A values ​​are both within a fourth preset range, the R values ​​of pixels in the second area and the fourth area are both within a fifth preset range, the G values ​​are both within a sixth preset range, the B values ​​are both within a seventh preset range, and the A values ​​are both within an eighth preset range.

[0053] Since the first target area can be the left eye area in the facial area, and the second target area can be the right eye area in the facial area. It can be understood that the first area is the white of the left eye, the second area is the black of the left eye, the third area is the white of the right eye, and the fourth area is the black of the right eye. Among them, the first preset range is, for example: [200-255], the second preset range is, for example: [200-255], the third preset range is, for example: [200-255], the fourth preset range is, for example: 255, the fifth preset range is, for example: [0-50], the sixth preset range is, for example: [0-50], the seventh preset range is, for example: [0-50], and the eighth preset range is, for example: 255.

[0054] According to some optional embodiments of the present application, the image to be processed includes n rows of pixels, where n is a positive integer greater than 2.

[0055] Furthermore, in step S104, determining the first target area and the second target area in the image to be processed according to the RGBA value of each pixel point can be achieved by the following method:

[0056] For the pixels in the first row, a scanning operation is performed on each pixel from left to right to determine the 11th sub-region and the 12th sub-region in the first row, wherein the pixel positions of the 11th sub-region and the 12th sub-region are different, and within the 11th sub-region and the 12th sub-region, m1 consecutive pixels meet the first preset requirement, and the first preset requirement includes: the R value of the pixel is within the first preset range, the G value is within the second preset range, the B value is within the third preset range, and the A value is within the fourth preset range, or the R value of the pixel is within the fifth preset range, the G value is within the sixth preset range, the B value is within the seventh preset range, and the A value is within the eighth preset range, and m is a positive integer greater than 1.

[0057] For the pixels in the i-th row, a scanning operation is performed on each pixel from left to right to determine the i1-th sub-region and the i2-th sub-region of the pixels in the i-th row, wherein the pixel positions of the i1-th sub-region and the i2-th sub-region are different, and within the i1-th sub-region and the i2-th sub-region, there are continuous m i pixel points meet the first preset requirement, and i is a positive integer greater than 1 and less than n.

[0058] For the nth row of pixels, a scanning operation is performed on each pixel from left to right to determine the n1th sub-region and the n2th sub-region of the nth row of pixels, wherein the pixel positions of the n1th sub-region and the n2th sub-region are different, and within the n1th sub-region and the n2th sub-region, there are m consecutive n pixels meet the first preset requirement.

[0059] The 11th sub-region, the i1th sub-region and the n1th sub-region are spliced ​​to obtain a first target region.

[0060] The 12th sub-region, the i2th sub-region and the n2th sub-region are spliced ​​to obtain a second target region.

[0061] Assuming that the image to be processed includes 100 rows of pixels, for the first row of pixels, a scanning operation is performed on each pixel from left to right to determine the 11th sub-region and the 12th sub-region in the first row of pixels, wherein the pixel positions of the 11th sub-region and the 12th sub-region are different, and it can be understood that the 11th sub-region is the left eye region in the first row of pixels, and the 12th sub-region is the right eye region in the first row of pixels. In the 11th sub-region and the 12th sub-region, 10 consecutive pixels meet the following first preset requirement: the R value of the pixel is within the first preset range, the G value is within the second preset range, the B value is within the third preset range, and the A value is within the fourth preset range, or the R value of the pixel is within the fifth preset range, the G value is within the sixth preset range, the B value is within the seventh preset range, and the A value is within the eighth preset range.

[0062] For the second row of pixels, a scanning operation is performed on each pixel from left to right to determine the 21st sub-region and the 22nd sub-region of the second row of pixels, wherein the pixel positions of the 21st sub-region and the 22nd sub-region are different, and in the 21st sub-region and the 22nd sub-region, m2 consecutive pixels meet the first preset requirement. It can be understood that the 21st sub-region is the left eye region in the second row of pixels, and the 22nd sub-region is the right eye region in the second row of pixels.

[0063] In summary, the same applies to the pixels in the 3rd to 99th rows.

[0064] Finally, for the 100th row of pixels, a scanning operation is performed on each pixel from left to right to determine the 1001st sub-region and the 1002nd sub-region of the 100th row of pixels, where the pixel positions of the 1001st sub-region and the 1002nd sub-region are different. In the 1001st sub-region and the 1002nd sub-region, there are m consecutive 100 The pixels meet the first preset requirement. It can be understood that the 1001st sub-area is the left eye area in the 100th row of pixels, and the 1002nd sub-area is the right eye area in the 100th row of pixels.

[0065] According to some other optional embodiments of the present application, determining a first length and a second length between a first target area and a second target area includes:

[0066] The leftmost pixel in the n first sub-areas is determined as the first pixel; the rightmost pixel in the n second sub-areas is determined as the second pixel; the rightmost pixel in the n first sub-areas is determined as the third pixel; and the leftmost pixel in the n second sub-areas is determined as the fourth pixel.

[0067] A first length is determined according to the first pixel point and the third pixel point; and a second length is determined according to the second pixel point and the fourth pixel point.

[0068] It can be understood that the leftmost pixel point in the n first sub-areas is the leftmost point in the left eye, the rightmost pixel point in the n first sub-areas is the rightmost point in the left eye, the leftmost pixel point in the n second sub-areas is the leftmost point in the right eye, and the rightmost pixel point in the n second sub-areas is the rightmost point in the right eye.

[0069] According to the leftmost point in the left eye and the rightmost point in the right eye, the total length EW between the two eyes can be determined; according to the rightmost point in the left eye and the leftmost point in the right eye, the distance EC between the two eyes can be determined.

[0070] In some optional embodiments of the present application, determining the initial facial region according to the first length and the second length can be achieved by the following method:

[0071] Determine a first midpoint of a line segment formed by the first pixel point and the third pixel point;

[0072] Determine a second midpoint of a line segment formed by the second pixel point and the fourth pixel point;

[0073] Taking the first midpoint as the base point, extend the first target area in the left-right direction by u times the first length, and in the upward and downward direction by v times the second length, to obtain a third target area, where u and v are positive numbers;

[0074] Taking the second midpoint as the base point, extend the second target area in the left-right direction by u times the first length, and in the upward-downward direction by v times the second length, to obtain a fourth target area;

[0075] An initial facial region is determined according to the third target region and the fourth target region.

[0076] The above method can also be expressed in the following manner: determine the midpoint of the left eye and the midpoint of the right eye. Taking the midpoint of the left eye as the base point, extend the left eye area by u times EW in the left and right directions and v times EC in the up and down directions to obtain a third target area. Taking the midpoint of the right eye as the base point, extend the right eye area by u times EW in the left and right directions and v times EC in the up and down directions to obtain a fourth target area. Adaptively adjust the third target area and the fourth target area to determine the initial facial area.

[0077] In some optional embodiments of the present application, the initial facial region includes k rows of pixels, where k is a positive integer greater than 2. Further, determining the facial region in the initial facial region according to the third pixel and the fourth pixel may be implemented by the following method:

[0078] Determine the third midpoint of the line segment formed by the third pixel and the fourth pixel, generate a first circular area with the third midpoint as the center and a preset length as the radius, and obtain the range of RGBA values ​​of the pixel points in the first circular area.

[0079] It is understandable that the third midpoint is the midpoint of the distance EC between the two eyes, which can be generally understood as the center of the eyebrows. With the center of the eyebrows as the origin and 10 pixels as the radius, the range of RGBA values ​​of the pixels in the first circular area can be obtained (hereinafter referred to as the first range).

[0080] For the first row of pixels, a scanning operation is performed on y pixels from left to right to determine a plurality of first sub-regions of the first row of pixels, wherein in each first sub-region, RGBA values ​​of a preset proportion of the y pixels are within a first range, wherein the first range is a range of RGBA values ​​of the pixels within the first circular region, and y is a positive integer;

[0081] For the j-th row of pixels, a scanning operation is performed on y pixels from left to right to determine a plurality of j-th sub-regions of the j-th row of pixels, wherein in each j-th sub-region, RGBA values ​​of a preset proportion of the y pixels are within a first range;

[0082] For the k-th row of pixels, a scanning operation is performed on y pixels from left to right to determine a plurality of k-th sub-regions of the k-th row of pixels, wherein in each k-th sub-region, RGBA values ​​of a preset proportion of the y pixels are within a first range;

[0083] The plurality of first sub-regions, the plurality of j-th sub-regions, and the plurality of k-th sub-regions are spliced ​​and drawn to obtain a facial region.

[0084] Assuming that the initial facial area includes 50 rows of pixels, for the first row of pixels, a scanning operation is performed on 10 pixels from left to right to determine multiple first sub-regions of the first row of pixels, wherein in each first sub-region, RGBA values ​​of 90% of the 10 pixels are within the first range.

[0085] For the second row of pixels, a scanning operation is performed on 10 pixels from left to right to determine multiple second sub-regions of the second row of pixels, wherein in each second sub-region, RGBA values ​​of 90% of the 10 pixels are within the first range.

[0086] In summary, the same applies to the pixels in rows 3 to 49.

[0087] Finally, for the 50th row of pixels, a scanning operation is performed on 10 pixels from left to right to determine multiple 50th sub-regions of the 50th row of pixels, wherein in each 50th sub-region, RGBA values ​​of 90% of the 10 pixels are within the first range.

[0088] Finally, multiple first sub-regions, multiple second to 49 sub-regions, and multiple 50th sub-regions are spliced ​​and drawn using Canvas to obtain a facial region.

[0089] As some optional embodiments of the present application, after the facial region is determined in the initial facial region, the following steps may also be performed:

[0090] The size of the facial region is adjusted to a target size to obtain a first facial image, wherein the target size is the size of a preset facial image in a preset model; the preset facial image is replaced with the first facial image to obtain a target model; and the target model is displayed.

[0091] In other words, the extracted facial content is scaled down or enlarged in the same proportion and replaced with the face of the model prepared in advance, and then displayed.

[0092] Furthermore, after displaying the target model, the following steps may be performed: obtaining a first image to be processed uploaded by the target object, wherein the first image to be processed includes a first facial area; determining pixel information of a plurality of pixel points in the first image to be processed; obtaining a first click behavior on the first image to be processed; determining a first point corresponding to the first click behavior, and determining and recording a pixel position of the first point; obtaining a mouse activity track on the first image to be processed, wherein the mouse activity track includes a plurality of second points; in the case where the plurality of second points include a second point that coincides with the first point, determining and recording a pixel position of each second point; drawing an image of an area enclosed by each second point based on the pixel information of the plurality of pixel points in the first image to be processed and the pixel position of each second point to obtain a first facial image; and displaying the first facial image.

[0093] In the case that the user does not recognize the target model, a new picture uploaded by the user is obtained, and the facial area selected by the user in the new picture is identified.

[0094] Use the getImageData method of Canvas to scan the selected facial area from left to right and from top to bottom, obtain the RGBA value of each pixel and save the data. Use Canvas to draw the collected data to obtain the first facial image.

[0095] Figure 2 is a flowchart of another image processing method according to an embodiment of the present application. Figure 2As shown, the method comprises the following steps:

[0096] Step S201, use Canvas to read the image, use the getImageData method of Canvas to scan the image from left to right and from top to bottom, obtain the RGBA value of each pixel and save the data.

[0097] Step S202, the human face is composed of eyebrows, eyes, nose, mouth and ears, and the facial features are symmetrical. Find the position of the eyes. The eyes are composed of white eyeballs and black eyeballs. Generally speaking, the color of the white eyeballs tends to be white or light gray, and its color will be affected by light and environment. The corresponding RGBA values ​​can be set to R: 200-255, G: 200-255, B: 200-255, A: 255. The color of the black eyeball is generally dark, and its RGBA value can be set to R: 0-50, G: 0-50, B: 0-50, A: 255. The RGBA values ​​corresponding to the white eyeballs and the black eyeballs are thresholds E1 and E2 respectively.

[0098] Step S203, once a pixel that meets the threshold E1 or E2 is scanned, its pixel position is recorded and scanning continues until its RGBA value is not within the threshold A or B for more than 10 consecutive times, and the last pixel position EF1 (x, y) that is not within the threshold AB is recorded, and the next row of pixels is scanned from left to right, and this step is repeated until no pixel within the threshold AB is scanned. At this point, the pixel position of one eye in the picture can be collected, and scanning continues from the first EF1 (x, y) position until the pixel position of the other eye in the picture is collected.

[0099] Step S204, after collecting pixel information of the two eyes, the length EW and the distance EC between the two eyes can be calculated, and the RGBA range value with the center of the middle of the two eyes and a radius of 10 pixels is collected. This range value is the facial RGBA value F.

[0100] Step S205, taking the centers of the two eyes as the dots, extending left and right by 1 time the length of EW, and extending upward and downward by 2 times the length of EW, and extracting the image within the range as the rough facial content F.

[0101] Step S206, according to the extracted facial content F, scan from left to right and from top to bottom again. When the extracted pixel RGBA value is within the facial RGBA value F range, record the pixel point scanned for the first time and mark it as [Start S1], and continue scanning; 10 pixels, if 90% of these 10 pixels are within the range F, collect the coordinates of pixel point S1. Similarly, scan the last pixel point in the current row within the facial RGBA value F range and mark it as [End E1], and record the positions of [Start S1] and [End E1] and the RGBA values ​​of the pixels between them. When the last column is scanned, continue to loop from the next row. At the end of the scan, an array that collects the start and end of each row is obtained: [{S1, E1}, {S2, E2}, {S3, E3}..... {Sn, En}].

[0102] Step S207, using Canvas to draw a picture according to the collected [{S1, E1}, {S2, E2}, {S3, E3}.....{Sn, En}] values, the drawn picture is the extracted cropped facial image.

[0103] Step S208, using the model prepared in advance, the extracted facial content is scaled down or enlarged in the same proportion and replaced with the face of the model to obtain the final result, and the final result is displayed to the user.

[0104] Step S209: If the user is not satisfied with the picture generated in the above steps, a new picture uploaded by the user is received.

[0105] Step S210, use Canvas to read a new picture, and the user marks the selected area with the mouse.

[0106] Step S211, recording the position and pixel information of the user's first mouse click.

[0107] Step S212: the user starts to move the mouse, and the position and pixel information of each mouse movement trajectory are recorded according to mousemove.

[0108] Step S213, after the mouse moves, record whether the click event coincides with the starting click position, and select End when it coincides.

[0109] Step S214, use the getImageData method of Canvas to scan the image from left to right and from top to bottom, obtain the RGBA value of each pixel and save the data.

[0110] Step S215, using Canvas to draw the collected data to obtain new results.

[0111] Figure 3 is a structural diagram of an image processing device according to an embodiment of the present application, such as Figure 3 As shown, the device comprises:

[0112] The acquisition module 30 is used to acquire a picture to be processed, wherein the picture to be processed includes a plurality of pixels.

[0113] The first determination module 32 is used to determine the RGBA value of each pixel in the plurality of pixels, and determine a first target area and a second target area in the image to be processed according to the RGBA value of each pixel, wherein the pixel position information of the first target area is different from that of the second target area.

[0114] The second determination module 34 is used to determine the first length and the second length between the first target area and the second target area, wherein the first length is the distance between the first pixel point in the first target area and the second pixel point in the second target area, and the second length is the distance between the third pixel point in the first target area and the fourth pixel point in the second target area, the first pixel point is the pixel point farthest from the second target area, the second pixel point is the pixel point farthest from the first target area, the third pixel point is the pixel point closest to the second target area, and the fourth pixel point is the pixel point closest to the second target area.

[0115] The third determining module 36 is configured to determine an initial facial region according to the first length and the second length, and determine a target facial region in the initial facial region according to the third pixel point and the fourth pixel point.

[0116] Optionally, the first target area includes: a first area and a second area, the second target area includes: a third area and a fourth area, the R values ​​of pixels in the first area and the third area are both within a first preset range, the G values ​​are both within a second preset range, the B values ​​are both within a third preset range, and the A values ​​are both within a fourth preset range, the R values ​​of pixels in the second area and the fourth area are both within a fifth preset range, the G values ​​are both within a sixth preset range, the B values ​​are both within a seventh preset range, and the A values ​​are both within an eighth preset range.

[0117] Optionally, the image to be processed includes n rows of pixels, where n is a positive integer greater than 2; determining the first target area and the second target area in the image to be processed according to the RGBA value of each pixel, including: for the first row of pixels, from left to right, performing a scanning operation on each pixel to determine the 11th sub-area and the 12th sub-area in the first row of pixels, wherein the pixel positions of the 11th sub-area and the 12th sub-area are different, and in the 11th sub-area and the 12th sub-area, continuous m1 pixels meet the first preset requirement, and the first preset requirement includes: the pixels The R value of the pixel is within the first preset range, the G value is within the second preset range, the B value is within the third preset range, and the A value is within the fourth preset range, or the R value of the pixel is within the fifth preset range, the G value is within the sixth preset range, the B value is within the seventh preset range, and the A value is within the eighth preset range, and m is a positive integer greater than 1; for the pixel points in the i-th row, from left to right, a scanning operation is performed on each pixel point to determine the i1-th sub-region and the i2-th sub-region of the pixel points in the i-th row, wherein the pixel positions of the i1-th sub-region and the i2-th sub-region are different, and within the i1-th sub-region and the i2-th sub-region, there are m consecutive sub-regions. i pixel points satisfy the first preset requirement, i is a positive integer greater than 1 and less than n; for the nth row of pixels, from left to right, a scanning operation is performed on each pixel point to determine the n1th sub-region and the n2th sub-region of the nth row of pixels, wherein the pixel positions of the n1th sub-region and the n2th sub-region are different, and within the n1th sub-region and the n2th sub-region, there are m consecutive n pixel points meet the first preset requirement; the 11th sub-region, the i1th sub-region and the n1th sub-region are spliced ​​to obtain the first target region; the 12th sub-region, the i2th sub-region and the n2th sub-region are spliced ​​to obtain the second target region.

[0118] Optionally, determining the first length and the second length between the first target area and the second target area includes: determining the leftmost pixel in the n first sub-areas as the first pixel; determining the rightmost pixel in the n second sub-areas as the second pixel; determining the rightmost pixel in the n first sub-areas as the third pixel; determining the leftmost pixel in the n second sub-areas as the fourth pixel; determining the first length based on the first pixel and the third pixel; and determining the second length based on the second pixel and the fourth pixel.

[0119] Optionally, determining the initial facial area according to the first length and the second length includes: determining the first midpoint of the line segment formed by the first pixel and the third pixel; determining the second midpoint of the line segment formed by the second pixel and the fourth pixel; taking the first midpoint as a base point, extending the first target area in the left-right direction by u times the first length and in the upward and downward direction by v times the second length to obtain a third target area, wherein u and v are positive numbers; taking the second midpoint as a base point, extending the second target area in the left-right direction by u times the first length and in the upward and downward direction by v times the second length to obtain a fourth target area; determining the initial facial area according to the third target area and the fourth target area.

[0120] Optionally, the initial facial area includes k rows of pixels, where k is a positive integer greater than 2; determining the facial area in the initial facial area according to the third pixel and the fourth pixel, including: determining a third midpoint of a line segment formed by the third pixel and the fourth pixel; generating a first circular area with the third midpoint as the center and a preset length as the radius; obtaining a range of RGBA values ​​of the pixels within the first circular area; for the first row of pixels, performing a scanning operation on y pixels from left to right to determine a plurality of first sub-areas of the first row of pixels, wherein, in each first sub-area, RGBA values ​​of a preset proportion of the y pixels are within a first range, wherein the first range is a first circular area. The range of RGBA values ​​of pixels in the j-shaped area is as follows: y is a positive integer; for the j-th row of pixels, a scanning operation is performed on y pixels from left to right to determine a plurality of j-th sub-areas of the j-th row of pixels, wherein in each j-th sub-area, RGBA values ​​of a preset proportion of pixels in the y pixels are within a first range; for the k-th row of pixels, a scanning operation is performed on y pixels from left to right to determine a plurality of k-th sub-areas of the k-th row of pixels, wherein in each k-th sub-area, RGBA values ​​of a preset proportion of pixels in the y pixels are within a first range; the plurality of first sub-areas, the plurality of j-th sub-areas and the plurality of k-th sub-areas are spliced ​​and drawn to obtain a facial area.

[0121] Optionally, after determining the facial area in the initial facial area, the following steps may also be performed: adjusting the size of the facial area to a target size to obtain a first facial image, wherein the target size is the size of a preset facial image in a preset model; replacing the preset facial image with the first facial image to obtain a target model; and displaying the target model.

[0122] Optionally, after displaying the target model, the following steps may also be performed: receiving the target object's selection result for the target model, and if the target object has not selected the target model, performing the following steps: obtaining a first image to be processed uploaded by the target object, wherein the first image to be processed includes a first facial area; determining pixel information of a plurality of pixel points in the first image to be processed; obtaining a first click behavior on the first image to be processed; determining a first point corresponding to the first click behavior, and determining and recording a pixel position of the first point; obtaining a mouse activity track on the first image to be processed, wherein the mouse activity track includes a plurality of second points; in the case where a second point that coincides with the first point is included in the plurality of second points, determining and recording a pixel position of each second point; drawing an image of the area enclosed by each second point based on the pixel information of the plurality of pixel points in the first image to be processed and the pixel position of each second point to obtain a first facial image; and displaying the first facial image.

[0123] Optionally, the first preset range includes: [200-255], the second preset range includes: [200-255], the third preset range includes: [200-255], the fourth preset range includes: 255, the fifth preset range includes: [0-50], the sixth preset range includes: [0-50], the seventh preset range includes: [0-50], and the eighth preset range includes: 255.

[0124] It should be noted that the above Figure 3 The modules in the embodiment may be program modules (e.g., a set of program instructions for implementing a specific function) or hardware modules. For the latter, they may be expressed in the following forms, but are not limited thereto: the expression form of the above modules is a processor, or the functions of the above modules are implemented by a processor.

[0125] It should be noted that Figure 3 The preferred implementation of the illustrated embodiment can be found in Figure 1 The relevant description of the illustrated embodiment will not be repeated here.

[0126] Figure 4 FIG. 1 shows a hardware structure block diagram of a computer terminal for implementing a method for image processing. Figure 4As shown, the computer terminal 40 may include one or more (402a, 402b, ..., 402n are used to illustrate) processors 402 (the processor 402 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 404 for storing data, and a transmission module 406 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 4 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 4 More or fewer components as shown, or with Figure 4 Different configurations are shown.

[0127] It should be noted that the one or more processors 402 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 40. As involved in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0128] The memory 404 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the image processing method in the embodiment of the present application. The processor 402 executes various functional applications and data processing by running the software programs and modules stored in the memory 404, that is, realizing the above-mentioned image processing method. The memory 404 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 404 may further include a memory remotely arranged relative to the processor 402, and these remote memories may be connected to the computer terminal 40 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0129] The transmission module 406 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 40. In one example, the transmission module 406 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission module 406 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0130] The display may be, for example, a touch screen liquid crystal display (LCD), which may enable the target object to interact with the target object interface of the computer terminal 40 .

[0131] It should be noted that, in some optional embodiments, the above Figure 4 The computer terminal shown may include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of hardware elements and software elements. It should be noted that Figure 4 This is merely one example of a particular embodiment and is intended to illustrate the types of components that may be present in the computer terminal described above.

[0132] It should be noted that Figure 4 The computer terminal shown is used to execute Figure 1 The image processing method shown, therefore the relevant explanations in the execution method of the above command are also applicable to the electronic device and will not be repeated here.

[0133] An embodiment of the present application further provides a non-volatile storage medium, which includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the above image processing method.

[0134] A program for a non-volatile storage medium to perform the following functions: obtaining a to-be-processed picture, wherein the to-be-processed picture includes a plurality of pixels; determining an RGBA value of each pixel in the plurality of pixels, and determining a first target area and a second target area in the to-be-processed picture according to the RGBA value of each pixel, wherein the pixel position information of the first target area is different from that of the second target area; determining a first length and a second length between the first target area and the second target area, wherein the first length is a distance between a first pixel in the first target area and a second pixel in the second target area, and the second length is a distance between a third pixel in the first target area and a fourth pixel in the second target area, wherein the first pixel is a pixel farthest from the second target area, the second pixel is a pixel farthest from the first target area, the third pixel is a pixel closest to the second target area, and the fourth pixel is a pixel closest to the second target area; determining an initial facial area according to the first length and the second length, and determining a target facial area in the initial facial area according to the third pixel and the fourth pixel.

[0135] An embodiment of the present application further provides an electronic device, including: a memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the above image processing method is executed when the program is run.

[0136] The processor is used to run a program that performs the following functions: obtaining a to-be-processed image, wherein the to-be-processed image includes a plurality of pixels; determining an RGBA value of each pixel in the plurality of pixels, and determining a first target area and a second target area in the to-be-processed image according to the RGBA value of each pixel, wherein the pixel position information of the first target area is different from that of the second target area; determining a first length and a second length between the first target area and the second target area, wherein the first length is a distance between a first pixel in the first target area and a second pixel in the second target area, and the second length is a distance between a third pixel in the first target area and a fourth pixel in the second target area, wherein the first pixel is a pixel farthest from the second target area, the second pixel is a pixel farthest from the first target area, the third pixel is a pixel closest to the second target area, and the fourth pixel is a pixel closest to the second target area; determining an initial facial area according to the first length and the second length, and determining a target facial area in the initial facial area according to the third pixel and the fourth pixel.

[0137] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0138] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0139] In the above-mentioned embodiments of the present application, the collected information is information and data authorized by the target object or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary protection measures, do not violate public order and good morals, and provide corresponding operation entrances for the target object to choose to authorize or refuse.

[0140] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0141] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0142] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0143] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.

[0144] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for processing an image, characterized in that: include: Acquire a picture to be processed, wherein the picture to be processed includes a plurality of pixel points; Determine an RGBA value of each pixel in the plurality of pixels, and determine a first target area and a second target area in the image to be processed according to the RGBA value of each pixel, wherein the first target area and the second target area have different pixel position information; Determine a first length and a second length between the first target area and the second target area, wherein the first length is the distance between a first pixel point in the first target area and a second pixel point in the second target area, and the second length is the distance between a third pixel point in the first target area and a fourth pixel point in the second target area, the first pixel point is the pixel point farthest from the second target area, the second pixel point is the pixel point farthest from the first target area, the third pixel point is the pixel point closest to the second target area, and the fourth pixel point is the pixel point closest to the second target area; An initial facial region is determined according to the first length and the second length, and a target facial region is determined in the initial facial region according to the third pixel point and the fourth pixel point.

2. The method according to claim 1, characterized in that: The first target area includes: a first area and a second area, the second target area includes: a third area and a fourth area, the R values ​​of the pixels in the first area and the third area are both within the first preset range, the G values ​​are both within the second preset range, the B values ​​are both within the third preset range, and the A values ​​are both within the fourth preset range, the R values ​​of the pixels in the second area and the fourth area are both within the fifth preset range, the G values ​​are both within the sixth preset range, the B values ​​are both within the seventh preset range, and the A values ​​are both within the eighth preset range.

3. The method according to claim 2, characterized in that The image to be processed includes n rows of pixels, where n is a positive integer greater than 2; Determining a first target area and a second target area in the image to be processed according to the RGBA value of each pixel point includes: For the first row of pixels, from left to right, a scanning operation is performed on each pixel to determine the 11th sub-region and the 12th sub-region in the first row of pixels, wherein the pixel positions of the 11th sub-region and the 12th sub-region are different, and in the 11th sub-region and the 12th sub-region, m1 consecutive pixels meet a first preset requirement, and the first preset requirement includes: the R value of the pixel is within the first preset range, the G value is within the second preset range, the B value is within the third preset range, and the A value is within the fourth preset range, or the R value of the pixel is within the fifth preset range, the G value is within the sixth preset range, the B value is within the seventh preset range, and the A value is within the eighth preset range, and m is a positive integer greater than 1; For the pixel points in the i-th row, a scanning operation is performed on each pixel point from left to right to determine the i1-th sub-region and the i2-th sub-region of the pixel points in the i-th row, wherein the pixel positions of the i1-th sub-region and the i2-th sub-region are different, and within the i1-th sub-region and the i2-th sub-region, there are m consecutive i pixel points meet the first preset requirement, i is a positive integer greater than 1 and less than n; For the nth row of pixels, a scanning operation is performed on each pixel from left to right to determine the n1th sub-region and the n2th sub-region of the nth row of pixels, wherein the n1th sub-region and the n2th sub-region have different pixel positions, and within the n1th sub-region and the n2th sub-region, there are m consecutive n pixels satisfy the first preset requirement; performing splicing processing on the 11th sub-region, the i1th sub-region and the n1th sub-region to obtain the first target region; The 12th sub-region, the i2th sub-region and the n2th sub-region are spliced ​​to obtain the second target region.

4. The method according to claim 3, characterized in that Determining a first length and a second length between the first target area and the second target area includes: Determine the leftmost pixel in the n first sub-areas as the first pixel; Determine the rightmost pixel in the n second sub-areas as the second pixel; Determine the rightmost pixel point in the n first sub-areas as the third pixel point; Determine the leftmost pixel point in the n second sub-areas as the fourth pixel point; Determine the first length according to the first pixel point and the third pixel point; The second length is determined according to the second pixel point and the fourth pixel point.

5. The method according to claim 1, characterized in that Determining an initial facial region according to the first length and the second length includes: Determine a first midpoint of a line segment formed by the first pixel point and the third pixel point; Determine a second midpoint of a line segment formed by the second pixel point and the fourth pixel point; Taking the first midpoint as the base point, extend the first target area in the left-right direction by u times the first length and in the upward-downward direction by v times the second length to obtain a third target area, where u and v are positive numbers; Taking the second midpoint as the base point, extending the second target area in the left-right direction by u times the first length and in the upward-downward direction by v times the second length, to obtain a fourth target area; The initial facial region is determined according to the third target region and the fourth target region.

6. The method according to claim 1, characterized in that The initial facial area includes k rows of pixels, where k is a positive integer greater than 2; Determining a facial region in the initial facial region according to the third pixel and the fourth pixel includes: Determine a third midpoint of a line segment formed by the third pixel point and the fourth pixel point; With the third midpoint as the center and a preset length as the radius, a first circular area is generated; Obtain the range of RGBA values ​​of pixels within the first circular area; For the first row of pixels, a scanning operation is performed on y pixels from left to right to determine a plurality of first sub-regions of the first row of pixels, wherein in each first sub-region, RGBA values ​​of a preset proportion of the y pixels are within a first range, wherein the first range is a range of RGBA values ​​of the pixels within the first circular region, and y is a positive integer; For the j-th row of pixels, performing a scanning operation on y pixels from left to right to determine a plurality of j-th sub-regions of the j-th row of pixels, wherein in each j-th sub-region, RGBA values ​​of a preset proportion of the y pixels are within the first range; For the k-th row of pixels, performing a scanning operation on y pixels from left to right to determine a plurality of k-th sub-regions of the k-th row of pixels, wherein in each k-th sub-region, RGBA values ​​of a preset proportion of the y pixels are within the first range; The plurality of first sub-regions, the plurality of j-th sub-regions, and the plurality of k-th sub-regions are spliced ​​and drawn to obtain the facial region.

7. The method according to any one of claims 1 to 6, characterized in that: After determining the facial region in the initial facial region, the method further includes: Adjusting the size of the facial region to a target size to obtain a first facial image, wherein the target size is the size of a preset facial image in a preset model; Replacing the preset facial image with the first facial image to obtain a target model; The target model is displayed.

8. The method according to claim 7, characterized in that After displaying the target model, the method further includes: Receive a selection result of the target object on the target model, and if the target object does not select the target model, perform the following steps: Acquire a first image to be processed uploaded by the target object, wherein the first image to be processed includes a first facial area; Determine pixel information of a plurality of pixels in the first picture to be processed; Obtaining the first click behavior on the first to-be-processed image; Determine a first point corresponding to the first click behavior, and determine and record a pixel position of the first point; Acquire a mouse activity track on the first to-be-processed picture, wherein the mouse activity track includes a plurality of second points; In a case where the plurality of second points include a second point that coincides with the first point, determining and recording a pixel position of each of the second points; According to the pixel information of a plurality of pixel points in the first to-be-processed picture and the pixel position of each of the second points, an image of an area enclosed by each of the second points is drawn to obtain a first facial image; The first facial image is displayed.

9. The method according to claim 2, characterized in that: The first preset range includes: [200-255], the second preset range includes: [200-255], the third preset range includes: [200-255], the fourth preset range includes: 255, the fifth preset range includes: [0-50], and the sixth preset range includes: [0-50], the seventh preset range includes: [0-50], and the eighth preset range includes:

255.

10. A picture processing device, characterized in that: include: An acquisition module is used to acquire a picture to be processed, wherein the picture to be processed includes a plurality of pixels; a first determining module, configured to determine an RGBA value of each pixel of the plurality of pixels, and determine a first target area and a second target area in the image to be processed according to the RGBA value of each pixel, wherein the pixel position information of the first target area is different from that of the second target area; A second determination module is used to determine a first length and a second length between the first target area and the second target area, wherein the first length is the distance between a first pixel point in the first target area and a second pixel point in the second target area, and the second length is the distance between a third pixel point in the first target area and a fourth pixel point in the second target area, the first pixel point is the pixel point farthest from the second target area, the second pixel point is the pixel point farthest from the first target area, the third pixel point is the pixel point closest to the second target area, and the fourth pixel point is the pixel point closest to the second target area; The third determining module is used to determine an initial facial region according to the first length and the second length, and determine a target facial region in the initial facial region according to the third pixel point and the fourth pixel point.

11. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored program, wherein when the program is executed, the device where the non-volatile storage medium is located is controlled to execute the image processing method according to any one of claims 1 to 9.

12. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the program executes the image processing method described in any one of claims 1 to 9 when running.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the image processing method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Image segmentation information generation method and device, equipment and storage medium

    CN110853056A

  • Image processing method and device

    CN114596213A

  • Method for detecting a human face and an apparatus of the same

    US20010036298A1