CN104484855B - The method and apparatus that picture is cut - Google Patents
The method and apparatus that picture is cut Download PDFInfo
- Publication number
- CN104484855B CN104484855B CN201410820195.4A CN201410820195A CN104484855B CN 104484855 B CN104484855 B CN 104484855B CN 201410820195 A CN201410820195 A CN 201410820195A CN 104484855 B CN104484855 B CN 104484855B
- Authority
- CN
- China
- Prior art keywords
- cropping
- original picture
- picture
- human face
- original
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 86
- 238000001514 detection method Methods 0.000 claims description 19
- 230000000717 retained effect Effects 0.000 claims description 5
- 230000009286 beneficial effect Effects 0.000 description 4
- 238000004364 calculation method Methods 0.000 description 2
- 230000006835 compression Effects 0.000 description 2
- 238000007906 compression Methods 0.000 description 2
- 238000004590 computer program Methods 0.000 description 2
- 238000000429 assembly Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000006870 function Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/10—Selection of transformation methods according to the characteristics of the input images
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Analysis (AREA)
Abstract
本发明公开了一种图片裁剪的方法和装置,主要涉及互联网技术领域,主要目的在于对于不同图片能够及时采用适宜的裁剪方式。方法包括:对待裁剪的原始图片进行检测,检测出原始图片中包含的特征元素;根据特征元素,选择用于对原始图片进行裁剪的裁剪方式;按裁剪方式对原始图片进行裁剪,以得到目标图片。根据本发明,在裁剪图片之前首先对原始图片进行检测,检测出其中包含的特征元素,并根据特征元素的不同来采用不同的裁剪方式进行裁剪,从而保证对于不同图片能够及时采用适宜的裁剪方式,使得裁剪得到的目标图片符合需求。
The invention discloses a method and device for cutting pictures, which mainly relate to the technical field of the Internet, and the main purpose is to adopt an appropriate cutting method for different pictures in time. The method includes: detecting the original picture to be cut, and detecting the characteristic elements contained in the original picture; selecting a cutting method for cutting the original picture according to the characteristic elements; cutting the original picture according to the cutting method to obtain the target picture . According to the present invention, before cutting the picture, the original picture is first detected, the characteristic elements contained therein are detected, and different cutting methods are used for cutting according to the difference of the characteristic elements, so as to ensure that the appropriate cutting method can be adopted in time for different pictures , so that the cropped target image meets the requirements.
Description
技术领域technical field
本发明涉及互联网技术领域,具体而言,涉及一种图片裁剪的方法和装置。The present invention relates to the technical field of the Internet, in particular, to a method and device for cropping pictures.
背景技术Background technique
在互联网领域,通常需要对互联网上的大量图片进行抓取。由于互联网上的图片大小各异,会导致抓取到的图片尺寸很难符合需求,此时就需要计算机自动完成对图片的裁剪,使得图片的尺寸符合需求。In the Internet field, it is usually necessary to crawl a large number of pictures on the Internet. Due to the different sizes of pictures on the Internet, it will be difficult for the size of the captured pictures to meet the requirements. At this time, the computer needs to automatically complete the cropping of the pictures so that the size of the pictures meets the needs.
对于不同的图片,由于图片中展示的内容是不同的,导致图片中需要裁剪的部分也是不同的。而目前的采用三等分构图、黄金比例构图进行裁剪的方式,统统是对图片中的固定位置进行裁剪,这样则很难保证裁剪后的图片效果令人满意。尤其有些包含人物的图片,利用现有技术的裁剪方法往往使得裁剪后的人物形象不全或残缺,使得图片无法利用,或还得通过人工的方式进行裁剪,效率低,应用不广泛。For different pictures, since the contents displayed in the pictures are different, the parts that need to be cropped in the pictures are also different. However, the current cropping methods of thirds composition and golden ratio composition are all to crop the fixed position in the picture, so it is difficult to ensure that the effect of the cropped picture is satisfactory. Especially for some pictures that contain characters, the cutout methods of the prior art often make the cut out characters incomplete or incomplete, making the pictures unusable, or have to be cut out manually, which is inefficient and not widely used.
发明内容Contents of the invention
鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的图片裁剪的方法和装置。In view of the above problems, the present invention is proposed to provide a method and device for cropping a picture that overcomes the above problems or at least partially solves the above problems.
依据本发明的一个方面,提供了一种图片裁剪的方法,其包括:对待裁剪的原始图片进行检测,检测出所述原始图片中包含的特征元素;根据所述特征元素,选择用于对所述原始图片进行裁剪的裁剪方式;按所述裁剪方式对所述原始图片进行裁剪,以得到目标图片。According to one aspect of the present invention, a method for cropping a picture is provided, which includes: detecting the original picture to be cropped, and detecting the feature elements contained in the original picture; The cropping method of clipping the original picture; according to the clipping method, the original picture is cropped to obtain the target picture.
可选地,前述的方法,所述特征元素包括人物的人脸和/或图形标志。Optionally, in the foregoing method, the feature element includes a human face and/or a graphic symbol of a person.
可选地,前述的方法,对待裁剪的原始图片进行检测,检测出所述原始图片中包含的特征元素,具体包括:检测所述原始图片中是否包含所述人脸;在所述原始图片中不包含所述人脸时,检测所述原始图片中是否包含所述图形标志。Optionally, in the aforementioned method, detecting the original picture to be cropped and detecting the feature elements contained in the original picture specifically includes: detecting whether the human face is included in the original picture; When the human face is not included, it is detected whether the graphic mark is included in the original picture.
可选地,前述的方法,还包括:在所述原始图片中不包含所述人脸和所述图形标志时,选择预设的通用裁剪方式作为对所述原始图片进行裁剪的裁剪方式。Optionally, the aforementioned method further includes: when the original picture does not contain the human face and the graphic logo, selecting a preset general cropping mode as the cropping mode for cropping the original picture.
可选地,前述的方法,在根据所述图片元素,选择用于对所述原始图片进行裁剪的裁剪方式之前,还包括:在从所述原始图片中检测到所述人脸时,统计所述人脸的数量;根据所述图片元素,选择用于对所述原始图片进行裁剪的裁剪方式,具体包括:在所述原始图片中所述人脸的数量为1时,根据所述人脸选择对应的裁剪方式。Optionally, the aforementioned method, before selecting a cropping method for cropping the original picture according to the picture elements, further includes: when the human face is detected from the original picture, counting The number of faces; according to the picture element, select the cropping method for cutting the original picture, specifically including: when the number of faces in the original picture is 1, according to the face Select the corresponding cropping method.
可选地,前述的方法,还包括:在所述原始图片中所述人脸的数量大于1时,选择预设的通用裁剪方式作为对所述原始图片进行裁剪的裁剪方式。Optionally, the aforementioned method further includes: when the number of faces in the original picture is greater than 1, selecting a preset general cropping mode as the cropping mode for cropping the original picture.
可选地,前述的方法,所述目标图片中保留有所述特征元素。Optionally, in the aforementioned method, the feature elements are retained in the target picture.
依据本发明的另一方面,还提供了一种图片裁剪的装置,其包括:特征元素检测模块,用于对待裁剪的原始图片进行检测,检测出所述原始图片中包含的特征元素;裁剪方式选择模块,用于据所述特征元素,选择用于对所述原始图片进行裁剪的裁剪方式;裁剪模块,用于按所述裁剪方式对所述原始图片进行裁剪,以得到目标图片。According to another aspect of the present invention, there is also provided a device for cropping a picture, which includes: a feature element detection module, configured to detect the original picture to be cropped, and detect the feature elements contained in the original picture; the cropping method The selection module is configured to select a cropping method for cropping the original picture according to the characteristic elements; the cropping module is configured to crop the original picture according to the cropping method to obtain a target picture.
可选地,前述的装置,所述特征元素包括人物的人脸和/或图形标志。Optionally, in the aforementioned device, the feature element includes a human face and/or a graphic sign of a person.
可选地,前述的装置,所述特征元素检测模块检测所述原始图片中是否包含所述人脸;并在所述原始图片中不包含所述人脸时,检测所述原始图片中是否包含所述图形标志。Optionally, in the aforementioned device, the feature element detection module detects whether the original picture contains the human face; and when the original picture does not contain the human face, detects whether the original picture contains The graphic logo.
可选地,前述的装置,所述裁剪方式选择模块在所述原始图片中不包含所述人脸和所述图形标志时,选择预设的通用裁剪方式作为对所述原始图片进行裁剪的裁剪方式。Optionally, in the aforementioned device, when the cropping mode selection module does not contain the human face and the graphic logo in the original picture, select a preset general cropping mode as the cropping method for cropping the original picture Way.
可选地,前述的装置,所述特征元素检测模块还在从所述原始图片中检测到所述人脸时,统计所述人脸的数量;所述裁剪方式选择模块在所述原始图片中所述人脸的数量为1时,根据所述人脸选择对应的裁剪方式。Optionally, in the aforementioned device, when the feature element detection module detects the human face from the original picture, it counts the number of the human faces; When the number of faces is 1, a corresponding cropping method is selected according to the faces.
可选地,前述的装置,所述裁剪方式选择模块在所述原始图片中所述人脸的数量大于1时,选择预设的通用裁剪方式作为对所述原始图片进行裁剪的裁剪方式。Optionally, in the aforementioned device, the cropping mode selection module selects a preset general cropping mode as the cropping mode for cropping the original picture when the number of faces in the original picture is greater than 1.
可选地,前述的装置,所述目标图片中保留有所述特征元素。Optionally, in the aforementioned apparatus, the feature element is retained in the target picture.
根据以上的技术方案,可知本发明的图片裁剪的方法和装置至少具有以下优点:According to the above technical solutions, it can be known that the method and device for image cropping of the present invention have at least the following advantages:
根据本发明的技术方案,在裁剪图片之前首先对原始图片进行检测,检测出其中包含的特征元素,并根据特征元素的不同来采用不同的裁剪方式进行裁剪,从而保证对于不同图片能够及时采用适宜的裁剪方式,使得裁剪得到的目标图片符合需求。According to the technical solution of the present invention, before cutting the picture, the original picture is first detected, the characteristic elements contained therein are detected, and different cutting methods are used to cut according to the difference of the characteristic elements, so as to ensure that different pictures can be used in time. The cropping method makes the cropped target image meet the requirements.
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention, it can be implemented according to the contents of the description, and in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable , the specific embodiments of the present invention are enumerated below.
附图说明Description of drawings
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiment. The drawings are only for the purpose of illustrating a preferred embodiment and are not to be considered as limiting the invention. Also throughout the drawings, the same reference numerals are used to designate the same components. In the attached picture:
图1示出了根据本发明的一个实施例的图片裁剪的方法的流程图;Fig. 1 shows the flowchart of the method for cropping a picture according to an embodiment of the present invention;
图2示出了根据本发明的一个实施例的图片裁剪的方法的流程图;Fig. 2 shows the flowchart of the method for cropping a picture according to an embodiment of the present invention;
图3示出了根据本发明的一个实施例的图片裁剪的方法的流程图;Fig. 3 shows a flowchart of a method for cropping a picture according to an embodiment of the present invention;
图4示出了根据本发明的一个实施例的图片裁剪的装置的框图。Fig. 4 shows a block diagram of an apparatus for cropping a picture according to an embodiment of the present invention.
具体实施方式Detailed ways
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided for more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
如图1所示,本发明的一个实施例中提供了一种图片裁剪的方法,其包括:As shown in Fig. 1, a kind of method of picture clipping is provided in one embodiment of the present invention, and it comprises:
步骤110,对待裁剪的原始图片进行检测,检测出原始图片中包含的特征元素。在本实施例中,对特征元素的类型不进行限制,其包括但不限于人物的人脸以及图形标志,例如,商品、企业的标志。Step 110: Detect the original picture to be cropped, and detect the feature elements contained in the original picture. In this embodiment, there is no limitation on the types of feature elements, which include but not limited to faces of people and graphic signs, for example, signs of commodities and enterprises.
步骤120,根据特征元素,选择用于对原始图片进行裁剪的裁剪方式。在本实施例中,对裁剪方式不进行限制,例如,人物照片中特征元素为其脸部,则对应裁剪方式为裁剪下包含脸部的图片;商品标志图片中特征元素为起标示作用的图形或背景色,则将图片全部内容复制到一定区域中进行裁剪,并用背景色填充复制图片时剩余的区域。Step 120: Select a cropping method for cropping the original image according to the characteristic elements. In this embodiment, there is no restriction on the cropping method. For example, if the characteristic element in a photo of a person is its face, the corresponding cropping method is to crop the image containing the face; the characteristic element in the product logo image is a graphic that serves as a sign or background color, copy the entire content of the picture to a certain area for cropping, and fill the remaining area when copying the picture with the background color.
步骤130,按裁剪方式对原始图片进行裁剪,以得到目标图片。根据本实施例的技术方案,在裁剪图片之前首先对原始图片进行检测,检测出其中包含的特征元素,并根据特征元素的不同来采用不同的裁剪方式进行裁剪,从而保证对于不同图片能够及时采用适宜的裁剪方式,使得裁剪得到的目标图片符合需求。Step 130, cropping the original picture according to the cropping method to obtain the target picture. According to the technical solution of this embodiment, before cutting the picture, the original picture is first detected, the characteristic elements contained in it are detected, and different cutting methods are used to cut according to the difference of the characteristic elements, so as to ensure that different pictures can be used in time An appropriate cropping method makes the cropped target image meet the requirements.
进一步地,目标图片中保留有特征元素。这是因为通常特征元素是原始图片中的重要部分,例如人物图片中的人脸、图形标志图片中的起到标示作用的图形或背景色,都有必要进行保留。Further, feature elements are retained in the target image. This is because usually the characteristic elements are an important part of the original picture, for example, the face in the picture of a person, the figure or background color that plays a marking role in the picture of a graphic logo, all of which must be preserved.
根据图1,对人物A的新闻照片进行检测,基于人脸识别技术,可以检测到人物A的脸部;则对照片裁剪时从照片上裁剪下人物A的脸部所在区域,其余部分放弃;裁剪后得到的图片中具有人物A的脸部,有利于指示人物A的身份,与人物A的新闻相配合。According to Figure 1, the news photo of person A is detected, and based on the face recognition technology, the face of person A can be detected; when cutting the photo, the area where the face of person A is located is cut out from the photo, and the rest is discarded; The cropped picture has the face of the person A, which is beneficial to indicate the identity of the person A and matches the news of the person A.
如图2所示,本发明的一个实施例中提供了一种图片裁剪的方法,其包括:As shown in Figure 2, a method for cropping a picture is provided in one embodiment of the present invention, which includes:
步骤210,检测原始图片中是否包含人脸。Step 210, detecting whether the original picture contains a human face.
步骤220,在原始图片包含人脸时,根据人脸选择用于对原始图片进行裁剪的裁剪方式。Step 220, when the original picture contains a human face, select a cropping method for cropping the original picture according to the human face.
步骤230,在原始图片中不包含人脸时,检测原始图片中是否包含图形标志。在本实施例中,人脸相比于图形标志具有更高的检测优先级,这是因为同时具有人脸和图形标志的图片,通常主要呈现的内容是人脸,所以优先检测人脸以进行裁剪。Step 230, when the original picture does not contain a human face, detect whether the original picture contains a graphic mark. In this embodiment, the human face has a higher detection priority than the graphic mark, because the picture with the human face and the graphic mark at the same time usually mainly presents the human face, so the human face is preferentially detected for further detection. cropped.
步骤240,在原始图片包含图形标志时,根据图形标志选择用于对原始图片进行裁剪的裁剪方式。Step 240, when the original picture contains a graphic logo, select a cropping method for cropping the original picture according to the graphic logo.
步骤250,在原始图片中不包含人脸和图形标志时,选择预设的通用裁剪方式作为对所述原始图片进行裁剪的裁剪方式。在本实施例中,对通用裁剪方式不进行限制,在此提供一种能适应较多类别图片的裁剪方式:对原始图片按最小压缩比进行等比压缩,最小缩放比计算公式如下:Step 250, when the original picture does not contain a human face or graphic logo, select a preset general cropping mode as a cropping mode for cropping the original picture. In this embodiment, there is no limit to the general cropping method, and a cropping method that can adapt to more types of pictures is provided here: the original picture is compressed proportionally according to the minimum compression ratio, and the calculation formula of the minimum zoom ratio is as follows:
min_scale=MIN(widthsrc/widthdst,heightsrc/heightdst)min_scale=MIN(width src /width dst ,height src /height dst )
设未压缩的原始图片的宽和高分别为widthsrc,heightsrc;目标图片的宽和高分别为widthdst,heightdst。将缩放后的图片中周围超过目标图片范围的像素裁剪掉以获得目标图片,这种裁剪方式有利于裁剪掉原始图片的非重要的边缘部分。Suppose the width and height of the uncompressed original picture are width src and height src respectively; the width and height of the target picture are width dst and height dst respectively. The surrounding pixels in the scaled picture that exceed the range of the target picture are cropped to obtain the target picture. This cropping method is beneficial to crop the non-important edge parts of the original picture.
需要说明的是,上述各个公式并不是实现本发明的唯一公式,仅作为实施例的一种实现方式。技术人员可以根据业务需要对公式做适当变形,例如增加常量或变量或系数等方式,依然落在本发明的保护范围之内。It should be noted that each of the above formulas is not the only formula for implementing the present invention, and is only used as an implementation manner of the embodiment. Technicians can make appropriate changes to the formula according to business needs, such as adding constants or variables or coefficients, etc., which still fall within the protection scope of the present invention.
步骤260,按裁剪方式对原始图片进行裁剪,以得到目标图片。Step 260, cropping the original picture according to the cropping method to obtain the target picture.
根据图2,在一个明星新闻报道的照片中,一明星从车辆上下车,车辆上具有车标,明显地该张照片的重点是明星;此时首先基于人脸识别技术进行人脸检测,检测到明星的脸部,则进行裁剪时将明星的脸部裁剪下来即可,裁剪得到的图片中可以识别出该明星,与新闻报道相配合。According to Figure 2, in a photo of a star news report, a star gets off the vehicle, and the vehicle has a car logo. Obviously, the focus of the photo is the star; at this time, face detection is first performed based on face recognition technology, and If the star’s face is found, then the star’s face can be cut out during cropping, and the star can be identified in the cropped picture, which matches the news report.
如图3所示,本发明的一个实施例中提供了一种图片裁剪的方法,其包括:As shown in Figure 3, a method for cropping a picture is provided in one embodiment of the present invention, which includes:
步骤310,检测原始图片中是否包含人脸。Step 310, detecting whether the original picture contains a human face.
步骤320,在从原始图片中检测到人脸时,统计人脸的数量。Step 320, when a human face is detected from the original picture, count the number of human faces.
步骤330,在原始图片中人脸的数量为1时,根据人脸选择对应的裁剪方式。Step 330, when the number of faces in the original picture is 1, select the corresponding cropping method according to the faces.
步骤340,在原始图片中人脸的数量大于1时,选择预设的通用裁剪方式作为对所述原始图片进行裁剪的裁剪方式。在本实施例中,在人脸数量大于1时,通常个人脸部并非主要内容,例如多人合照的情况,所以不必对每个人的脸部进行裁剪。Step 340, when the number of human faces in the original picture is greater than 1, select a preset general cropping mode as the cropping mode for cropping the original picture. In this embodiment, when the number of human faces is greater than 1, usually individual faces are not the main content, such as the situation of multiple people taking a photo, so it is not necessary to crop each person's face.
步骤350,在原始图片中不包含人脸时,检测原始图片中是否包含图形标志。Step 350, when the original picture does not contain a human face, detect whether the original picture contains a graphic mark.
步骤360,在原始图片包含图形标志时,根据图形标志选择用于对原始图片进行裁剪的裁剪方式。Step 360, when the original picture contains a graphic logo, select a cropping method for cropping the original picture according to the graphic logo.
在原始图片中不包含人脸和图形标志时,也进入步骤340:选择预设的通用裁剪方式作为对所述原始图片进行裁剪的裁剪方式。When the original picture does not contain a human face or a graphic logo, go to step 340: select a preset general cropping mode as a cropping mode for cropping the original picture.
步骤370,按裁剪方式对原始图片进行裁剪,以得到目标图片。Step 370, crop the original picture according to the cropping method to obtain the target picture.
根据图3,对于某张班级合影,进行人脸检测后发现人脸数量为20个,则采用前述实施例的通用裁剪策略进行裁剪,则裁剪得到的图片中20人的全身部分基本全部得到保留。According to Figure 3, for a class group photo, after face detection, it is found that the number of faces is 20, then the general clipping strategy of the aforementioned embodiment is used for clipping, and the whole body parts of the 20 people in the cropped image are basically preserved .
如图4所示,本发明的一个实施例中提供了一种图片裁剪的装置,其包括:As shown in Figure 4, an embodiment of the present invention provides a device for cropping a picture, which includes:
特征元素检测模块410,对待裁剪的原始图片进行检测,检测出原始图片中包含的特征元素。在本实施例中,对特征元素的类型不进行限制,其包括但不限于人物的人脸以及图形标志,例如,商品、企业的标志。The characteristic element detection module 410 detects the original picture to be cropped, and detects the characteristic elements contained in the original picture. In this embodiment, there is no limitation on the types of feature elements, which include but not limited to faces of people and graphic signs, for example, signs of commodities and enterprises.
裁剪方式选择模块420,根据特征元素,选择用于对原始图片进行裁剪的裁剪方式。在本实施例中,对裁剪方式不进行限制,例如,人物照片中特征元素为其脸部,则对应裁剪方式为裁剪下包含脸部的图片;商品标志图片中特征元素为起标示作用的图形或背景色,则将图片全部内容复制到一定区域中进行裁剪,并用背景色填充复制图片时剩余的区域。The cropping mode selection module 420 selects a cropping mode for cropping the original picture according to the characteristic elements. In this embodiment, there is no restriction on the cropping method. For example, if the characteristic element in a photo of a person is its face, the corresponding cropping method is to crop the image containing the face; the characteristic element in the product logo image is a graphic that serves as a sign or background color, copy the entire content of the picture to a certain area for cropping, and fill the remaining area when copying the picture with the background color.
裁剪模块430,按裁剪方式对原始图片进行裁剪,以得到目标图片。根据本实施例的技术方案,在裁剪图片之前首先对原始图片进行检测,检测出其中包含的特征元素,并根据特征元素的不同来采用不同的裁剪方式进行裁剪,从而保证对于不同图片能够及时采用适宜的裁剪方式,使得裁剪得到的目标图片符合需求。The cropping module 430 is used to crop the original picture in a cropping manner to obtain the target picture. According to the technical solution of this embodiment, before cutting the picture, the original picture is first detected, the characteristic elements contained in it are detected, and different cutting methods are used to cut according to the difference of the characteristic elements, so as to ensure that different pictures can be used in time An appropriate cropping method makes the cropped target image meet the requirements.
进一步地,目标图片中保留有特征元素。这是因为通常特征元素是原始图片中的重要部分,例如人物图片中的人脸、图形标志图片中的起到标示作用的图形或背景色,都有必要进行保留。Further, feature elements are retained in the target image. This is because usually the characteristic elements are an important part of the original picture, for example, the face in the picture of a person, the figure or background color that plays a marking role in the picture of a graphic logo, all of which must be preserved.
根据图4,对人物A的新闻照片进行检测,基于人脸识别技术,可以检测到人物A的脸部;则对照片裁剪时从照片上裁剪下人物A的脸部所在区域,其余部分放弃;裁剪后得到的图片中具有人物A的脸部,有利于指示人物A的身份,与人物A的新闻相配合。According to Figure 4, the news photo of person A is detected, and based on the face recognition technology, the face of person A can be detected; when cutting the photo, the area where the face of person A is located is cut from the photo, and the rest is discarded; The cropped picture has the face of the person A, which is beneficial to indicate the identity of the person A and matches the news of the person A.
本发明的一个实施例中提供了一种图片裁剪的装置,其包括:An embodiment of the present invention provides a device for cropping a picture, which includes:
特征元素检测模块410,检测原始图片中是否包含人脸。The feature element detection module 410 detects whether the original picture contains a human face.
裁剪方式选择模块420,在原始图片包含人脸时,根据人脸选择用于对原始图片进行裁剪的裁剪方式。The cropping mode selection module 420 selects a cropping mode for cropping the original picture according to the human face when the original picture contains a human face.
特征元素检测模块410在原始图片中不包含人脸时,检测原始图片中是否包含图形标志。在本实施例中,人脸相比于图形标志具有更高的检测优先级,这是因为同时具有人脸和图形标志的图片,通常主要呈现的内容是人脸,所以优先检测人脸以进行裁剪。The feature element detection module 410 detects whether the original picture contains a graphic sign when the original picture does not contain a human face. In this embodiment, the human face has a higher detection priority than the graphic mark, because the picture with the human face and the graphic mark at the same time usually mainly presents the human face, so the human face is preferentially detected for further detection. cropped.
裁剪方式选择模块420在原始图片包含图形标志时,根据图形标志选择用于对原始图片进行裁剪的裁剪方式。The cropping method selection module 420 selects a cropping method for cropping the original picture according to the graphic symbol when the original picture contains a graphic symbol.
裁剪方式选择模块420在原始图片中不包含人脸和图形标志时,选择预设的通用裁剪方式作为对所述原始图片进行裁剪的裁剪方式。在本实施例中,对通用裁剪方式不进行限制,在此提供一种能适应较多类别图片的裁剪方式:对原始图片按最小压缩比进行等比压缩,最小缩放比计算公式如下:The cropping mode selection module 420 selects a preset general cropping mode as the cropping mode for cropping the original picture when the original picture does not contain a human face or a graphic logo. In this embodiment, there is no limit to the general cropping method, and a cropping method that can adapt to more types of pictures is provided here: the original picture is compressed proportionally according to the minimum compression ratio, and the calculation formula of the minimum zoom ratio is as follows:
min_scale=MIN(widthsrc/widthdst,heightsrc/heightdst)min_scale=MIN(width src /width dst ,height src /height dst )
设未压缩的原始图片的宽和高分别为widthsrc,heightsrc;目标图片的宽和高分别为widthdst,heightdst。将缩放后的图片中周围超过目标图片范围的像素裁剪掉以获得目标图片,这种裁剪方式有利于裁剪掉原始图片的非重要的边缘部分。Suppose the width and height of the uncompressed original picture are width src and height src respectively; the width and height of the target picture are width dst and height dst respectively. The surrounding pixels in the scaled picture that exceed the range of the target picture are cropped to obtain the target picture. This cropping method is beneficial to crop the non-important edge parts of the original picture.
需要说明的是,上述各个公式并不是实现本发明的唯一公式,仅作为实施例的一种实现方式。技术人员可以根据业务需要对公式做适当变形,例如增加常量或变量或系数等方式,依然落在本发明的保护范围之内。It should be noted that each of the above formulas is not the only formula for implementing the present invention, and is only used as an implementation manner of the embodiment. Technicians can make appropriate changes to the formula according to business needs, such as adding constants or variables or coefficients, etc., which still fall within the protection scope of the present invention.
裁剪模块430按裁剪方式对原始图片进行裁剪,以得到目标图片。The cropping module 430 crops the original picture in a cropping manner to obtain the target picture.
根据图4,在一个明星新闻报道的照片中,一明星从车辆上下车,车辆上具有车标,明显地该张照片的重点是明星;此时首先基于人脸识别技术进行人脸检测,检测到明星的脸部,则进行裁剪时将明星的脸部裁剪下来即可,裁剪得到的图片中可以识别出该明星,与新闻报道相配合。According to Figure 4, in a photo of a star news report, a star gets off the vehicle, and the vehicle has a car logo. Obviously, the focus of the photo is the star; at this time, face detection is first based on face recognition technology, and If the star’s face is found, then the star’s face can be cut out during cropping, and the star can be identified in the cropped picture, which matches the news report.
本发明的一个实施例中提供了一种图片裁剪的装置,其包括:An embodiment of the present invention provides a device for cropping a picture, which includes:
特征元素检测模块410,检测原始图片中是否包含人脸,并在从原始图片中检测到人脸时,统计人脸的数量。The feature element detection module 410 detects whether the original picture contains a human face, and counts the number of human faces when a human face is detected from the original picture.
裁剪方式选择模块420,在原始图片中人脸的数量为1时,根据人脸选择对应的裁剪方式。The cropping mode selection module 420, when the number of faces in the original picture is 1, selects the corresponding cropping mode according to the faces.
裁剪方式选择模块420在原始图片中人脸的数量大于1时,选择预设的通用裁剪方式作为对所述原始图片进行裁剪的裁剪方式。在本实施例中,在人脸数量大于1时,通常个人脸部并非主要内容,例如多人合照的情况,所以不必对每个人的脸部进行裁剪。The cropping mode selection module 420 selects a preset general cropping mode as the cropping mode for cropping the original picture when the number of human faces in the original picture is greater than 1. In this embodiment, when the number of human faces is greater than 1, usually individual faces are not the main content, such as the situation of multiple people taking a photo, so it is not necessary to crop each person's face.
特征元素检测模块410,在原始图片中不包含人脸时,检测原始图片中是否包含图形标志。The feature element detection module 410 detects whether the original picture contains a graphic sign when the original picture does not contain a human face.
裁剪方式选择模块420在原始图片包含图形标志时,根据图形标志选择用于对原始图片进行裁剪的裁剪方式。The cropping method selection module 420 selects a cropping method for cropping the original picture according to the graphic symbol when the original picture contains a graphic symbol.
裁剪方式选择模块420在原始图片中不包含人脸和图形标志时,选择预设的通用裁剪方式作为对所述原始图片进行裁剪的裁剪方式。The cropping mode selection module 420 selects a preset general cropping mode as the cropping mode for cropping the original picture when the original picture does not contain a human face or a graphic logo.
裁剪模块430,按裁剪方式对原始图片进行裁剪,以得到目标图片。The cropping module 430 is used to crop the original picture in a cropping manner to obtain the target picture.
根据图4,对于某张班级合影,进行人脸检测后发现人脸数量为20个,则采用前述实施例的通用裁剪策略进行裁剪,则裁剪得到的图片中20人的全身部分基本全部得到保留。According to Figure 4, for a class group photo, after face detection, it is found that the number of faces is 20, then the general cutting strategy of the aforementioned embodiment is used for cutting, and the whole body parts of the 20 people in the cut picture are basically preserved .
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。The algorithms and displays presented herein are not inherently related to any particular computer, virtual system, or other device. Various generic systems can also be used with the teachings based on this. The structure required to construct such a system is apparent from the above description. Furthermore, the present invention is not specific to any particular programming language. It should be understood that various programming languages can be used to implement the content of the present invention described herein, and the above description of specific languages is for disclosing the best mode of the present invention.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure the understanding of this description.
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, in order to streamline this disclosure and to facilitate an understanding of one or more of the various inventive aspects, various features of the invention are sometimes grouped together in a single embodiment, figure, or its description. This method of disclosure, however, is not to be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the Detailed Description are hereby expressly incorporated into this Detailed Description, with each claim standing on its own as a separate embodiment of this invention.
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art can understand that the modules in the device in the embodiment can be adaptively changed and arranged in one or more devices different from the embodiment. Modules or units or components in the embodiments may be combined into one module or unit or component, and furthermore may be divided into a plurality of sub-modules or sub-units or sub-assemblies. All features disclosed in this specification (including accompanying claims, abstract and drawings) and any method or method so disclosed may be used in any combination, except that at least some of such features and/or processes or units are mutually exclusive. All processes or units of equipment are combined. Each feature disclosed in this specification (including accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。Furthermore, those skilled in the art will understand that although some embodiments described herein include some features included in other embodiments but not others, combinations of features from different embodiments are meant to be within the scope of the invention. and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的图片裁剪的装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all functions of some or all components in the image cropping apparatus according to the embodiment of the present invention. The present invention can also be implemented as an apparatus or an apparatus program (for example, a computer program and a computer program product) for performing a part or all of the methods described herein. Such a program for realizing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet site, or provided on a carrier signal, or provided in any other form.
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means can be embodied by one and the same item of hardware. The use of the words first, second, and third, etc. does not indicate any order. These words can be interpreted as names.
Claims (8)
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410820195.4A CN104484855B (en) | 2014-12-24 | 2014-12-24 | The method and apparatus that picture is cut |
PCT/CN2015/095862 WO2016101767A1 (en) | 2014-12-24 | 2015-11-27 | Picture cropping method and device and image detecting method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410820195.4A CN104484855B (en) | 2014-12-24 | 2014-12-24 | The method and apparatus that picture is cut |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104484855A CN104484855A (en) | 2015-04-01 |
CN104484855B true CN104484855B (en) | 2018-03-27 |
Family
ID=52759395
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410820195.4A Active CN104484855B (en) | 2014-12-24 | 2014-12-24 | The method and apparatus that picture is cut |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104484855B (en) |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2016101767A1 (en) * | 2014-12-24 | 2016-06-30 | 北京奇虎科技有限公司 | Picture cropping method and device and image detecting method and device |
CN106296760B (en) * | 2015-05-21 | 2021-05-14 | 腾讯科技(深圳)有限公司 | Picture clipping method and device |
CN106326823B (en) * | 2015-07-07 | 2020-06-30 | 北京神州泰岳软件股份有限公司 | Method and system for obtaining head portrait in picture |
CN105975204A (en) * | 2016-04-28 | 2016-09-28 | 深圳市金立通信设备有限公司 | Picture processing method and terminal |
CN107240105A (en) * | 2017-06-05 | 2017-10-10 | 深圳市茁壮网络股份有限公司 | A kind of image cropping method and device |
CN107622497B (en) * | 2017-09-29 | 2020-03-27 | Oppo广东移动通信有限公司 | Image cropping method and device, computer readable storage medium and computer equipment |
CN110298833B (en) * | 2019-06-28 | 2021-08-31 | 百度在线网络技术(北京)有限公司 | Picture processing method and device |
CN110703973B (en) * | 2019-09-30 | 2021-04-23 | 北京金山安全软件有限公司 | Image cropping method and device |
CN111062868B (en) * | 2019-12-03 | 2021-04-02 | 广州云从鼎望科技有限公司 | Image processing method, device, machine readable medium and equipment |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102339457A (en) * | 2010-07-16 | 2012-02-01 | 腾讯科技(深圳)有限公司 | Picture cropping method and system |
CN103903221A (en) * | 2012-12-24 | 2014-07-02 | 腾讯科技(深圳)有限公司 | Image generation method, image generation device and image generation system |
CN103914689A (en) * | 2014-04-09 | 2014-07-09 | 百度在线网络技术(北京)有限公司 | Picture cropping method and device based on face recognition |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2011019192A (en) * | 2009-07-10 | 2011-01-27 | Toshiba Corp | Image display |
-
2014
- 2014-12-24 CN CN201410820195.4A patent/CN104484855B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102339457A (en) * | 2010-07-16 | 2012-02-01 | 腾讯科技(深圳)有限公司 | Picture cropping method and system |
CN103903221A (en) * | 2012-12-24 | 2014-07-02 | 腾讯科技(深圳)有限公司 | Image generation method, image generation device and image generation system |
CN103914689A (en) * | 2014-04-09 | 2014-07-09 | 百度在线网络技术(北京)有限公司 | Picture cropping method and device based on face recognition |
Also Published As
Publication number | Publication date |
---|---|
CN104484855A (en) | 2015-04-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104484855B (en) | The method and apparatus that picture is cut | |
WO2016101767A1 (en) | Picture cropping method and device and image detecting method and device | |
CN110933296B (en) | Apparatus and method for providing content-aware photo filters | |
CN104484854A (en) | Cropping method and device for people pictures | |
EP2722850A1 (en) | Method for generating thumbnail image and electronic device thereof | |
EP2549735A3 (en) | Method of editing static digital combined images comprising images of multiple objects | |
EP3495996A3 (en) | Image processing method and apparatus, and electronic device | |
EP2784723A3 (en) | Method, system and computer program for comparing images | |
CN110889824A (en) | Sample generation method and device, electronic equipment and computer readable storage medium | |
EP3236415B1 (en) | Determining a boundary associated with image data | |
US20150310585A1 (en) | Method and apparatus for identifying a representative area of an image | |
KR101825200B1 (en) | Method and device for adsorbing straight line/line segment, and method and device for constructing polygon | |
US10051179B2 (en) | Photographing method, device and terminal | |
US20170053388A1 (en) | Techniques for automatically correcting groups of images | |
CN108810619A (en) | Identify the method, apparatus and electronic equipment of watermark in video | |
CN106028095A (en) | Method and device for controlling video playing | |
CN103390260B (en) | A kind of method and image processing apparatus for handling image | |
JP2015095711A (en) | Image processor, image processing method, program, and record medium | |
CN104484853A (en) | Method and device for clipping pictures containing graphical signs | |
JP5664346B2 (en) | Image processing apparatus, information providing system, and program | |
US20130051679A1 (en) | Image processing apparatus and image processing method | |
CN108833974B (en) | Method, device and electronic device for removing translucent watermark in video | |
CN105512595B (en) | Bar code modification method and device | |
EP3772042A3 (en) | Electronic apparatus for augmented reality and control method thereof | |
CN112183294B (en) | Text elimination method, device, electronic device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20220801 Address after: Room 801, 8th floor, No. 104, floors 1-19, building 2, yard 6, Jiuxianqiao Road, Chaoyang District, Beijing 100015 Patentee after: BEIJING QIHOO TECHNOLOGY Co.,Ltd. Address before: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park) Patentee before: BEIJING QIHOO TECHNOLOGY Co.,Ltd. Patentee before: Qizhi software (Beijing) Co.,Ltd. |
|
TR01 | Transfer of patent right |