CN113538502A - Picture clipping method and device, electronic equipment and storage medium - Google Patents

Picture clipping method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113538502A
CN113538502A CN202110042473.8A CN202110042473A CN113538502A CN 113538502 A CN113538502 A CN 113538502A CN 202110042473 A CN202110042473 A CN 202110042473A CN 113538502 A CN113538502 A CN 113538502A
Authority
CN
China
Prior art keywords
picture
cut
size
cutting
region
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
CN202110042473.8A
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202110042473.8A priority Critical patent/CN113538502A/en
Publication of CN113538502A publication Critical patent/CN113538502A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration by the use of local operators
    • G06T5/30Erosion or dilatation, e.g. thinning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • G06T2207/30201Face

Abstract

The application relates to the technical field of image processing and artificial intelligence, and discloses a picture clipping method, a device, electronic equipment and a storage medium, wherein the picture clipping method comprises the following steps: acquiring a picture to be cut and a cutting size; carrying out picture main body detection on a picture to be cut to obtain a central point of a communication area covering at least one picture main body in the picture to be cut; and cutting the picture to be cut based on the central point and the cutting size of the communication area to obtain a cut picture containing at least one picture main body. According to the picture clipping method provided by the application, the clipped picture containing at least one picture main body in the picture to be clipped can be obtained, and the main content of the picture to be clipped is displayed.

Description

Picture clipping method and device, electronic equipment and storage medium
Technical Field
The application relates to the technical field of image processing and artificial intelligence, in particular to a picture clipping method and device, electronic equipment and a storage medium.
Background
With the development of electronic and artificial intelligence technologies, there is a great difference in the display sizes of different terminal devices, such as: the advertisement screen of advertising stop board, mobile terminal etc. if need carry out normal display with same picture on different terminal equipment, need tailor the picture, even if show on same terminal equipment, also have the condition of tailorring to the picture, if: when the video/album cover picture is displayed by changing from a horizontal screen to a vertical screen, one picture needs to meet the requirements of the horizontal screen and the vertical screen at the same time, and the picture needs to be cut.
In the prior art, when a picture is cut, a saliency algorithm is often adopted, a blocking mode is adopted to calculate a background part, the background is marked on the picture, and then the background part of the picture is cut.
Disclosure of Invention
The present application aims to solve at least one of the above technical drawbacks, and particularly proposes the following technical solutions to solve the problem of inaccurate picture cropping.
In one aspect of the present application, a method for cropping a picture is provided, including:
acquiring a picture to be cut and a cutting size;
carrying out picture main body detection on a picture to be cut to obtain a central point of a communication area covering at least one picture main body in the picture to be cut;
and cutting the picture to be cut based on the central point and the cutting size of the communication area to obtain a cut picture containing at least one picture main body.
In another aspect of the present application, there is provided a picture cropping apparatus, including:
the acquisition module is used for acquiring a picture to be cut and the cutting size;
the main body detection module is used for carrying out picture main body detection on the picture to be cut to obtain a central point of a communication area covering at least one picture main body in the picture to be cut;
and the cutting module is used for cutting the picture to be cut based on the central point and the cutting size of the communication area to obtain a cut picture containing at least one picture main body.
In a further aspect of the present application, there is provided an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the picture cropping method shown in the first aspect of the present application.
In yet another aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the picture cropping method shown in the first aspect of the present application.
The beneficial effect that technical scheme that this application provided brought is:
according to the picture cutting method, the width and the height of the cutting frame are determined according to the cutting size, the cutting picture containing at least one picture main body is obtained based on the center of the communication area and the cutting size, the main content of the picture to be cut can be displayed on the cutting picture, the picture cutting accuracy is improved, and the cutting mode is carried out based on the picture main body, so that the situation that partial cutting is carried out on any picture main body in the picture to be cut can be avoided, and the picture main body in the cutting picture is guaranteed to be a complete picture main body.
Additional aspects and advantages of the present application will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the present application.
Drawings
The foregoing and/or additional aspects and advantages of the present application will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
fig. 1 is a schematic diagram of an implementation environment of a picture cropping method according to an embodiment of the present application;
FIG. 2 is a flowchart of a method for cropping a picture according to an embodiment of the present application;
FIG. 3-1 is a schematic diagram illustrating an embodiment of the present application, which illustrates an area where each individual face in a picture to be cut is marked by a rectangular frame;
fig. 3-2 is a schematic diagram illustrating a connected region covering at least one face according to a region of each single face in a picture to be cut according to another embodiment of the present application;
FIG. 4 is a flow chart of determining a center point of a connected component according to an embodiment of the present disclosure;
fig. 5-1 and 5-2 are schematic diagrams illustrating determination of a clipping position according to an original size, a clipping size, and a center point of a connected region according to an embodiment of the present disclosure, where fig. 5-1 shows a picture to be clipped, and fig. 5-2 is a picture corresponding to the clipping position determined based on the original size, the clipping size, and the center point of the connected region of the picture to be clipped;
FIG. 6 is a schematic interface diagram of a second picture provided in accordance with an embodiment of the present application;
fig. 7 is a schematic structural diagram of a picture cropping device according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to the embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are exemplary only for the purpose of explaining the present application and are not to be construed as limiting the present application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
And (3) significance detection: salient regions (i.e., regions of interest to the user) in the picture are extracted through an artificial intelligence algorithm.
Face region feature binary image: and marking a binary image of the face area and the non-face area in the image.
Significant feature binary map: and marking a binary image of the significant area and the insignificant area in the picture.
During the research process, the inventor also finds that: when a face detection algorithm is used for face detection and face position determination, if a plurality of faces are included in a picture, a situation exists in which one face is taken as a picture main body and part of faces are cut off from other faces in the picture.
The scheme provided by the embodiment of the application can be executed by any electronic device, such as a terminal device, or a server, wherein the server can be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud computing service. The terminal device may be, but is not limited to, a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a smart television, a smart car device, and the like. The terminal device and the server may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein. For technical problems in the prior art, the image cropping method, the image cropping device, the electronic device and the storage medium provided by the application aim to solve at least one of the technical problems in the prior art.
Fig. 1 is a schematic diagram of an implementation environment of a picture cropping method according to an embodiment of the present application, where the implementation environment in this example may include, but is not limited to, a server 101, a network 102, and a terminal device 103. The server 101 may communicate with the terminal device 103 through the network 102, and the server 101 may transmit the cut picture after the cutting process to the terminal device 103 through the network. The terminal device 103 includes a human-computer interaction screen 1031, a processor 1032 and a memory 1033. The man-machine interaction screen 1031 is used for displaying the picture to be cut and the related information of the cut picture. The memory 1033 is used for storing a picture to be cropped and related data of the cropped picture. The server 101 includes a database 1011 and a processing engine 1012. The terminal device 103 may upload the picture to be cut to the server 101 through the network, and the server 101 performs cutting processing on the picture to be cut to obtain a cut picture, and sends the cut picture to the terminal device 103 for display.
The terminal device 103 may be operated by a client providing a picture display function, and a specific form is not limited, and the client provides the picture display function, for example: the media player, the browser, etc. may be in the form of an application program, or may be in the form of a web page, which is not limited herein.
In an embodiment of the present application, the scheme provided in the embodiment of the present application may be implemented based on a cloud technology, and the data processing (including but not limited to data computing, etc.) related in each optional embodiment may be implemented by using cloud computing. Cloud technology refers to a hosting technology for unifying serial resources such as hardware, software, network and the like in a wide area network or a local area network to realize calculation, storage, processing and sharing of data. The cloud technology is based on the general names of network technology, information technology, integration technology, management platform technology, application technology and the like applied in the cloud computing business model, can form a resource pool, is used as required, and is flexible and convenient. Cloud computing technology will become an important support. Background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture-like websites and more web portals. With the high development and application of the internet industry, each article may have its own identification mark and needs to be transmitted to a background system for logic processing, data in different levels are processed separately, and various industrial data need strong system background support and can only be realized through cloud computing.
Cloud computing (cloud computing) is a computing model that distributes computing tasks over a pool of resources formed by a large number of computers, enabling various application systems to obtain computing power, storage space, and information services as needed. The network that provides the resources is referred to as the "cloud". Resources in the "cloud" appear to the user as being infinitely expandable and available at any time, available on demand, expandable at any time, and paid for on-demand.
As a basic capability provider of cloud computing, a cloud computing resource pool (called as a cloud Platform in general, an Infrastructure as a Service) Platform is established, and multiple types of virtual resources are deployed in the resource pool for selective use by external clients, the cloud computing resource pool mainly includes a computing device (including an operating system, for a virtualized machine), a storage device, and a network device, and is divided according to logical functions, a PaaS (Platform as a Service) layer may be deployed on an IaaS (Infrastructure as a Service) layer, a SaaS (Software as a Service) layer may be deployed on the PaaS layer, or the SaaS may be directly deployed on the IaaS layer, the PaaS may be a Platform running on Software, such as a web database, a container, and the like, as business Software of various websites, a web portal, and the like, SaaS and PaaS are upper layers relative to IaaS.
The following describes the technical solutions of the present application and how to solve the above technical problems in detail with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
The present application provides a possible implementation manner, and as shown in fig. 2, a flowchart of a picture cropping method is provided, where the scheme may be executed by any electronic device, for example, the scheme of the embodiment of the present application may be executed on a terminal device or a server, or executed by both the terminal device and the server, and the picture to be cropped is cropped by obtaining the picture to be cropped and the cropping size, so that the cropped picture includes a picture main body. For convenience of description, the method provided by the embodiment of the present application will be described below by taking a server as an execution subject. As shown in the flow chart of fig. 2, the method may comprise the steps of:
step S110, obtaining a picture to be cut and a cutting size;
step S120, carrying out picture main body detection on the picture to be cut to obtain a central point of a communication area covering at least one picture main body in the picture to be cut;
and step S130, cutting the picture to be cut based on the central point and the cutting size of the connected region to obtain a cut picture containing at least one picture main body.
According to the scheme provided by the embodiment, when the same picture is displayed on different terminal devices, in order to adapt to the requirements of different display sizes, the picture needs to be cut, the picture to be cut is the picture to be cut, and the cut picture after being cut for the picture to be cut can adapt to the requirements of different display sizes, and on the basis, secondary processing can be performed on the basis of the cut picture to obtain a new picture, such as: advertisement picture, poster picture, etc. with added propaganda slogan. However, if the picture to be cut is cut to only satisfy the size requirement, the cut picture may not include the picture or include a part of the picture body, and the cut picture may not satisfy the requirement.
For the situation, the application provides a picture cutting method, firstly, a picture to be cut and a cutting size are obtained, wherein the cutting size is the preset size of the cut picture; and then, carrying out picture main body detection on the picture to be cut, wherein when the picture to be cut contains a face, the picture main body of the picture to be cut is the face, and when the picture to be cut does not contain the face, the picture main body of the picture to be cut is a significant area, and the significant area is a non-background area.
After the picture to be cut is subjected to picture main body detection, a picture main body is obtained, and the picture main body can be marked, for example: the outer border of the picture body may be framed by a rectangular frame, which may be referred to as an outer frame of the picture body. If the picture to be cut contains at least one picture main body and each picture main body is marked by a rectangular frame, after the picture to be cut is subjected to picture main body detection, at least one rectangular frame for framing the picture main body is obtained on the picture to be cut, a communication area covering the at least one picture main body is obtained based on the at least one rectangular frame, and a central point of the communication area is obtained. If there is one picture main body, the connected region is the outer frame of the picture main body, and if there are two or more picture main bodies, the connected region is the region covering the two or more picture main bodies. In an embodiment of the present application, the outer frames of each picture main body are expanded until the outer frames of the two picture main bodies are connected or there is an intersection, and then an area covered by the outer frames of the two picture main bodies is a connected area.
And cutting the picture to be cut out based on the central point of the communication area and the preset cutting size to obtain the cut-out picture containing at least one picture main body.
In one embodiment of the application, the center point of the connected region is used as the center, the cutting size is cutting width and height, or cutting diameter, when the cutting size is cutting width and height, the width and height of the cutting frame are determined according to the cutting size, the cutting picture containing at least one picture main body is obtained based on the center and the cutting size of the connected region, the cutting picture is a picture containing at least one picture main body in the picture to be cut, therefore, the cutting picture can display the main content of the picture to be cut, and the cutting mode is performed based on the picture main body, so that the situation that partial cutting is performed on any picture main body in the picture to be cut can be avoided, and the picture main bodies in the cutting picture are all complete picture main bodies.
According to the picture clipping method provided by the embodiment of the application, the clipped picture containing at least one picture main body is obtained based on the center and the clipping size of the connected region, the situation that half picture main bodies appear in the clipped picture is avoided, and the picture clipping accuracy is improved.
In order to clarify the technical solutions provided by the present application, the following explains the solutions provided by the present application by specific examples:
in an embodiment of the present application, when the picture main body includes a human face, the step S120 of performing picture main body detection on the picture to be cut to obtain a central point covering a connected region of at least one picture main body in the picture to be cut includes:
a1, carrying out face detection on a picture to be cut to obtain a face region characteristic binary image;
a2, if the face region feature binary image is valid, determining a connected region covering at least one face in the picture to be cut based on the face region feature binary image, and determining a central point of the connected region.
The face detection can be performed on the picture to be cut through a face detection algorithm to obtain a face area feature binary image, such as: the MTCNN algorithm (Multi-task Cascaded Convolutional neural network) can meet the accuracy of face detection on a CPU and realize the real-time performance of face detection. The pixel value of the face area in the face area feature binary image is 1, and the pixel value of the non-face area is 0.
And if the human face region feature binary image is detected to have a region with the value of 1, determining that the human face region feature binary image is valid, wherein the picture to be cut contains a human face, and the picture main body is the human face. The face is marked according to the face region feature binary image, for example, the region where each single face is located in the picture to be cut can be marked through a rectangular frame, as shown in fig. 3-1, the picture to be cut contains 2 faces, a face a and a face B, each face is marked through the rectangular frame, and the rectangular frame corresponding to the face a is not connected with the rectangular frame corresponding to the face B. Then, a connected region covering at least one face is obtained according to the region of each single face in the picture to be cut, as shown in fig. 3-2, 2 faces in the picture to be cut can be covered by one connected region, and the connected region can be a regular region or an irregular region. And then obtaining the central point of the connected region by an algorithm for solving the central point of the graph.
In an embodiment of the present application, the determining, based on the face region feature binary image, a connected region covering at least one face in the picture to be cropped, which is provided by a2, may be performed in the following manner, including:
a21, determining the coverage area of each single face in the picture to be cut according to the face area feature binary image;
and A22, performing expansion processing on the coverage area of each single face to obtain a communication area covering at least one face in the picture to be cut.
And determining the coverage area of each single face in the picture to be cut according to the area with the value of 1 in the face area characteristic binary image because the value of the face area in the face area characteristic binary image is 1.
And performing expansion processing on the coverage area of the single face, such as: and performing expansion processing on the coverage area of the single face by using an expansion algorithm, or expanding the coverage area of the single face by using a preset expansion coefficient to obtain a connected area covering at least one face in the picture to be cut.
In one embodiment of the application, when only one face exists in the picture to be cut, the covering area is subjected to expansion processing with an expansion coefficient of 1, and a connected area covering at least one face in the picture to be cut is obtained. When two or more faces exist in the picture to be cut, performing expansion processing with preset expansion coefficients on the coverage area of each single face to enable the boundaries of the coverage areas of the adjacent single faces to be intersected or connected, as shown in fig. 3-2, the coverage area of the face a and the coverage area of the face B have an overlapping area after the expansion processing, and when the overlapping area exists, the area covering the face a and the face B is used as a connected area.
According to the scheme provided by the embodiment, the expansion processing is carried out on the coverage area of a single face, the expansion processing enables the adjacent unconnected face areas to be connected into a connected area, the connected area can cover at least one face in the picture to be cut, the number of the faces covered by the connected area is at least one, the faces are complete face coverage areas, and the accuracy of the cutting area determined based on the central point of the connected area is improved.
When the face region feature binary image is invalid, that is, when the picture to be cut does not contain a face, the present application further provides an embodiment, performing picture body detection on the picture to be cut to obtain a central point of a connected region covering at least one picture body in the picture to be cut, which can be performed in the following manner, including:
b1, carrying out significance detection on the picture to be cut to obtain a significance characteristic binary image;
and B2, obtaining a connected region covering at least one significant region in the picture to be cut based on the significant feature binary image, and determining the central point of the connected region.
The saliency detection of the picture to be cropped can be performed through a saliency detection algorithm, such as: a RAS algorithm (Reverse Attention for sales Object Detection), which generates a saliency feature binary image, where, since there is no human face in the picture to be cropped, the picture body in the picture to be cropped is a saliency region, and the saliency region is a region of interest to a user, such as: in a landscape picture, a salient region may be a target region other than the background and the foreground. In the significant feature binary image, the significant region takes a value of 1, and the remaining regions take a value of 0. The position of each saliency region in the picture to be cut can be determined according to the saliency feature binary image, a connected region covering at least one saliency region in the picture to be cut is formed according to the position of each saliency region, when the number of picture bodies is one, the connected region is a frame of a single saliency region, and when the number of picture bodies is at least two, the connected region is a region covering at least two adjacent regions. And then obtaining the central point of the connected region by an algorithm for solving the central point of the graph.
In an embodiment of the present application, the obtaining of the connected region covering at least one saliency region in the picture to be cropped based on the saliency feature binary map provided in B2 may be performed by the following steps:
b21, determining at least one salient region in the picture to be cut according to the salient feature binary image;
and B22, performing expansion processing on the at least one salient region to obtain a connected region covering the at least one salient region in the picture to be cut.
And determining the salient region in the picture to be cut according to the region with the value of 1 in the salient feature binary image because the value of the salient region in the salient feature binary image is 1.
And (3) performing expansion treatment on each significant area, such as: and performing expansion processing on each salient region by using an expansion algorithm, or expanding each salient region by using a preset expansion coefficient to obtain a connected region covering at least one salient region in the picture to be cut.
In an embodiment of the application, when only one salient region exists in a picture to be cropped, the salient region is subjected to expansion processing with an expansion coefficient of 1, so that a connected region covering at least one salient region in the picture to be cropped is obtained. When two or more significant areas exist in the picture to be cut, expansion processing with preset expansion coefficients is carried out on each significant area, so that the boundaries of the adjacent significant areas are intersected or connected to realize the communication of the adjacent significant areas, and the area covered by the significant areas with the intersected or connected boundaries is a communicated area.
According to the scheme provided by the embodiment, the salient regions are subjected to expansion processing, the expansion processing enables the adjacent unconnected salient regions to be connected into a connected region, the connected region can cover at least one salient region in the picture to be cut, and the covered salient region is a complete salient region, so that the accuracy of the cutting region of the cut picture determined based on the central point of the connected region is improved.
Fig. 4 is a flowchart of determining a center point of a connected component according to an embodiment of the present application, where the flowchart includes: firstly, a picture to be cut and a cutting size can be obtained through the schemes provided in S110 to S120, and picture main body detection is carried out on the picture to be cut to obtain a face region feature binary image (corresponding to S410 in FIG. 4); then detecting whether the face region feature binary image is valid (corresponding to S420 in fig. 4), if so, determining a coverage area of each single face in the picture to be cut according to the face region feature binary image (corresponding to a21 in fig. 4); and performing expansion processing on the coverage area of each single face to obtain a connected area (corresponding to a22 in fig. 4) covering at least one face in the picture to be cut. If the image is invalid, performing significance detection on the image to be cut to obtain a significance characteristic binary image (corresponding to B1 in FIG. 4); and obtaining a connected region (corresponding to B2 in the figure 4) covering at least one salient region in the picture to be cut based on the salient feature binary image.
According to the scheme provided by the embodiment, firstly, the face detection is carried out on the picture to be cut, if the face is detected, the picture main body is the face, if the face cannot be detected, the significance region is obtained through the significance detection, the picture main body is the significance region, the communication region covering at least one picture main body is determined based on the face or the significance region, then the central point of the communication region is determined, and the picture main body of the picture to be cut and the central point of the communication region can be accurately and efficiently determined.
According to the solution provided by the above embodiment, after the central point of the connected region is determined, the present application further provides an embodiment, where a picture to be cropped is cropped based on the central point and the cropping size of the connected region, so as to obtain a cropped picture including at least one picture main body, where the method includes:
c1, acquiring the original size of the picture to be cut;
c2, determining the cutting position of the cut picture according to the relation between the original image size and the cutting size and the central point of the communication area;
and C3, cutting the picture to be cut according to the cutting position to obtain a cut picture containing at least one picture main body.
The embodiment of the application provides a scheme for determining a cut picture, which is characterized in that a cutting position of the cut picture is determined based on the original picture size and the cutting size of the picture to be cut and the central point of a communication area, and the picture to be cut is cut according to the cutting position to obtain the cut picture containing at least one picture main body. The cutting position and the cutting picture obtained by the scheme can not only ensure that the cutting picture comprises a picture main body, but also ensure the integrity of the cut picture main body.
Especially, when the size of cutting out the picture and the original image size of waiting to cut out the picture differed greatly, directly adopt the central point of cutting out size and intercommunication area to confirm to cut out the position, the condition that can't the complete picture main part of intercepting appears, consequently, this application combines original image size and the relation of cutting out the size and the central point of intercommunication area to confirm the position of cutting out the picture, is favorable to promoting the integrality of the picture main part in the picture of cutting out, and then promotes the accuracy of the position of cutting out the picture, if: when the difference between the original image size and the cutting size is large, the original image size can be firstly adjusted, so that the difference between the adjusted original image size and the cutting size is in a reasonable range, and the situation that only a part of a picture main body is cut in a cut picture is avoided.
In an embodiment of the present application, when the dimensions in the embodiment are height and width, that is, the original dimension includes an original height and an original width, and the cropping dimension includes a cropping width and a cropping height, the determining of the cropping position of the cropped picture according to the relationship between the original dimension and the cropping dimension and the central point of the connected region provided by C2 may be performed by:
c21, when the aspect ratio corresponding to the original size is larger than the aspect ratio corresponding to the cutting size, adjusting the width corresponding to the original size based on the height corresponding to the original size and the aspect ratio corresponding to the cutting size so that the aspect ratio corresponding to the adjusted original size is consistent with the aspect ratio corresponding to the cutting size, and determining the cutting position of the cutting picture based on the adjusted original size and the central point of the communication area;
c22, when the aspect ratio corresponding to the original size is smaller than the aspect ratio corresponding to the cutting size, adjusting the height corresponding to the original size based on the width corresponding to the original size and the aspect ratio corresponding to the cutting size so that the aspect ratio corresponding to the adjusted original size is consistent with the aspect ratio corresponding to the cutting size, and determining the cutting position of the cutting picture based on the adjusted original size and the central point of the connected region;
c23, when the aspect ratio corresponding to the original size and the aspect ratio corresponding to the cutting size are consistent, determining the cutting position of the cutting picture according to the original size and the central point of the connected region.
Specifically, an aspect ratio corresponding to the original size of the picture to be cut and an aspect ratio corresponding to the cutting size are obtained, and the cutting position of the cut picture is determined according to the relationship between the aspect ratio corresponding to the original size and the aspect ratio corresponding to the cutting size and the central point of the connected region.
And when the aspect ratio corresponding to the original image size is consistent with the aspect ratio corresponding to the cutting size, determining the cutting position of the cutting picture according to the original image size and the central point of the connected region.
When the aspect ratio corresponding to the original size does not match the aspect ratio corresponding to the cutting size, the original size is adjusted so that the aspect ratio corresponding to the adjusted original size is equal to the aspect ratio corresponding to the cutting size. And then, determining a cutting position of the cut picture by taking the central point of the connected area as a center and the adjusted size of the original picture as the screenshot size, wherein the picture corresponding to the cutting position comprises at least one picture main body.
The relationship between the aspect ratio corresponding to the original size and the aspect ratio corresponding to the cut size includes the following two types: the aspect ratio corresponding to the original size is equal to the aspect ratio corresponding to the cutting size, and the aspect ratio corresponding to the original size is not equal to the aspect ratio corresponding to the cutting size. Specifically, the aspect ratio corresponding to the original size is not equal to the aspect ratio corresponding to the cropping size, which includes the following two cases: the aspect ratio corresponding to the original size is larger than the aspect ratio corresponding to the cutting size, and the aspect ratio corresponding to the original size is smaller than the aspect ratio corresponding to the cutting size. In both cases, the scheme for adjusting the size of the original image is as follows:
when the aspect ratio corresponding to the original image size is larger than the aspect ratio corresponding to the cutting size, the width corresponding to the original image size is adjusted based on the height corresponding to the original image size and the aspect ratio corresponding to the cutting size, so that the aspect ratio corresponding to the original image size after adjustment is consistent with the aspect ratio corresponding to the cutting size.
When the aspect ratio corresponding to the original image size is smaller than the aspect ratio corresponding to the cutting size, the height corresponding to the original image size is adjusted based on the width corresponding to the original image size and the aspect ratio corresponding to the cutting size, so that the aspect ratio corresponding to the original image size after adjustment is consistent with the aspect ratio corresponding to the cutting size.
The scheme for determining the clipping position according to the original image size, the clipping size and the center point of the connected region provided by one embodiment of the present application is described with reference to the schematic diagrams shown in fig. 5-1 and 5-2. Fig. 5-1 shows a picture to be cut, where the width and height of the original size are denoted as w and h, respectively, and if the picture to be cut includes a face, the picture body (the face in fig. 5-1) is marked by a rectangular frame (the dashed frame in fig. 5-1). Assume that the width and height corresponding to the crop size are characterized as w 'and h', respectively. As shown in fig. 5-1, w/h > w '/h', the width of the original size is adjusted by the height of the original size and the aspect ratio of the trimming size, that is, the h side is fixed and the w side is adjusted, the original width w1 after adjustment is hw '/h', and w1/h after adjustment is w '/h'. Determining the clipping position of the clipped picture according to w1, h and the central point of the connected region, where the picture corresponding to the clipping position is shown in fig. 5-2, and includes the picture main body represented by the face and a part of the background region near the picture main body.
On the basis, after the size of the original image is adjusted, the adjusted original image is subjected to equal-proportion scaling h/h ', and a cutting picture with the width and the height of w ' h ' can be obtained. When w/h < w '/h', the height of the original size is adjusted by the width of the original size and the aspect ratio of the cutting size, that is, the side w is fixed and the side h is adjusted, the original height h1 after adjustment is wh '/w', and the original height w/h1 after adjustment is w '/h'. And determining the cutting position of the cut picture according to the w, the h1 and the central point of the connected region. After the size of the original image is adjusted, the adjusted original image is scaled by w/w ' in equal proportion, and a cutting picture with the width of w ' h ' can be obtained. If the aspect ratio corresponding to the original size is equal to the aspect ratio corresponding to the clipping size, that is, w/h is w '/h', the clipping position of the clipped picture is determined from the original size and the center point of the connected region without adjusting the original size.
After the clipping position of the clipped picture is obtained according to the above embodiment, an embodiment of the present application further provides a scheme for obtaining the clipped picture, and the clipping of the picture to be clipped according to the clipping position to obtain the clipped picture including at least one picture main body can be performed in the following manner:
d1, cutting the picture to be cut according to the cutting position;
d2, determining the ratio of the aspect ratio corresponding to the original image size or the adjusted original image size to the aspect ratio corresponding to the cutting size, and performing equal-ratio adjustment on the picture to be cut according to the cutting position to obtain a cut picture.
When the aspect ratio corresponding to the original size or the adjusted original size is equal to the aspect ratio corresponding to the trimming size, a first ratio of the aspect ratio is determined. And obtaining a first picture obtained after the picture to be cut is cut by using the cutting position, and carrying out equal-proportion adjustment on the width and the height of the first picture according to the first proportion to obtain a cut picture.
Examples are as follows: assuming that the aspect ratio corresponding to the original size is equal to the aspect ratio corresponding to the cropping size, that is, w/h is w '/h ', and the first ratio p is w/w ', when p >1, the first picture obtained at the cropping position is reduced to 1/p of the first picture, and when p <1, the first picture obtained at the cropping position is enlarged by p times.
The cutting position determined by the scheme can effectively avoid the problem that the single picture main body is partially intercepted, is favorable for improving the integrity of the picture main body in the cutting picture, and further improves the accuracy of the cutting position of the cutting picture.
After the cropped picture is obtained according to the scheme provided in the embodiment, in an embodiment of the present application, a second picture may be generated based on the cropped picture, where the layer where the cropped picture is located is one of the layers, and the second picture includes at least two layers.
According to the scheme, other layers are added on the basis of cutting the picture to generate a second picture, and the second picture can be a picture formed by adding elements such as a search box, a marker picture and the like. The second picture is based on the secondary production of the cut picture, and can be a poster picture, an advertisement picture and the like added with other design elements, so that advertisement putting, user renewing and the like can be carried out based on the second picture.
In an embodiment of the application, the second picture may further include a fixed layer and/or a non-fixed layer in addition to the layer where the cropped picture is located. Taking the cut picture as a video cover picture as an example, the second picture is a picture formed by adding search frames, platform logo and drama logo elements on the cut picture. The search box and the platform logo are located at fixed positions of the layer, namely the sizes and the positions of the elements are fixed, so that the elements are called as fixed layers, and the positions and the sizes of the dramatic name logos can be adjusted, so that the elements are called as non-fixed layers. The second picture may include at least two layers, where one layer is a layer where the cropped picture is located, and in addition, the second picture further includes a fixed layer and/or a non-fixed layer.
When the second picture includes a fixed layer in addition to the layer where the cropped picture is located, in an embodiment of the present application, the second picture may be generated based on the cropped picture in the following manner, including:
e1, acquiring the picture of the fixed layer and the picture main body area of the cut picture;
e2, taking the area outside the picture main body area as the placement position of the picture of the fixed layer;
and E3, generating a second picture based on the picture of the fixed layer, the placement position of the picture of the fixed layer and the cropping picture.
In order to improve the visual perception of the user, the picture corresponding to the fixed layer is preferably placed in a region where the picture main body in the cropped picture is not blocked, so that a region outside the picture main body region of the cropped picture is used as a placement region of the picture of the fixed layer, that is, the picture of the fixed layer is placed in a region outside the picture main body region. And placing the picture of the fixed layer at the determined placing position of the picture of the fixed layer, and carrying out picture fusion and other processing on the picture of the fixed layer placed at the placing position and the cut picture to form a second picture.
Fig. 6 is an interface schematic diagram of a second picture according to an embodiment of the present application, in which a picture in a fixed layer is a search box and a platform logo, and a picture body of a clipped picture is a human face.
The size of the platform logo shown in fig. 6 may be set to 180px × 52px, and the platform logo is placed at the upper right corner of the second picture, and a certain distance may be left between the upper boundary of the platform logo and the upper boundary of the second picture, for example: 24px, a certain distance may also be left between the right boundary of the platform logo and the right boundary of the second picture, such as: 10 px. The size of the search box can be set to be 702px wide and 70px high, the font in the search box can be set to be bold, and the font size of the font in the search box can also be set, such as: the font size is 34 px. The pictures in the fixed layer and the picture main body in the cut picture have no intersection, and as shown in fig. 6, the search frame and the platform logo do not shield the face area in the cut picture.
When the second picture includes a non-fixed layer in addition to the layer where the cropped picture is located, in an embodiment of the present application, the generating of the second picture based on the cropped picture may be performed in the following manner, including:
f1, acquiring the picture of the non-fixed layer, the preset size range of the picture of the non-fixed layer, the size of the non-fixed layer and the picture main body area of the picture to be cut;
f2, determining the size of the picture in the non-fixed layer based on the relation between the size of the non-fixed layer and the preset size range of the picture in the non-fixed layer;
f3, dividing the non-fixed layer into a plurality of placeable areas according to the size of the picture in the non-fixed layer;
f4, taking the corresponding placeable regions when the intersection areas of the placeable regions and the picture main body regions are minimum as the placement positions of the pictures of the non-fixed layer;
and F5, generating a second picture based on the picture, the placing position and the cropping picture of the non-fixed layer.
The preset threshold ranges of the width and the height corresponding to the picture size of the non-fixed layer are w0 and h0, and assuming that the width and the height of the non-fixed layer are represented by w1 and h1, respectively, taking the picture of the non-fixed layer as an example, the position of the dramatic logo is non-fixed, and the size of the dramatic logo is not fixed, that is, the picture position and the picture size of the non-fixed layer are adjustable, in the embodiment of the present application, the size of the picture of the non-fixed layer can be determined in the following manner: when w0/h0> w1/h1, the edge of h1 is fixed, the width of the unfixed layer is adjusted to w 1' ═ w0 × h1/h0, and then the size of the dramatic logo is (w0 × h1/h0, h 1); when w0/h0< w1/h1, the side of w1 is fixed, the height of the unfixed layer is adjusted to h 1' ═ w1 × h0/w0, and the size of the dramatic logo is (w1, w1 × h0/w 0).
The method comprises the steps of dividing a non-fixed image layer into a plurality of placeable regions according to the size of a picture of the non-fixed image layer, wherein the size of the non-fixed image layer is smaller than that of the fixed image layer, so that a new placeable region can be obtained by moving one pixel point each time if the picture of the non-fixed image layer as a fixed size moves pixel by pixel in the non-fixed image layer region according to a preset dividing mode.
Taking the picture of the non-fixed layer as an example of the dramatic logo, traversing the dramatic logo in the placeable region, obtaining the intersection area of the placeable position and the picture main body region in the cut picture, namely calculating the overlapping area of the placeable position and the picture main body region, and taking the placeable region corresponding to the minimum overlapping area of the placeable position and the picture main body region in the cut picture as the placement position of the picture in the non-fixed layer, wherein the minimum overlapping area can be 0.
And placing the picture of the non-fixed layer at the determined placing position of the picture of the non-fixed layer, and carrying out picture fusion and other processing on the picture of the non-fixed layer placed at the placing position and the cut picture to form a second picture.
When the placement position of the picture of the non-fixed layer is determined from the plurality of placeable areas, in addition to the above scheme, an embodiment of the present application further provides the following scheme:
f6, when the intersection area is the minimum, corresponding to a plurality of placeable regions, obtaining the pixel values of the placeable regions corresponding to the minimum intersection area; and taking the placeable area with the minimum pixel change as the placement position of the picture of the non-fixed layer.
If a plurality of placeable regions exist correspondingly under the condition that the intersection area is the smallest, if the intersection areas are all a, a may be 0, the placement position of the picture in the non-fixed layer cannot be accurately determined according to the scheme provided in the above embodiment, and in order to further accurately position the placement position of the picture in the non-fixed layer, the embodiment of the present application selects a region with the lowest energy value in the placeable region corresponding to the lowest intersection area, that is, a region with the smallest pixel value change in the placement region, and also a region with the smallest background gray scale change, and places the picture in the non-fixed layer at the placement position, so that the picture in the non-fixed layer can be highlighted to the greatest extent, and the visual experience of the user is improved.
As shown in fig. 6, the drama logo is a picture in a non-fixed layer, the picture in the non-fixed layer is placed outside a picture main body region, the picture main body is not shielded, and the background color of the picture in the non-fixed layer is not greatly changed compared with the background color of the cut picture, which is beneficial to improving the visual perception of a user.
Based on the same principle as the method provided in the embodiment of the present application, an embodiment of the present application further provides a picture cropping device 60, which can implement a picture cropping scheme executed by a server side, and a schematic structural diagram of the device is shown in fig. 7, and the device may include: an obtaining module 610, a body detecting module 620, and a clipping module 630, wherein:
an obtaining module 610, configured to obtain a picture to be cut and a cutting size;
the main body detection module 620 is used for performing picture main body detection on the picture to be cut to obtain a central point of a communication area covering at least one picture main body in the picture to be cut;
and the cropping module 630 is configured to crop the picture to be cropped based on the central point and the cropping size of the connected region, so as to obtain a cropped picture including at least one picture main body.
The image cutting device determines the width and the height of a cutting frame according to the cutting size, obtains a cutting image containing at least one image main body based on the center of a communication area and the cutting size, can display the main content of the image to be cut, and improves the accuracy of image cutting.
In an embodiment of the present application, the picture body includes a human face, and the body detection module 620 is specifically configured to:
carrying out face detection on a picture to be cut to obtain a face area characteristic binary image;
and if the face region feature binary image is valid, determining a connected region covering at least one face in the picture to be cut based on the face region feature binary image, and determining a central point of the connected region.
In an embodiment of the present application, when the face region feature binary image is invalid, the main body detection module 620 is further configured to:
carrying out significance detection on a picture to be cut to obtain a significance characteristic binary image;
and obtaining a connected region covering at least one significant region in the picture to be cut based on the significant feature binary image, and determining the central point of the connected region.
In an embodiment of the present application, the subject detecting module 620 is further configured to:
determining the coverage area of each single face in the picture to be cut according to the face area characteristic binary image;
and expanding the coverage area of each single face to obtain a communication area covering at least one face in the picture to be cut.
In an embodiment of the present application, the subject detecting module 620 is further configured to:
determining at least one salient region in the picture to be cut according to the salient feature binary image;
and performing expansion processing on at least one salient region to obtain a connected region covering at least one salient region in the picture to be cut.
In an embodiment of the present application, the clipping module 630 is specifically configured to:
acquiring the size of an original image of a picture to be cut;
determining the cutting position of the cut picture according to the relation between the size of the original picture and the cutting size and the central point of the communication area;
and cutting the picture to be cut according to the cutting position to obtain a cut picture containing at least one picture main body.
In one embodiment of the present application, the cropping module 630 includes a cropping position determining unit configured to:
when the aspect ratio corresponding to the original image size is larger than the aspect ratio corresponding to the cutting size, adjusting the width corresponding to the original image size based on the height corresponding to the original image size and the aspect ratio corresponding to the cutting size, enabling the aspect ratio corresponding to the adjusted original image size to be consistent with the aspect ratio corresponding to the cutting size, and determining the cutting position of the cut picture based on the adjusted original image size and the central point of the connected region;
when the aspect ratio corresponding to the original image size is smaller than the aspect ratio corresponding to the cutting size, adjusting the height corresponding to the original image size based on the width corresponding to the original image size and the aspect ratio corresponding to the cutting size, enabling the aspect ratio corresponding to the adjusted original image size to be consistent with the aspect ratio corresponding to the cutting size, and determining the cutting position of the cut picture based on the adjusted original image size and the central point of the connected region;
and when the aspect ratio corresponding to the original image size is consistent with the aspect ratio corresponding to the cutting size, determining the cutting position of the cutting picture according to the original image size and the central point of the connected region.
In an embodiment of the application, the clipping position determining unit is further configured to:
cutting the picture to be cut according to the cutting position;
and determining the ratio of the aspect ratio corresponding to the original image size or the adjusted original image size to the aspect ratio corresponding to the cutting size, and performing equal-ratio adjustment on the picture to be cut according to the cutting position to obtain a cut picture.
In an embodiment of the present application, the image cropping device 60 further includes a second image generating module, configured to:
and generating a second picture based on the cut picture, wherein the second picture comprises at least two layers, and the layer where the cut picture is located is one of the layers.
In an embodiment of the application, when the second picture further includes a fixed layer, the second picture generating module is configured to:
acquiring a picture of a fixed layer and a picture main body area of a cut picture;
taking the area outside the picture main area as the placement position of the picture of the fixed picture layer;
and generating a second picture based on the picture of the fixed layer, the placing position and the cut picture.
In an embodiment of the application, when the second picture further includes a fixed layer, the second picture generating module is configured to:
acquiring a picture of a non-fixed layer, a preset size range of the picture of the non-fixed layer, the size of the non-fixed layer and a picture main body area of a picture to be cut;
determining the size of the picture in the non-fixed layer according to the relation between the size of the non-fixed layer and the preset size range;
dividing the non-fixed layer into a plurality of placeable areas according to the size of the picture in the non-fixed layer;
taking the corresponding placeable regions when the intersection areas of the placeable regions and the picture main body region are minimum as the placement positions of the pictures of the non-fixed picture layer;
and generating a second picture based on the picture, the placing position and the cutting picture of the non-fixed layer.
In an embodiment of the application, the second picture generation module is further configured to:
and when the intersection area is the minimum, corresponding to the plurality of placeable regions, acquiring pixel values of the plurality of placeable regions, and taking the placeable region with the minimum pixel value change as the placement position of the picture of the non-fixed layer.
The image cropping device of the embodiment of the present application can execute the image cropping method provided in the embodiment of the present application, and the implementation principle is similar, the actions executed by each module and unit in the image cropping device in each embodiment of the present application correspond to the steps in the image cropping method in each embodiment of the present application, and for the detailed functional description of each module of the image cropping device, reference may be specifically made to the description in the corresponding image cropping method shown in the foregoing, and details are not repeated here.
Based on the same principle as the method shown in the embodiments of the present application, there is also provided in the embodiments of the present application an electronic device, which may include but is not limited to: a processor and a memory; a memory for storing a computer program; and the processor is used for executing the picture cropping method shown in any embodiment of the application by calling the computer program. According to the picture cutting method, the width and the height of the cutting frame are determined according to the cutting size, the cutting picture containing at least one picture main body is obtained based on the center of the communication area and the cutting size, the main content of the picture to be cut can be displayed on the cutting picture, the picture cutting accuracy is improved, and in addition, due to the fact that the cutting mode is carried out based on the picture main body, the situation that partial cutting is carried out on any picture main body in the picture to be cut can be avoided, and the picture main body in the cutting picture is guaranteed to be a complete picture main body.
In an embodiment of the present application, an electronic device is provided, as shown in fig. 8, where the electronic device 4000 shown in fig. 8 may be a server, including: a processor 4001 and a memory 4003. Processor 4001 is coupled to memory 4003, such as via bus 4002. In one embodiment of the application, the electronic device 4000 may further comprise a transceiver 4004. In addition, the transceiver 4004 is not limited to one in practical applications, and the structure of the electronic device 4000 is not limited to the embodiment of the present application.
The Processor 4001 may be a CPU (Central Processing Unit), a general-purpose Processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other Programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor 4001 may also be a combination that performs a computational function, including, for example, a combination of one or more microprocessors, a combination of a DSP and a microprocessor, or the like.
Bus 4002 may include a path that carries information between the aforementioned components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus 4002 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 8, but this is not intended to represent only one bus or type of bus.
The Memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical Disc storage, optical Disc storage (including Compact Disc, laser Disc, optical Disc, digital versatile Disc, blu-ray Disc, etc.), a magnetic Disc storage medium or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to these.
The memory 4003 is used for storing application codes for executing the scheme of the present application, and the execution is controlled by the processor 4001. Processor 4001 is configured to execute application code stored in memory 4003 to implement what is shown in the foregoing method embodiments.
The electronic device may also be a terminal device, and the electronic device shown in fig. 8 is only an example, and should not bring any limitation to the functions and the application scope of the embodiments of the present application.
The image clipping method provided by the application can be realized in a cloud computing mode, wherein the cloud computing mode refers to a delivery and use mode of an IT infrastructure, and refers to a mode of acquiring required resources in an easily-extensible mode on demand through a network; the generalized cloud computing refers to a delivery and use mode of a service, and refers to obtaining a required service in an on-demand and easily-extensible manner through a network. Such services may be IT and software, internet related, or other services. Cloud Computing is a product of development and fusion of traditional computers and Network Technologies, such as Grid Computing (Grid Computing), distributed Computing (distributed Computing), Parallel Computing (Parallel Computing), Utility Computing (Utility Computing), Network Storage (Network Storage Technologies), Virtualization (Virtualization), Load balancing (Load Balance), and the like.
With the development of diversification of internet, real-time data stream and connecting equipment and the promotion of demands of search service, social network, mobile commerce, open collaboration and the like, cloud computing is rapidly developed. Different from the prior parallel distributed computing, the generation of cloud computing can promote the revolutionary change of the whole internet mode and the enterprise management mode in concept.
The picture clipping method can achieve automatic clipping of the clipped picture. Such a scheme may also be implemented by an artificial intelligence cloud Service, also commonly referred to as AIaaS (AI as a Service, chinese). The method is a service mode of an artificial intelligence platform, and particularly, the AIaaS platform splits several types of common AI services and provides independent or packaged services at a cloud. This service model is similar to the one opened in an AI theme mall: all developers can access one or more artificial intelligence services provided by the platform through an API (application programming interface), and part of the qualified developers can also use an AI framework and an AI infrastructure provided by the platform to deploy and operate and maintain the self-dedicated cloud artificial intelligence services. In the application, the image cropping method provided by the application can be realized by using an AI framework and an AI infrastructure provided by a platform.
The present application provides a computer-readable storage medium, on which a computer program is stored, which, when running on a computer, enables the computer to execute the corresponding content in the foregoing method embodiments.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
The computer readable storage medium provided by the embodiments of the present application may be, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer-readable storage medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.
According to another aspect of the application, there is also provided a computer program product or a computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the picture cropping method provided in the various embodiment implementation manners.
Computer program code for carrying out operations for aspects of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present application may be implemented by software or hardware. The name of the module does not in some cases form a limitation on the module itself, and for example, the acquiring module may also be described as a "acquire picture to be cropped and crop size module".
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the disclosure. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (15)

1. A picture cropping method is characterized by comprising the following steps:
acquiring a picture to be cut and a cutting size;
performing picture main body detection on the picture to be cut to obtain a central point of a communication area covering at least one picture main body in the picture to be cut;
and cutting the picture to be cut out based on the central point of the connected region and the cutting size to obtain a cut out picture containing the at least one picture main body.
2. The method according to claim 1, wherein the picture body includes a human face, and the performing picture body detection on the picture to be cropped to obtain a central point of a connected region covering at least one picture body in the picture to be cropped comprises:
carrying out face detection on the picture to be cut to obtain a face area characteristic binary image;
and if the face region feature binary image is valid, determining a connected region covering at least one face in the picture to be cut based on the face region feature binary image, and determining a central point of the connected region.
3. The method according to claim 2, wherein if the face region feature binary image is invalid, the detecting the picture body of the picture to be cropped to obtain a center point of a connected region covering at least one picture body in the picture to be cropped, further comprising:
carrying out significance detection on the picture to be cut to obtain a significance characteristic binary image;
and obtaining a connected region covering at least one significant region in the picture to be cut based on the significant feature binary image, and determining the central point of the connected region.
4. The method according to claim 2, wherein the determining a connected component covering at least one face in the picture to be cropped based on the face region feature binary image comprises:
determining the coverage area of each single face in the picture to be cut according to the face area characteristic binary image;
and performing expansion processing on the coverage area of each single face to obtain a communication area covering at least one face in the picture to be cut.
5. The method according to claim 3, wherein the obtaining a connected region covering at least one salient region in the picture to be cropped based on the salient feature binary image comprises:
determining at least one salient region in a picture to be cut according to the salient feature binary image;
and performing expansion processing on the at least one salient region to obtain a connected region covering the at least one salient region in the picture to be cut.
6. The method according to claim 1, wherein the cropping the picture to be cropped based on the center point of the connected region and the cropping size to obtain a cropped picture including the at least one picture body comprises:
acquiring the size of an original image of the picture to be cut;
determining the cutting position of the cut picture according to the relation between the original image size and the cutting size and the central point of the communication area;
and cutting the picture to be cut according to the cutting position to obtain a cut picture containing the at least one picture main body.
7. The method of claim 6, wherein the artwork size and the cropping size comprise a width and a height, and wherein determining the cropping position of the cropped picture based on the relationship between the artwork size and the cropping size and the center point of the connected region comprises:
when the aspect ratio corresponding to the original image size is larger than the aspect ratio corresponding to the cutting size, adjusting the width corresponding to the original image size based on the height corresponding to the original image size and the aspect ratio corresponding to the cutting size, enabling the aspect ratio corresponding to the adjusted original image size to be consistent with the aspect ratio corresponding to the cutting size, and determining the cutting position of the cut picture based on the adjusted original image size and the central point of the connected region;
when the aspect ratio corresponding to the original image size is smaller than the aspect ratio corresponding to the cutting size, adjusting the height corresponding to the original image size based on the width corresponding to the original image size and the aspect ratio corresponding to the cutting size, enabling the aspect ratio corresponding to the adjusted original image size to be consistent with the aspect ratio corresponding to the cutting size, and determining the cutting position of the cut picture based on the adjusted original image size and the central point of the connected region;
and when the aspect ratio corresponding to the original image size is consistent with the aspect ratio corresponding to the cutting size, determining the cutting position of the cutting image according to the original image size and the central point of the connected region.
8. The method according to claim 7, wherein said cropping the picture to be cropped according to the cropping position, resulting in a cropped picture including the at least one picture body, comprises:
cutting the picture to be cut according to the cutting position;
and determining the ratio of the aspect ratio corresponding to the original image size or the adjusted original image size to the aspect ratio corresponding to the cutting size, and performing equal-ratio adjustment on the picture cut from the picture to be cut according to the cutting position to obtain a cut picture.
9. The method of claim 1, further comprising:
and generating a second picture based on the cut picture, wherein the second picture comprises at least two layers, and the layer where the cut picture is located is one of the layers.
10. The method of claim 9, wherein the second picture further comprises a fixed layer, and wherein generating the second picture based on the cropped picture comprises:
acquiring the picture of the fixed layer and the picture main body area of the cut picture;
taking the area outside the picture main area as the placement position of the picture of the fixed layer;
and generating a second picture based on the picture of the fixed layer, the placing position and the cutting picture.
11. The method of claim 9, wherein the second picture further comprises a non-fixed layer, and wherein generating the second picture based on the cropped picture comprises:
acquiring a picture of a non-fixed layer, a preset size range of the picture of the non-fixed layer, the size of the non-fixed layer and a picture main body area of the picture to be cut;
determining the size of the picture in the non-fixed layer according to the relation between the size of the non-fixed layer and the preset size range;
dividing the non-fixed image layer into a plurality of placeable areas according to the size of the picture in the non-fixed image layer;
taking the corresponding placeable regions when the intersection areas of the placeable regions and the picture main body region are minimum as the placement positions of the pictures of the non-fixed picture layer;
and generating a second picture based on the picture of the non-fixed layer, the placing position and the cutting picture.
12. The method of claim 11, further comprising:
and when the intersection area is the minimum, corresponding to a plurality of placeable regions, acquiring pixel values of the placeable regions, and taking the placeable region with the minimum pixel value change as the placement position of the picture of the non-fixed layer.
13. A picture cropping device, comprising:
the acquisition module is used for acquiring a picture to be cut and the cutting size;
the main body detection module is used for carrying out picture main body detection on the picture to be cut to obtain a central point of a communication area covering at least one picture main body in the picture to be cut;
and the cutting module is used for cutting the picture to be cut based on the central point of the communication area and the cutting size to obtain a cut picture containing the at least one picture main body.
14. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of any one of claims 1-12 when executing the program.
15. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method of any one of claims 1-12.
CN202110042473.8A 2021-01-13 2021-01-13 Picture clipping method and device, electronic equipment and storage medium Pending CN113538502A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110042473.8A CN113538502A (en) 2021-01-13 2021-01-13 Picture clipping method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110042473.8A CN113538502A (en) 2021-01-13 2021-01-13 Picture clipping method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113538502A true CN113538502A (en) 2021-10-22

Family

ID=78124268

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110042473.8A Pending CN113538502A (en) 2021-01-13 2021-01-13 Picture clipping method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113538502A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022242397A1 (en) * 2021-05-17 2022-11-24 腾讯科技(深圳)有限公司 Image processing method and apparatus, and computer-readable storage medium
WO2024051467A1 (en) * 2022-09-09 2024-03-14 北京字跳网络技术有限公司 Image processing method and apparatus, electronic device, and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022242397A1 (en) * 2021-05-17 2022-11-24 腾讯科技(深圳)有限公司 Image processing method and apparatus, and computer-readable storage medium
WO2024051467A1 (en) * 2022-09-09 2024-03-14 北京字跳网络技术有限公司 Image processing method and apparatus, electronic device, and storage medium

Similar Documents

Publication Publication Date Title
KR102215766B1 (en) Method and apparatus for generating synthetic picture
US10846870B2 (en) Joint training technique for depth map generation
US10311548B2 (en) Scaling render targets to a higher rendering resolution to display higher quality video frames
CN110750664B (en) Picture display method and device
CN111598902B (en) Image segmentation method, device, electronic equipment and computer readable medium
CN109118456B (en) Image processing method and device
CN104360847A (en) Method and equipment for processing image
CN113538502A (en) Picture clipping method and device, electronic equipment and storage medium
CN112711729A (en) Rendering method and device based on page animation, electronic equipment and storage medium
US10403040B2 (en) Vector graphics rendering techniques
CN115237522A (en) Page self-adaptive display method and device
CN110689014B (en) Method and device for detecting region of interest, electronic equipment and readable storage medium
CN112651475A (en) Two-dimensional code display method, device, equipment and medium
CN113506305A (en) Image enhancement method, semantic segmentation method and device for three-dimensional point cloud data
CN108734712B (en) Background segmentation method and device and computer storage medium
CN116596748A (en) Image stylization processing method, apparatus, device, storage medium, and program product
CN114419322B (en) Image instance segmentation method and device, electronic equipment and storage medium
CN113419806B (en) Image processing method, device, computer equipment and storage medium
CN109739403B (en) Method and apparatus for processing information
CN113763552A (en) Three-dimensional geographic model display method and device, computer equipment and storage medium
CN110633595B (en) Target detection method and device by utilizing bilinear interpolation
CN110020285B (en) Histogram processing method and device
CN106156371B (en) Method and device for realizing complete background picture of webpage
CN112465692A (en) Image processing method, device, equipment and storage medium
US20230043150A1 (en) Animation generation method and apparatus, electronic device, and computer-readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40054001

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination