CN114333030A - Image processing method, device, equipment and storage medium - Google Patents

Image processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN114333030A
CN114333030A CN202111679330.4A CN202111679330A CN114333030A CN 114333030 A CN114333030 A CN 114333030A CN 202111679330 A CN202111679330 A CN 202111679330A CN 114333030 A CN114333030 A CN 114333030A
Authority
CN
China
Prior art keywords
image
target
pixel
sub
center position
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111679330.4A
Other languages
Chinese (zh)
Inventor
陈松
沈义
龙明康
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
iFlytek Co Ltd
Original Assignee
iFlytek Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by iFlytek Co Ltd filed Critical iFlytek Co Ltd
Priority to CN202111679330.4A priority Critical patent/CN114333030A/en
Publication of CN114333030A publication Critical patent/CN114333030A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the application discloses an image processing method, an image processing device, image processing equipment and a storage medium, wherein the image processing method, the image processing device, the image processing equipment and the storage medium are used for carrying out face detection on a target image so as to obtain an image mask of a face area; determining a regular hexagon frame covering the face region based on the image mask; and cutting an area covered by the regular hexagonal frame from the target image to serve as a target sub-image, wherein the target sub-image is used for face matching. According to the image processing method provided by the embodiment of the application, when the subimage used for face matching is intercepted from the target image, the subimage containing the regular hexagon of the face area is intercepted, and then the face matching is carried out based on the subimage containing the regular hexagon.

Description

Image processing method, device, equipment and storage medium
Technical Field
The present application relates to the field of image processing technologies, and in particular, to an image processing method, an image processing apparatus, an image processing device, and a storage medium.
Background
With the continuous progress of computer software and hardware technology in modern society, the robot face recognition system is increasingly deeply integrated into our lives. The main idea of the face recognition technology is as follows: collecting images, positioning the face position according to a face recognition algorithm, and cutting out the face part from the collected images and sending the face part into a face library for matching and distinguishing. The increasingly large face libraries are matched with algorithms quickly, and the database storage has higher requirements, so that how to optimize the existing face recognition technology becomes a technical problem to be solved urgently.
Disclosure of Invention
In view of the above, the present application provides an image processing method, apparatus, device and storage medium to optimize a face recognition technology.
In order to achieve the above object, the following solutions are proposed:
an image processing method comprising:
carrying out face detection on the target image to obtain an image mask of a face area;
determining a regular hexagon box covering the face region based on the image mask;
and cutting the area covered by the regular hexagonal frame from the target image to be used as a target sub-image, wherein the target sub-image is used for face matching.
In the above method, preferably, the determining a regular hexagon box covering the face region based on the image mask includes:
determining the length and the width of the minimum circumscribed rectangle of the face region according to the image mask;
and determining the center position and the side length of the regular hexagon frame based on the length and the width of the minimum bounding rectangle.
Preferably, the determining the length and the width of the minimum bounding rectangle of the face region according to the image mask includes:
scanning the image mask line by line to determine the first pixel at the top and the second pixel at the bottom in the image mask;
scanning the image mask column by column to determine a third pixel located leftmost and a fourth pixel located rightmost in the image mask;
and determining the vertical distance between the column of the third pixel and the column of the fourth pixel as the length of the minimum circumscribed rectangle, and determining the vertical distance between the row of the first pixel and the row of the second pixel as the width of the minimum circumscribed rectangle.
Preferably, the determining the center position and the side length of the regular hexagon frame based on the length and the width of the minimum bounding rectangle includes:
determining the central position of the minimum circumscribed rectangle as the central position of the regular six deformation by using the first pixel, the second pixel, the third pixel and the fourth pixel, and the length and the width of the minimum circumscribed rectangle;
determining the maximum value of the length and the width of the minimum bounding rectangle as the distance of opposite sides of the regular hexagonal frame;
the side length of the regular hexagonal box is determined based on the distance of the opposite side.
The above method, preferably, further comprises:
and saving the target sub-image as a reference image into a database.
The above method, preferably, further comprises:
respectively matching the target sub-image with each reference image in a database to determine a reference image matched with the target sub-image;
the reference image is a regular hexagon image.
The above method, preferably, further comprises:
under the condition that a reference image matched with the target sub-image is not found, acquiring an extended sub-image in the target image; wherein the extended subimage is: the regular hexagon image has the same central position as the target sub-image and the side length is larger than that of the target sub-image; or the expansion sub-image comprises the target sub-image and partial neighbor sub-images of the target sub-image; the neighbor sub-images of the target sub-images are regular hexagonal images;
and respectively matching the expansion sub-image with each reference image in a database to determine a reference image matched with the expansion sub-image.
In the above method, preferably, the acquiring an extended sub-image in the target image includes:
determining the central position of each neighbor sub-image of the target sub-image according to the central position and the side length of the regular hexagonal frame;
determining the central position of a neighbor subimage which meets a preset position relation with the central position of the regular hexagon frame as a target central position;
corresponding to each target center position, determining pixels located in a hexagon represented by the target center position based on the distance between the pixels and the target center position;
the target sub-images and the hexagonally overlaid neighbor sub-images represented by the respective target center positions constitute the extended sub-images.
Preferably, the method for determining the pixels located in the hexagon represented by the target center position based on the distance between the pixels and the target center position includes:
determining a circumscribed rectangle of the regular hexagon represented by the target center position according to the target center position and the side length of the regular hexagon;
for each pixel within the circumscribed rectangle, it is determined whether the pixel is located within the hexagon represented by the target center position based on the distance between the pixel and the target center position.
Preferably, the determining whether the pixel is located within a hexagon represented by the target center position based on the distance between the pixel and the target center position includes:
calculating the distance between the pixel and the target center position;
if the distance between the pixel and the target central position is smaller than or equal to the radius of an inscribed circle of a regular hexagon represented by the target central position, determining that the pixel is positioned in the regular hexagon represented by the target central position;
if the distance between the pixel and the target central position is larger than the radius of the inscribed circle of the regular hexagon represented by the target central position, calculating the distance between the pixel and the central position of each neighbor regular hexagon of the regular hexagon represented by the target central position;
and if the distance between the pixel and the center position of each adjacent regular hexagon of the regular hexagon represented by the target center position is larger than the distance between the pixel and the target center position, determining that the pixel is positioned in the regular hexagon represented by the target center position.
Preferably, the determining whether the pixel is located within a hexagon represented by the target center position based on the distance between the pixel and the target center position includes:
determining the central position of each regular hexagon in the target image if the target image is densely paved by the regular hexagons;
calculating the distance between the pixel and the center position of each regular hexagon;
if the distance between the pixel and the target center position is minimum, the pixel is determined to be positioned in a regular hexagon represented by the target center position.
An image processing apparatus comprising:
the detection module is used for carrying out face detection on the target image so as to obtain an image mask of a face area;
a determining module for determining a regular hexagon box covering the face region based on the image mask;
and the cutting module is used for cutting the target sub-image in the regular hexagon frame from the target image, and the target sub-image is used for face matching.
An image processing apparatus includes a memory and a processor;
the memory is used for storing programs;
the processor is configured to execute the program to implement the steps of the image processing method according to any one of the above.
A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the image processing method according to any one of the preceding claims.
According to the technical scheme, the image processing method, the device, the equipment and the storage medium provided by the embodiment of the application carry out face detection on the target image so as to obtain an image mask of a face area; determining a regular hexagon frame covering the face region based on the image mask; and cutting an area covered by the regular hexagonal frame from the target image to serve as a target sub-image, wherein the target sub-image is used for face matching. According to the image processing method provided by the embodiment of the application, when the subimage used for face matching is intercepted from the target image, the subimage containing the regular hexagon of the face area is intercepted, and then the face matching is carried out based on the subimage containing the regular hexagon.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flow chart of an implementation of an image processing method disclosed in an embodiment of the present application;
fig. 2 is a schematic comparison diagram of selecting a face region by using a square frame and selecting a face region by using a regular hexagon frame, which are disclosed in the embodiment of the present application;
fig. 3 is an exemplary diagram of a real face region framed using squares and using regular hexagons according to an embodiment of the present disclosure;
FIG. 4 is a flow chart of one implementation of determining a regular hexagon box covering a face region based on an image mask as disclosed in an embodiment of the present application;
FIG. 5 is a flowchart of one implementation of determining the length and width of a minimum bounding rectangle for a face region based on an image mask, as disclosed in an embodiment of the present application;
FIG. 6 is an exemplary diagram of a first pixel, a second pixel, a third pixel, and a fourth pixel determined by scanning an image mask as disclosed in an embodiment of the present application;
FIG. 7 is an exemplary illustration of a plurality of hexagonal subimages densely tiled in a target image as disclosed in an embodiment of the present application;
FIG. 8 is a flowchart of one implementation of obtaining an extended sub-image in a target image according to an embodiment of the disclosure;
FIG. 9 is a flow chart of one implementation of determining pixels located within a hexagon represented by a target center position based on a distance between the pixel and the target center position as disclosed in an embodiment of the present application;
FIG. 10 is a flow chart of one implementation of determining whether a pixel is located within a hexagon represented by a target center position based on a distance between the pixel and the target center position as disclosed in an embodiment of the present application;
FIG. 11 is a flow chart illustrating one implementation of determining whether a pixel is located within a hexagon represented by a target center position based on a distance between the pixel and the target center position as disclosed in an embodiment of the present application;
fig. 12 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present application;
fig. 13 is a block diagram of a hardware configuration of an image processing apparatus disclosed in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The inventor of the present application finds that, with the use of a face recognition system, data in a face database will increase gradually, which will cause face matching to consume more time, and at the same time, will bring more pressure on a database storing images. Moreover, when the face position is located by the conventional face recognition technology, the face area is selected by a square frame, the square area containing the face is cut out from the image, the cut square area is sent to a face library for matching, and the reference image stored in the face library is also a square image. The face recognition method enables the calculation amount of face matching and the data amount stored in a face library to be large.
The scheme of the application is provided for optimizing the face recognition method.
As shown in fig. 1, a flowchart for implementing an image processing method provided in an embodiment of the present application may include:
step S101: and carrying out face detection on the target image to obtain an image mask of a face area.
The face detection of the target image refers to detecting whether a face exists in the target image, and if the face exists in the target image, generating an image mask of a face area.
As an example, the image mask of the face region may be obtained by a skin color detection method, or the image mask of the face region may also be obtained by other methods, for example, the face detection based on the structural features of the two eyes of the face, which is not limited in this application.
Step S102: a regular hexagonal box covering the face region is determined based on the image mask.
In the embodiment of the application, when the face area is selected, the square is not used as the identification frame, but the regular hexagon is used as the identification frame.
As shown in fig. 2, a schematic diagram of comparison between the use of square framing and the use of regular hexagon framing for selecting a face region is provided in the embodiment of the present application. In this exampleFor comparison, a circle (denoted as a circle a) is used to represent a face, a traditional frame selection scheme uses a circumscribed square of the circle a as a face recognition frame as shown in fig. 2-a, while the circumscribed regular hexagon of the circle a is used as a face recognition frame in the present application as shown in fig. 2-b. Assuming that the radius of the circle a is r, the side length of the circumscribed square of the circle a is 2r, and the area S1 of the circumscribed square is 4r2The side length of the circumscribed regular hexagon of the circle A is
Figure BDA0003453518140000071
Area of external regular hexagon
Figure BDA0003453518140000072
It can be seen that, for the same face size, the area of the external regular hexagon is smaller than that of the external square by more than 10%, so that more than 10% of pixels can be saved by using the external regular hexagon to frame the face than by using the square to frame the face, which means that the data amount of image data to be processed in the face recognition process can be reduced by 10%, and meanwhile, the stored data can be reduced by 10%, and the storage pressure of the database can be detected to a certain extent.
As shown in fig. 3, for an exemplary diagram of using a square and using a regular hexagon to frame a real face region provided in the embodiment of the present application, it can be seen that the area of the region framed using the regular hexagon is smaller than the area of the region framed using the square.
Step S103: and cutting an area covered by the regular hexagonal frame from the target image to serve as a target sub-image, wherein the target sub-image is used for face matching.
According to the image processing method provided by the embodiment of the application, when the subimage used for face matching is intercepted from the target image, the subimage containing the regular hexagon of the face area is intercepted, and then the face matching is carried out based on the subimage containing the regular hexagon.
In an alternative embodiment, a flowchart of the above-mentioned implementation of determining a regular hexagon box covering a face region based on an image mask is shown in fig. 4, and may include:
step S401: and determining the length and the width of the minimum bounding rectangle of the face region according to the image mask.
As an example, the minimum bounding rectangle of the face region of the image mask may be determined first, and then the length and width of the minimum bounding rectangle of the face region may be determined.
As an example, the minimum bounding rectangle of the face region of the image mask may be not determined, and the length and width of the minimum bounding rectangle of the face region may be directly calculated.
Step S402: and determining the center position and the side length of the regular hexagon frame based on the length and the width of the minimum circumscribed rectangle of the face region.
The center position of the minimum circumscribed rectangle can be determined based on the length and the width of the minimum circumscribed rectangle of the face region, the center position of the minimum circumscribed rectangle of the face region is used as the center position of the regular hexagon frame, and the side length of the regular hexagon frame can be determined based on the maximum value of the length and the width of the minimum circumscribed rectangle.
In an alternative embodiment, a flowchart of an implementation of the above determining the length and width of the minimum bounding rectangle of the face region according to the image mask is shown in fig. 5, and may include:
step S501: the image mask is scanned line by line to determine the uppermost first pixel and the lowermost second pixel in the image mask.
Step S502: the image mask is scanned column-by-column to determine a third pixel located leftmost and a fourth pixel located rightmost in the image mask.
The execution sequence of steps S501 and S502 is not limited in the present application, and step S501 may be executed first and then step S502 is executed, or step S502 may be executed first and then step S501 is executed.
Step S503: and determining the vertical distance between the column of the third pixel and the column of the fourth pixel as the length of the minimum bounding rectangle, and determining the vertical distance between the row of the first pixel and the row of the second pixel as the width of the minimum bounding rectangle.
As an example, coordinates of four vertices of a minimum bounding rectangle of the face region may be determined according to coordinates of the first pixel, the second pixel, the third pixel, and the fourth pixel, and then a length and a width of the minimum bounding rectangle may be calculated according to the coordinates of the four vertices.
As an example, the width of the minimum bounding rectangle may be directly calculated from the coordinates of the first pixel and the second pixel, and the length of the minimum bounding rectangle may be calculated from the coordinates of the third pixel and the fourth pixel.
As an example, as shown in fig. 6, an exemplary diagram of a first pixel a (x1, y1), a second pixel b (x2, y2), a third pixel c (x3, y3), and a fourth pixel d (x4, y4) determined by scanning an image mask is provided for the embodiment of the present application.
In the example shown in fig. 6, the coordinates of the 4 vertices of the minimum bounding rectangle of the face region may be determined to be (x4, y1), (x3, y1), (x3, y2), (x4, y2), respectively.
By way of example, the length of the minimum bounding rectangle may be determined to be x3-x4 based on the coordinates (x4, y1) and (x3, y1), and the width of the minimum bounding rectangle may be determined to be y2-y1 based on the coordinates (x3, y1), (x3, y 2).
As an example, the width w of the minimum bounding rectangle may also be determined from the first pixel a and the second pixel b as y2-y 1. It is also determined from the third pixel c and the fourth pixel d that the length of the minimum bounding rectangle is h ═ x3-x 4.
In an alternative embodiment, one implementation manner of determining the center position and the side length of the regular hexagon frame based on the length and the width of the minimum bounding rectangle may be as follows:
and determining the central position of the minimum circumscribed rectangle as the central position of the positive six deformation by using the first pixel, the second pixel, the third pixel and the fourth pixel and the length and the width of the minimum circumscribed rectangle.
Taking fig. 6 as an example, assuming that the point at the middle position of the minimum bounding rectangle is o (x5, x6), there are:
x5=x4+h/2,y5=y1+w/2。
determining the maximum value of the length and the width of the minimum circumscribed rectangle as the opposite side distance of the regular hexagon frame; the side length of the regular hexagonal box is determined based on the distance of the opposite side.
By way of example, if h ≧ w, the distance of the opposite side of the regular hexagonal box is determined to be h, and the side length of the corresponding regular hexagonal box is:
Figure BDA0003453518140000091
if h is<w, determining the opposite side distance of the regular hexagonal frame as w, and the side length of the corresponding regular hexagonal frame as:
Figure BDA0003453518140000092
in an optional embodiment, the image processing method provided in the embodiment of the present application may further include: and saving the target sub-image as a reference sub-image in a database.
In the embodiment of the present application, if a reference image of a human face needs to be entered into a database, a hexagonal target sub-image may be cut out from an acquired image by the image processing method described in the foregoing embodiment and stored in the database (that is, a human face library).
In an optional embodiment, the image processing method provided in the embodiment of the present application may further include:
and respectively matching the target sub-image with each reference image in a database (namely a human face library) to determine a reference image matched with the target sub-image.
The reference image in the database is a regular hexagon image of the face region obtained based on the image processing method.
The specific matching method can adopt the existing relatively mature method, and is not detailed here.
Further, if the reference image matched with the target sub-image is not found in the database, the extended sub-image can be obtained in the target image, and the extended sub-image is matched with each reference image in the database respectively to determine the reference image matched with the extended sub-image.
As an example, corresponding to each reference image, the reference image may be moved in a traversing manner in the extended sub-image, and when the reference image is moved to a position, the similarity of the reference image and the region of the extended sub-image where the reference image is located is calculated, and the region of the extended sub-image where the matching degree with the reference image is the maximum is taken as a candidate region; thus, a candidate area can be determined in the extended sub-image for each reference image.
And selecting one candidate region from the candidate regions corresponding to the reference images as a target candidate region, wherein the matching degree of the target candidate region and the corresponding reference image is greater than that of the non-target candidate region and the corresponding reference image.
And if the matching degree of the target candidate area and the corresponding reference image is greater than or equal to the threshold value, determining that the reference image corresponding to the target candidate area is the reference image matched with the expansion sub-image.
In an alternative embodiment, the expansion sub-image may be a new regular hexagon image having the same center position as the target sub-image, and the side length of the new regular hexagon image is larger than that of the target sub-image.
In an alternative embodiment, the expansion sub-image includes the target sub-image and a partial neighbor sub-image of the target sub-image.
And the side length of the neighbor sub-image is the same as that of the target sub-image. Each target sub-image may have six neighbor sub-images. As shown in fig. 7, an exemplary diagram of a plurality of hexagonal sub-images densely paved in a target image is provided for the embodiment of the present application. In fig. 7, assuming that the target sub-image is the region of the regular hexagon I, the six neighboring sub-images of the target sub-image are the regions covered by the six regular hexagons P in fig. 7, i.e. the region covered by each regular hexagon P is a neighboring sub-image of the target sub-image.
When the extended sub-image is obtained, partial neighbor sub-images are selected from six neighbor sub-images of the target sub-image to be used as a part of the extended sub-image.
Optionally, an implementation flowchart of obtaining an extended sub-image in a target image according to an embodiment of the present application is shown in fig. 8, and may include:
step S801: and determining the central position of each neighbor sub-image of the target sub-image according to the central position and the side length of the regular hexagonal frame.
Taking fig. 7 as an example, assuming that the area covered by the regular hexagon I is the target sub-image, the coordinates of the center point of the target sub-image are (X, Y), and the side length of the regular hexagon is (X, Y)
Figure BDA0003453518140000111
The coordinates of the center positions of the neighboring sub-images covered by the neighboring sub-images (i.e. the regular hexagons P) of the target sub-image are:
(X,Y+h),(X,Y-h),
Figure BDA0003453518140000112
Figure BDA0003453518140000113
step S802: and determining the central position of the neighbor subimage which meets the preset position relation with the central position of the regular hexagon frame as the target central position.
In the embodiment of the application, the center position of part of the neighbor sub-images can be determined as the target center position according to the direction of the face. Alternatively, it may be assumed that the direction of the face of the target sub-image from the head to the chin is the reference direction, and based on the reference direction, the center position of the partial neighbor sub-image located below the regular hexagonal frame may be selected as the target center position.
Taking fig. 7 as an example, assuming that the direction of the face in the target sub-image is from the direction of the regular hexagon P No. 1 to the direction of the regular hexagon P No. 4, the center positions of the three regular hexagons No. 3-5 can be selected as the three target center positions.
Assuming that the direction of the face in the target sub-image is from the boundary line of the regular hexagon P No. 1 or 6 to the boundary line of the regular hexagon P No. 3 or 4, the center positions of three regular hexagons No. 3 to 4 may be selected as two target center positions, or the center positions of four regular hexagons No. 2 to 5 may be selected as four target center positions.
Step S803: for each target center location, pixels located within the hexagon represented by the target center location are determined based on the distance between the pixel and the target center location.
That is, after determining the center position of the regular hexagon, it is necessary to determine which pixels belong to the regular hexagon represented by the center position, so as to determine the sub-image area covered by the regular hexagon.
The target sub-images and the hexagonally overlaid neighbor sub-images represented by the respective target center positions constitute the extended sub-images.
In an alternative embodiment, a flowchart for determining pixels located in a hexagon represented by the target center position based on a distance between the pixel and the target center position according to an implementation provided by the embodiment of the present application is shown in fig. 9, and may include:
step S901: and determining the circumscribed rectangle of the regular hexagon represented by the target center position according to the target center position and the side length of the regular hexagon.
The circumscribed rectangle of a regular hexagon refers to the smallest rectangle that contains a regular hexagon, wherein a set of opposing sides of the regular hexagon overlap with a set of opposing sides of the circumscribed rectangle.
Step S902: for each pixel within the circumscribed rectangle, it is determined whether the pixel is located within the hexagon represented by the target center position based on the distance between the pixel and the target center position.
That is to say, the method and the device only need to judge whether the pixels located in the external rectangle of the regular hexagon in the target image are located in the regular hexagon or not, and whether one pixel is located in the external rectangle area or not, and can determine the pixel by comparing the coordinate relation of the four fixed points of the pixel and the external rectangle without obtaining the pixel through calculation, so that the image processing flow is simplified, and the data processing amount is reduced.
In an alternative embodiment, the flowchart for determining whether the pixel is located within the hexagon represented by the target center position based on the distance between the pixel and the target center position as shown in fig. 10 may include:
step S1001: and determining the central position of each regular hexagon in the target image if the target image is densely paved by the regular hexagons.
For a specific calculation manner, reference may be made to the embodiment shown in fig. 8, which is not described herein again.
Step S1002: the distance of the pixel from the center position of each regular hexagon is calculated.
Alternatively, for each regular hexagon, the euclidean distance between the pixel and the center position of the regular hexagon may be calculated. Of course, other distance measures, such as the D4 distance, may be used in addition to the euclidean distance.
Step S1003: if the distance between the pixel and the target center position is minimum, the pixel is determined to belong to a regular hexagon represented by the target center position.
In an alternative embodiment, the flowchart for determining whether the pixel is located within the hexagon represented by the target center position based on the distance between the pixel and the target center position as shown in fig. 11 may include:
step S1101: and calculating the distance between the pixel and the target center position, and if the distance between the pixel and the target center position is smaller than or equal to the radius of an inscribed circle of the regular hexagon represented by the target center position, entering step S1102, otherwise, entering step S1103.
Alternatively, the euclidean distance between the pixel and the target center position may be calculated. Of course, other distance measures, such as the D4 distance, may be used in addition to the euclidean distance.
Step S1102: determining that the pixel is located within a regular hexagon represented by the target center position;
the radius of the inscribed circle of the regular hexagon shown in the target center position is half of the distance of opposite sides of the regular hexagon.
Step S1103: the distance between the pixel and the center position of each neighboring regular hexagon of the regular hexagon represented by the target center position is calculated.
Taking fig. 7 as an example, assuming that the center position of the regular hexagon I is the target center position, if the distance between the pixel and the target center position is greater than the radius of the inscribed circle of the regular hexagon I, the distance between the pixel and the center position of each regular hexagon P is calculated.
Step S1104: and if the distance between the pixel and the center position of each adjacent regular hexagon of the regular hexagon represented by the target center position is larger than the distance between the pixel and the target center position, determining that the pixel is positioned in the regular hexagon represented by the target center position.
And if the distance between the pixel and the center position of the regular hexagon I is smaller than the distance between the pixel and the center position of each regular hexagon P, determining that the pixel is positioned in the regular hexagon I.
Corresponding to the method embodiment, an embodiment of the present application further provides an image processing apparatus, and a schematic structural diagram of the image processing apparatus provided in the embodiment of the present application is shown in fig. 12, and the image processing apparatus may include:
a detection module 1201, a determination module 1202 and a cutting module 1203; wherein the content of the first and second substances,
the detection module 1201 is configured to perform face detection on the target image to obtain an image mask of a face region;
a determination module 1202 for determining a regular hexagon box covering the face region based on the image mask;
the cropping module 1203 is configured to crop a target sub-image in the regular hexagon frame from the target image, where the target sub-image is used for face matching.
The image processing device provided by the embodiment of the application intercepts the sub-image used for face matching from the target image, intercepts the sub-image containing the regular hexagon of the face area, and then carries out face matching based on the sub-image containing the regular hexagon.
In an optional embodiment, the determining module includes:
the first determining module is used for determining the length and the width of the minimum circumscribed rectangle of the face region according to the image mask;
and the second determination module is used for determining the center position and the side length of the regular hexagon frame based on the length and the width of the minimum circumscribed rectangle.
In an optional embodiment, the first determining module is configured to:
scanning the image mask line by line to determine the first pixel at the top and the second pixel at the bottom in the image mask;
scanning the image mask column by column to determine a third pixel located leftmost and a fourth pixel located rightmost in the image mask;
and determining the vertical distance between the column of the third pixel and the column of the fourth pixel as the length of the minimum circumscribed rectangle, and determining the vertical distance between the row of the first pixel and the row of the second pixel as the width of the minimum circumscribed rectangle.
In an optional embodiment, the second determining module is configured to:
determining a center position of the minimum bounding rectangle as a center position of the positive six deformation based on the first, second, third, and fourth pixels and the length and width of the minimum bounding rectangle;
determining the maximum value of the length and the width of the minimum bounding rectangle as the distance of opposite sides of the regular hexagonal frame;
the side length of the regular hexagonal box is determined based on the distance of the opposite side.
In an optional embodiment, the apparatus further comprises:
and the storage module is used for storing the target sub-image as a reference image into a database.
In an optional embodiment, the apparatus further comprises:
the matching module is used for respectively matching the target sub-image with each reference image in a database so as to determine a reference image matched with the target sub-image;
the reference image is a regular hexagon image.
In an optional embodiment, the apparatus further comprises:
the acquisition module is used for acquiring an extended sub-image in the target image under the condition that a reference image matched with the target sub-image is not found; wherein the extended subimage is: the regular hexagon image has the same central position as the target sub-image and the side length is larger than that of the target sub-image; or the expansion sub-image comprises the target sub-image and partial neighbor sub-images of the target sub-image; the neighbor sub-images of the target sub-images are regular hexagonal images;
the matching module is further used for respectively matching the expansion sub-image with each reference image in a database so as to determine a reference image matched with the expansion sub-image.
In an optional embodiment, the obtaining module is configured to:
determining the central position of each neighbor sub-image of the target sub-image according to the central position and the side length of the regular hexagonal frame;
determining the central position of a neighbor subimage which meets a preset position relation with the central position of the regular hexagon frame as a target central position;
corresponding to each target center position, determining pixels located in a hexagon represented by the target center position based on the distance between the pixels and the target center position;
the target sub-images and the hexagonally overlaid neighbor sub-images represented by the respective target center positions constitute the extended sub-images.
In an optional embodiment, when determining the pixel located in the hexagon represented by the target center position based on the distance between the pixel and the target center position, the obtaining module is configured to:
determining a circumscribed rectangle of the regular hexagon represented by the target center position according to the target center position and the side length of the regular hexagon;
for each pixel within the circumscribed rectangle, it is determined whether the pixel is located within the hexagon represented by the target center position based on the distance between the pixel and the target center position.
In an optional embodiment, the obtaining module, when determining whether the pixel is located within a hexagon represented by the target center position based on the distance between the pixel and the target center position, is configured to:
calculating the distance between the pixel and the target center position;
if the distance between the pixel and the target central position is smaller than or equal to the radius of an inscribed circle of a regular hexagon represented by the target central position, determining that the pixel is positioned in the regular hexagon represented by the target central position;
if the distance between the pixel and the target central position is larger than the radius of the inscribed circle of the regular hexagon represented by the target central position, calculating the distance between the pixel and the central position of each neighbor regular hexagon of the regular hexagon represented by the target central position;
and if the distance between the pixel and the center position of each adjacent regular hexagon of the regular hexagon represented by the target center position is larger than the distance between the pixel and the target center position, determining that the pixel is positioned in the regular hexagon represented by the target center position.
In an optional embodiment, the obtaining module, when determining whether the pixel is located within a hexagon represented by the target center position based on the distance between the pixel and the target center position, is configured to:
determining the central position of each regular hexagon in the target image if the target image is densely paved by the regular hexagons;
calculating the distance between the pixel and the center position of each regular hexagon;
if the distance between the pixel and the target center position is minimum, the pixel is determined to be positioned in a regular hexagon represented by the target center position.
The image processing device provided by the embodiment of the application can be applied to image processing equipment, such as a PC terminal, a cloud platform, a server cluster and the like. Alternatively, fig. 13 shows a block diagram of a hardware structure of the image processing apparatus, and referring to fig. 13, the hardware structure of the image processing apparatus may include: at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4;
in the embodiment of the application, the number of the processor 1, the communication interface 2, the memory 3 and the communication bus 4 is at least one, and the processor 1, the communication interface 2 and the memory 3 complete mutual communication through the communication bus 4;
the processor 1 may be a central processing unit CPU, or an application Specific Integrated circuit asic, or one or more Integrated circuits configured to implement embodiments of the present invention, etc.;
the memory 3 may include a high-speed RAM memory, and may further include a non-volatile memory (non-volatile memory) or the like, such as at least one disk memory;
wherein the memory stores a program and the processor can call the program stored in the memory, the program for:
carrying out face detection on the target image to obtain an image mask of a face area;
determining a regular hexagon box covering the face region based on the image mask;
and cutting the area covered by the regular hexagonal frame from the target image to be used as a target sub-image, wherein the target sub-image is used for face matching.
Alternatively, the detailed function and the extended function of the program may be as described above.
Embodiments of the present application further provide a storage medium, where a program suitable for execution by a processor may be stored, where the program is configured to:
carrying out face detection on the target image to obtain an image mask of a face area;
determining a regular hexagon box covering the face region based on the image mask;
and cutting the area covered by the regular hexagonal frame from the target image to be used as a target sub-image, wherein the target sub-image is used for face matching.
Alternatively, the detailed function and the extended function of the program may be as described above.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (14)

1. An image processing method, comprising:
carrying out face detection on the target image to obtain an image mask of a face area;
determining a regular hexagon box covering the face region based on the image mask;
and cutting the area covered by the regular hexagonal frame from the target image to be used as a target sub-image, wherein the target sub-image is used for face matching.
2. The method of claim 1, wherein determining a regular hexagonal box covering the face region based on the image mask comprises:
determining the length and the width of the minimum circumscribed rectangle of the face region according to the image mask;
and determining the center position and the side length of the regular hexagon frame based on the length and the width of the minimum bounding rectangle.
3. The method of claim 2, wherein determining the length and width of the minimum bounding rectangle for the face region from the image mask comprises:
scanning the image mask line by line to determine the first pixel at the top and the second pixel at the bottom in the image mask;
scanning the image mask column by column to determine a third pixel located leftmost and a fourth pixel located rightmost in the image mask;
and determining the vertical distance between the column of the third pixel and the column of the fourth pixel as the length of the minimum circumscribed rectangle, and determining the vertical distance between the row of the first pixel and the row of the second pixel as the width of the minimum circumscribed rectangle.
4. The method of claim 3, wherein the determining the center position and the side length of the regular hexagon box based on the length and the width of the minimum bounding rectangle comprises:
determining the central position of the minimum circumscribed rectangle as the central position of the regular six deformation by using the first pixel, the second pixel, the third pixel and the fourth pixel, and the length and the width of the minimum circumscribed rectangle;
determining the maximum value of the length and the width of the minimum bounding rectangle as the distance of opposite sides of the regular hexagonal frame;
the side length of the regular hexagonal box is determined based on the distance of the opposite side.
5. The method of any one of claims 1-4, further comprising:
and saving the target sub-image as a reference image into a database.
6. The method of any one of claims 1-4, further comprising:
respectively matching the target sub-image with each reference image in a database to determine a reference image matched with the target sub-image;
the reference image is a regular hexagon image.
7. The method of claim 6, further comprising:
under the condition that a reference image matched with the target sub-image is not found, acquiring an extended sub-image in the target image; wherein the extended subimage is: the regular hexagon image has the same central position as the target sub-image and the side length is larger than that of the target sub-image; or the expansion sub-image comprises the target sub-image and partial neighbor sub-images of the target sub-image; the neighbor sub-images of the target sub-images are regular hexagonal images;
and respectively matching the expansion sub-image with each reference image in a database to determine a reference image matched with the expansion sub-image.
8. The method of claim 7, wherein the obtaining an extended sub-image in the target image comprises:
determining the central position of each neighbor sub-image of the target sub-image according to the central position and the side length of the regular hexagonal frame;
determining the central position of a neighbor subimage which meets a preset position relation with the central position of the regular hexagon frame as a target central position;
corresponding to each target center position, determining pixels located in a hexagon represented by the target center position based on the distance between the pixels and the target center position;
the target sub-images and the hexagonally overlaid neighbor sub-images represented by the respective target center positions constitute the extended sub-images.
9. The method of claim 8, wherein determining pixels located within a hexagon represented by the target center position based on the distance between the pixels and the target center position comprises:
determining a circumscribed rectangle of the regular hexagon represented by the target center position according to the target center position and the side length of the regular hexagon;
for each pixel within the circumscribed rectangle, it is determined whether the pixel is located within the hexagon represented by the target center position based on the distance between the pixel and the target center position.
10. The method of claim 9, wherein determining whether the pixel is located within a hexagon represented by the target center position based on the distance between the pixel and the target center position comprises:
calculating the distance between the pixel and the target center position;
if the distance between the pixel and the target central position is smaller than or equal to the radius of an inscribed circle of a regular hexagon represented by the target central position, determining that the pixel is positioned in the regular hexagon represented by the target central position;
if the distance between the pixel and the target central position is larger than the radius of the inscribed circle of the regular hexagon represented by the target central position, calculating the distance between the pixel and the central position of each neighbor regular hexagon of the regular hexagon represented by the target central position;
and if the distance between the pixel and the center position of each adjacent regular hexagon of the regular hexagon represented by the target center position is larger than the distance between the pixel and the target center position, determining that the pixel is positioned in the regular hexagon represented by the target center position.
11. The method of claim 9, wherein determining whether the pixel is located within a hexagon represented by the target center position based on the distance between the pixel and the target center position comprises:
determining the central position of each regular hexagon in the target image if the target image is densely paved by the regular hexagons;
calculating the distance between the pixel and the center position of each regular hexagon;
if the distance between the pixel and the target center position is minimum, the pixel is determined to be positioned in a regular hexagon represented by the target center position.
12. An image processing apparatus characterized by comprising:
the detection module is used for carrying out face detection on the target image so as to obtain an image mask of a face area;
a determining module for determining a regular hexagon box covering the face region based on the image mask;
and the cutting module is used for cutting the target sub-image in the regular hexagon frame from the target image, and the target sub-image is used for face matching.
13. An image processing apparatus, comprising a memory and a processor;
the memory is used for storing programs;
the processor, which executes the program, implements the steps of the image processing method according to any one of claims 1 to 11.
14. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the image processing method according to any one of claims 1 to 11.
CN202111679330.4A 2021-12-31 2021-12-31 Image processing method, device, equipment and storage medium Pending CN114333030A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111679330.4A CN114333030A (en) 2021-12-31 2021-12-31 Image processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111679330.4A CN114333030A (en) 2021-12-31 2021-12-31 Image processing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114333030A true CN114333030A (en) 2022-04-12

Family

ID=81022302

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111679330.4A Pending CN114333030A (en) 2021-12-31 2021-12-31 Image processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114333030A (en)

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110136142A (en) * 2019-04-26 2019-08-16 微梦创科网络科技(中国)有限公司 A kind of image cropping method, apparatus, electronic equipment
CN110162138A (en) * 2019-04-10 2019-08-23 北京迈格威科技有限公司 Folding angles adjusting method, device and collapsible terminal
CN110782392A (en) * 2019-07-12 2020-02-11 北京达佳互联信息技术有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN111241992A (en) * 2020-01-08 2020-06-05 科大讯飞股份有限公司 Face recognition model construction method, recognition method, device, equipment and storage medium
CN111325051A (en) * 2018-12-13 2020-06-23 普天信息技术有限公司 Face recognition method and device based on face image ROI selection
CN111757098A (en) * 2020-06-30 2020-10-09 北京百度网讯科技有限公司 Debugging method and device of intelligent face monitoring camera, camera and medium
CN112016469A (en) * 2020-08-28 2020-12-01 Oppo广东移动通信有限公司 Image processing method and device, terminal and readable storage medium
CN112036317A (en) * 2020-08-31 2020-12-04 成都新潮传媒集团有限公司 Face image intercepting method and device and computer equipment
US20210133427A1 (en) * 2016-12-27 2021-05-06 Sharp Kabushiki Kaisha Image processing device, image printing device, imaging device, and non-transitory medium
CN113095119A (en) * 2020-01-09 2021-07-09 北京君正集成电路股份有限公司 Face recognition system for correcting face cutting frame
CN113269155A (en) * 2021-06-28 2021-08-17 苏州市科远软件技术开发有限公司 End-to-end face recognition method, device, equipment and storage medium
CN113326718A (en) * 2020-02-28 2021-08-31 腾讯科技(深圳)有限公司 Target face image detection method and device, storage medium and electronic equipment
CN113627328A (en) * 2021-08-10 2021-11-09 安谋科技(中国)有限公司 Electronic device, image recognition method thereof, system on chip, and medium
CN113837065A (en) * 2021-09-22 2021-12-24 上海商汤智能科技有限公司 Image processing method and device

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210133427A1 (en) * 2016-12-27 2021-05-06 Sharp Kabushiki Kaisha Image processing device, image printing device, imaging device, and non-transitory medium
CN111325051A (en) * 2018-12-13 2020-06-23 普天信息技术有限公司 Face recognition method and device based on face image ROI selection
CN110162138A (en) * 2019-04-10 2019-08-23 北京迈格威科技有限公司 Folding angles adjusting method, device and collapsible terminal
CN110136142A (en) * 2019-04-26 2019-08-16 微梦创科网络科技(中国)有限公司 A kind of image cropping method, apparatus, electronic equipment
CN110782392A (en) * 2019-07-12 2020-02-11 北京达佳互联信息技术有限公司 Image processing method, image processing device, electronic equipment and storage medium
CN111241992A (en) * 2020-01-08 2020-06-05 科大讯飞股份有限公司 Face recognition model construction method, recognition method, device, equipment and storage medium
CN113095119A (en) * 2020-01-09 2021-07-09 北京君正集成电路股份有限公司 Face recognition system for correcting face cutting frame
CN113326718A (en) * 2020-02-28 2021-08-31 腾讯科技(深圳)有限公司 Target face image detection method and device, storage medium and electronic equipment
CN111757098A (en) * 2020-06-30 2020-10-09 北京百度网讯科技有限公司 Debugging method and device of intelligent face monitoring camera, camera and medium
CN112016469A (en) * 2020-08-28 2020-12-01 Oppo广东移动通信有限公司 Image processing method and device, terminal and readable storage medium
CN112036317A (en) * 2020-08-31 2020-12-04 成都新潮传媒集团有限公司 Face image intercepting method and device and computer equipment
CN113269155A (en) * 2021-06-28 2021-08-17 苏州市科远软件技术开发有限公司 End-to-end face recognition method, device, equipment and storage medium
CN113627328A (en) * 2021-08-10 2021-11-09 安谋科技(中国)有限公司 Electronic device, image recognition method thereof, system on chip, and medium
CN113837065A (en) * 2021-09-22 2021-12-24 上海商汤智能科技有限公司 Image processing method and device

Similar Documents

Publication Publication Date Title
JP6099457B2 (en) Image processing apparatus, area determination method, and computer program
EP1710747A1 (en) Method for extracting person candidate area in image, person candidate area extraction system, person candidate area extraction program, method for judging top and bottom of person image, system for judging top and bottom, and program for judging top and bottom
JP4725490B2 (en) Automatic tracking method
CN112016469A (en) Image processing method and device, terminal and readable storage medium
JP7096034B2 (en) Building extraction system
KR20110074453A (en) Information processing apparatus and information processing method
JP2017535891A (en) Method and apparatus for detecting text
EP2782065A1 (en) Image-processing device removing encircling lines for identifying sub-regions of image
JP6542230B2 (en) Method and system for correcting projected distortion
KR101725501B1 (en) Method and apparatus for recognizing character
CN113177941A (en) Steel coil edge crack identification method, system, medium and terminal
CN114333030A (en) Image processing method, device, equipment and storage medium
CN106663317B (en) Morphological processing method and digital image processing device for digital image
CN111222508B (en) ROI-based house type graph scale identification method and device and computer equipment
JP7096033B2 (en) Building extraction system
CN109740337B (en) Method and device for realizing identification of slider verification code
JP4967045B2 (en) Background discriminating apparatus, method and program
CN108230328B (en) Method and device for acquiring target object and robot
CN112529013A (en) Image recognition method, device, equipment and computer readable medium
CN108615025A (en) Domestic environment Xiamen recognition positioning method, system and robot
CN114677388A (en) Room layout dividing method based on unit decomposition and space division
US6661535B1 (en) Moire fringe eliminating apparatus and a method for eliminating moire fringes
US9159118B2 (en) Image processing apparatus, image processing system, and non-transitory computer-readable medium
CN114529735A (en) Edge starting point extraction method and related device
JP4658714B2 (en) Method, apparatus, program, and storage medium for detecting line in image

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination