







技术领域technical field
本公开涉及图像处理技术领域,具体而言,涉及一种图像处理方法、装置、计算机设备及可读存储介质。The present disclosure relates to the technical field of image processing, and in particular, to an image processing method, apparatus, computer device, and readable storage medium.
背景技术Background technique
在一些创意设计的工作中,往往需要一些图像素材,基于这些图像完成目标设计内容。但由于图像的来源、质量良莠不齐,无法直接利用,因此,通常需要先对图像进行加工处理,再利用处理过的图像进行下一步的设计工作。In some creative design work, some image materials are often needed, and the target design content is completed based on these images. However, because the source and quality of the images are mixed, they cannot be used directly. Therefore, it is usually necessary to process the images first, and then use the processed images for the next design work.
目前,在针对图像的处理方法中,对于图像中有用区域的筛选效率不高,且筛选得到的图像质量较低。At present, in the processing method for images, the screening efficiency of useful regions in the image is not high, and the quality of the image obtained by screening is low.
发明内容SUMMARY OF THE INVENTION
本公开实施例至少提供一种图像处理方法、装置、计算机设备及可读存储介质。Embodiments of the present disclosure provide at least an image processing method, an apparatus, a computer device, and a readable storage medium.
第一方面,本公开实施例提供了一种图像处理方法,包括:In a first aspect, an embodiment of the present disclosure provides an image processing method, including:
确定待处理图像中的至少一个裁剪位置;determining at least one cropping position in the image to be processed;
基于所述裁剪位置,确定针对所述剪裁位置的至少一种剪裁顺序;Based on the cropping positions, determining at least one cropping order for the cropping positions;
针对每种剪裁顺序,基于所述至少一个裁剪位置分别在所述待处理图像中的位置信息,对所述待处理图像进行剪裁,得到该所述剪裁顺序对应的至少一张子图像;For each cropping order, based on the position information of the at least one cropping position in the to-be-processed image, the to-be-processed image is cropped to obtain at least one sub-image corresponding to the cropped order;
从所述子图像中,筛选得到第一目标子图像。From the sub-images, a first target sub-image is obtained by screening.
一种可选的实施方式中,所述确定待处理图像中的至少一个裁剪位置,包括:In an optional implementation manner, the determining at least one cropping position in the image to be processed includes:
对所述待处理图像进行第一目标检测处理,确定待剪裁的第一目标对象在所述待处理图像中的位置信息;Perform a first target detection process on the to-be-processed image, and determine the position information of the to-be-cropped first target object in the to-be-processed image;
基于所述位置信息,确定所述裁剪位置。Based on the position information, the cropping position is determined.
一种可选的实施方式中,所述基于所述裁剪位置,确定剪裁顺序,包括:In an optional implementation manner, the determining of the trimming order based on the trimming position includes:
基于所述裁剪位置,为各个裁剪位置添加编号信息;Based on the clipping position, adding numbering information for each clipping position;
根据各个所述裁剪位置对应的编号信息,生成至少一组对所述裁剪位置进行剪裁的剪裁顺序。According to the number information corresponding to each of the cropping positions, at least one set of cropping sequences for cropping the cropping positions is generated.
一种可选的实施方式中,所述针对每种剪裁顺序,基于所述至少一个裁剪位置分别在所述待处理图像中的位置信息,对所述待处理图像进行剪裁,得到该所述剪裁顺序对应的至少一张子图像,包括:In an optional implementation manner, the image to be processed is clipped based on the position information of the at least one clipping position in the image to be processed for each clipping order, and the clipping is obtained. At least one sub-image corresponding to the sequence, including:
针对每种剪裁顺序,基于该剪裁顺序所指示的剪裁顺序,确定当前裁剪位置;For each cropping order, determine the current cropping position based on the cropping order indicated by the cropping order;
确定与所述当前裁剪位置对应的待剪裁图像;其中,所述待剪裁图像包括:所述待处理图像,或者与其他裁剪位置对应的剪裁结果图像;determining an image to be cropped corresponding to the current cropping position; wherein the to-be-cropped image includes: the to-be-processed image, or a cropping result image corresponding to other cropping positions;
基于所述至少一个裁剪位置分别对应的剪裁结果图像,确定该剪裁顺序对应的至少一张子图像。Based on the cropping result images corresponding to the at least one cropping position respectively, at least one sub-image corresponding to the cropping sequence is determined.
一种可选的实施方式中,基于所述裁剪位置在所述待剪裁图像中的位置信息,对所述待剪裁图像进行剪裁处理,得到与所述当前裁剪位置对应的剪裁结果图像,包括:In an optional embodiment, based on the position information of the cropping position in the to-be-cropped image, the cropping process is performed on the to-be-cropped image to obtain a cropping result image corresponding to the current cropping position, including:
基于所述裁剪位置在所述待剪裁图像中的位置信息,对所述待剪裁图像进行剪裁处理,得到与该剪裁位置对应的备选图像;Based on the position information of the cropping position in the to-be-cropped image, the cropping process is performed on the to-be-cropped image to obtain a candidate image corresponding to the cropping position;
响应于所述备选图像满足预设条件,将该张备图像确定为所述当前裁剪位置对应的剪裁结果图像。In response to the candidate image satisfying a preset condition, the candidate image is determined as the cropping result image corresponding to the current cropping position.
一种可选的实施方式中,所述基于所述至少一个裁剪位置分别对应的剪裁结果图像,确定该剪裁顺序对应的至少一张子图像包括:In an optional implementation manner, the determining of at least one sub-image corresponding to the cropping order based on the cropping result images corresponding to the at least one cropping position respectively includes:
确定所述剪裁结果图像中是否包括第二目标对象;determining whether a second target object is included in the cropped result image;
响应于所述剪裁结果图像中包括所述第二目标对象,且所述第二目标对象的完整度满足预设的完整度条件,将所述剪裁结果图像确定为该剪裁顺序对应的子图像。In response to the cropping result image including the second target object and the integrity of the second target object satisfying a preset integrity condition, the cropping result image is determined as a sub-image corresponding to the cropping order.
一种可选的实施方式中,所述从所述子图像中,筛选得到第一目标子图像,包括:In an optional embodiment, the filtering to obtain the first target sub-image from the sub-images includes:
针对每张子图像,响应于该张子图像包括第二目标对象,确定所述第二目标对象是否满足预设的筛选条件;For each sub-image, in response to the sub-image including the second target object, determining whether the second target object satisfies a preset screening condition;
响应于所述第二目标对象满足所述预设的筛选条件,将该张子图像确定为所述第一目标子图像。In response to the second target object satisfying the preset screening condition, the sub-image is determined as the first target sub-image.
一种可选的实施方式中,所述第二目标对象包括人脸;In an optional implementation manner, the second target object includes a human face;
所述预设的筛选条件包括下述至少一种:The preset screening conditions include at least one of the following:
所述人脸占据的第一面积、与所述待处理图像的第二面积的比值,大于预设比值;The ratio of the first area occupied by the face to the second area of the image to be processed is greater than a preset ratio;
所述人脸的嘴部张开程度小于预设角度;The mouth opening degree of the face is less than the preset angle;
所述人脸的偏转角度位于预设偏转角度范围内;The deflection angle of the face is within a preset deflection angle range;
所述人脸的人眼宽高比位于预设的宽高比范围。The human-eye aspect ratio of the human face is within a preset aspect ratio range.
一种可选的实施方式中,所述方法还包括:In an optional embodiment, the method further includes:
对所述第一目标子图像进行预设风格迁移处理,得到第二目标子图像。Perform preset style transfer processing on the first target sub-image to obtain a second target sub-image.
第二方面,本公开实施例还提供一种图像处理装置,包括:In a second aspect, an embodiment of the present disclosure further provides an image processing apparatus, including:
第一确定模块,用于确定待处理图像中的至少一个裁剪位置;a first determining module, configured to determine at least one cropping position in the image to be processed;
第二确定模块,用于基于所述裁剪位置,确定针对所述剪裁位置的至少一种剪裁顺序;a second determining module, configured to determine at least one trimming order for the trimming position based on the trimming position;
剪裁模块,用于针对每种剪裁顺序,基于所述至少一个裁剪位置分别在所述待处理图像中的位置信息,对所述待处理图像进行剪裁,得到该所述剪裁顺序对应的至少一张子图像;A cropping module, configured to crop the to-be-processed image based on the position information of the at least one cropping position in the to-be-processed image for each cropping order, and obtain at least one image corresponding to the cropping order subimage;
筛选模块,用于从所述子图像中,筛选得到第一目标子图像。The screening module is used for screening the sub-images to obtain the first target sub-image.
一种可选的实施方式中,所述第一确定模块具体用于:In an optional implementation manner, the first determining module is specifically configured to:
对所述待处理图像进行第一目标检测处理,确定待剪裁的第一目标对象在所述待处理图像中的位置信息;Perform a first target detection process on the to-be-processed image, and determine the position information of the to-be-cropped first target object in the to-be-processed image;
基于所述位置信息,确定所述裁剪位置。Based on the position information, the cropping position is determined.
一种可选的实施方式中,所述第二确定模块具体用于:In an optional implementation manner, the second determining module is specifically configured to:
基于所述裁剪位置,为各个裁剪位置添加编号信息;Based on the clipping position, adding numbering information for each clipping position;
根据各个所述裁剪位置对应的编号信息,生成至少一组对所述裁剪位置进行剪裁的剪裁顺序;generating at least one set of trimming sequences for trimming the trimming positions according to the number information corresponding to each of the trimming positions;
基于所述剪裁顺序,确定所述剪裁顺序。Based on the clipping order, the clipping order is determined.
一种可选的实施方式中,所述剪裁模块包括:In an optional implementation manner, the tailoring module includes:
第一确定单元,用于针对每种剪裁顺序,基于该剪裁顺序所指示的剪裁顺序,确定当前裁剪位置;a first determining unit for determining the current cropping position for each cropping order based on the cropping order indicated by the cropping order;
第二确定单元,用于确定与所述当前裁剪位置对应的待剪裁图像;其中,所述待剪裁图像包括:所述待处理图像,或者与其他裁剪位置对应的剪裁结果图像;a second determining unit, configured to determine an image to be cropped corresponding to the current cropping position; wherein, the image to be cropped includes: the to-be-processed image, or a cropping result image corresponding to other cropping positions;
第三确定单元,用于基于所述至少一个裁剪位置分别对应的剪裁结果图像,确定该剪裁顺序对应的至少一张子图像。A third determining unit, configured to determine at least one sub-image corresponding to the clipping sequence based on the clipping result images corresponding to the at least one clipping position respectively.
一种可选的实施方式中,所述剪裁单元具体用于:In an optional implementation manner, the trimming unit is specifically used for:
基于所述裁剪位置在所述待剪裁图像中的位置信息,对所述待剪裁图像进行剪裁处理,得到与该剪裁位置对应的备选图像;Based on the position information of the cropping position in the to-be-cropped image, the cropping process is performed on the to-be-cropped image to obtain a candidate image corresponding to the cropping position;
响应于所述备选图像满足预设条件,将该张备图像确定为所述当前裁剪位置对应的剪裁结果图像。In response to the candidate image satisfying a preset condition, the candidate image is determined as the cropping result image corresponding to the current cropping position.
一种可选的实施方式中,所述第三确定单元具体用于:In an optional implementation manner, the third determining unit is specifically used for:
确定所述剪裁结果图像中是否包括第二目标对象;determining whether a second target object is included in the cropped result image;
响应于所述剪裁结果图像中包括所述第二目标对象,且所述第二目标对象的完整度满足预设的完整度条件,将所述剪裁结果图像确定为该剪裁顺序对应的子图像。In response to the cropping result image including the second target object and the integrity of the second target object satisfying a preset integrity condition, the cropping result image is determined as a sub-image corresponding to the cropping order.
一种可选的实施方式中,所述筛选模块具体用于:In an optional embodiment, the screening module is specifically used for:
针对每张子图像,响应于该张子图像包括第二目标对象,确定所述第二目标对象是否满足预设的筛选条件;For each sub-image, in response to the sub-image including the second target object, determining whether the second target object satisfies a preset screening condition;
响应于所述第二目标对象满足所述预设的筛选条件,将该张子图像确定为所述第一目标子图像。In response to the second target object satisfying the preset screening condition, the sub-image is determined as the first target sub-image.
一种可选的实施方式中,所述第二目标对象包括人脸;In an optional implementation manner, the second target object includes a human face;
所述预设的筛选条件包括下述至少一种:The preset screening conditions include at least one of the following:
所述人脸占据的第一面积、与所述待处理图像的第二面积的比值,大于预设比值;The ratio of the first area occupied by the face to the second area of the image to be processed is greater than a preset ratio;
所述人脸的嘴部张开程度小于预设角度;The mouth opening degree of the face is less than the preset angle;
所述人脸的偏转角度位于预设偏转角度范围内;The deflection angle of the face is within a preset deflection angle range;
所述人脸的人眼宽高比位于预设的宽高比范围。The human-eye aspect ratio of the human face is within a preset aspect ratio range.
一种可选的实施方式中,所述装置还包括:In an optional embodiment, the device further includes:
处理模块,用于对所述第一目标子图像进行预设风格迁移处理,得到第二目标子图像。A processing module, configured to perform preset style transfer processing on the first target sub-image to obtain a second target sub-image.
第三方面,本公开实施例还提供一种计算机设备,包括:处理器、存储器和总线,所述存储器存储有所述处理器可执行的机器可读指令,当计算机设备运行时,所述处理器与所述存储器之间通过总线通信,所述机器可读指令被所述处理器执行时执行上述第一方面,或第一方面中任一种可能的实施方式中的步骤。In a third aspect, embodiments of the present disclosure further provide a computer device, including: a processor, a memory, and a bus, where the memory stores machine-readable instructions executable by the processor, and when the computer device runs, the processing A bus communicates between the processor and the memory, and when the machine-readable instructions are executed by the processor, the first aspect or the steps in any possible implementation manner of the first aspect are performed.
第四方面,本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述第一方面,或第一方面中任一种可能的实施方式中的步骤。In a fourth aspect, embodiments of the present disclosure further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and the computer program is executed by a processor to execute the first aspect, or any one of the first aspect. steps in one possible implementation.
本公开实施例提供的一种图像处理方法、装置、计算机设备及可读存储介质,通过确定待处理图像中的裁剪位置,并基于裁剪位置以及每个裁剪位置对应的位置对该待处理图像进行剪裁,得到至少一个子图像,并对得到的子图像进行筛选,得到目标子图像。这样,通过对于待处理图像进行裁剪以及筛选过程,可以根据实际的素材使用需求,从中筛选符合质量的目标子图像,提升筛选得到的目标子图像的质量。An image processing method, apparatus, computer device, and readable storage medium provided by the embodiments of the present disclosure determine a cropping position in an image to be processed, and perform processing on the to-be-processed image based on the cropping position and the position corresponding to each cropping position. Crop to obtain at least one sub-image, and filter the obtained sub-image to obtain the target sub-image. In this way, through the process of cropping and screening the to-be-processed image, target sub-images that meet the quality can be screened according to actual material usage requirements, and the quality of the target sub-image obtained by screening can be improved.
为使本公开的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。In order to make the above-mentioned objects, features and advantages of the present disclosure more obvious and easy to understand, the preferred embodiments are exemplified below, and are described in detail as follows in conjunction with the accompanying drawings.
附图说明Description of drawings
为了更清楚地说明本公开实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,此处的附图被并入说明书中并构成本说明书中的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to explain the technical solutions of the embodiments of the present disclosure more clearly, the following briefly introduces the accompanying drawings required in the embodiments, which are incorporated into the specification and constitute a part of the specification. The drawings illustrate embodiments consistent with the present disclosure, and together with the description serve to explain the technical solutions of the present disclosure. It should be understood that the following drawings only show some embodiments of the present disclosure, and therefore should not be regarded as limiting the scope. Other related figures are obtained from these figures.
图1示出了本公开实施例所提供的一种图像处理方法的流程图;FIG. 1 shows a flowchart of an image processing method provided by an embodiment of the present disclosure;
图2示出了本公开实施例所提供的图像处理方法的处理示意图之一;FIG. 2 shows one of the processing schematic diagrams of the image processing method provided by the embodiment of the present disclosure;
图3示出了本公开实施例所提供的图像处理方法的处理示意图之二;FIG. 3 shows the second processing schematic diagram of the image processing method provided by the embodiment of the present disclosure;
图4示出了本公开实施例所提供的另一种图像处理方法的流程图;FIG. 4 shows a flowchart of another image processing method provided by an embodiment of the present disclosure;
图5示出了本公开实施例所提供的一种图像处理装置的示意图;FIG. 5 shows a schematic diagram of an image processing apparatus provided by an embodiment of the present disclosure;
图6示出了本公开实施例所提供的图像处理装置中,剪裁模块的具体示意图;FIG. 6 shows a specific schematic diagram of a cropping module in an image processing apparatus provided by an embodiment of the present disclosure;
图7示出了本公开实施例所提供的另一种图像处理装置的示意图;FIG. 7 shows a schematic diagram of another image processing apparatus provided by an embodiment of the present disclosure;
图8示出了本公开实施例所提供的一种计算机设备的示意图。FIG. 8 shows a schematic diagram of a computer device provided by an embodiment of the present disclosure.
具体实施方式Detailed ways
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本公开的实施例的详细描述并非旨在限制要求保护的本公开的范围,而是仅仅表示本公开的选定实施例。基于本公开的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only These are some, but not all, embodiments of the present disclosure. The components of the disclosed embodiments generally described and illustrated in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the disclosure provided in the accompanying drawings is not intended to limit the scope of the disclosure as claimed, but is merely representative of selected embodiments of the disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present disclosure.
经研究发现,在一些创意设计的工作中,往往需要一些素材,比如图像、视频等,基于这些素材完成目标设计内容。但由于素材的来源、质量良莠不齐,无法直接利用,因此,通常需要先对素材进行加工处理,再利用处理过的素材进行下一步的设计工作。例如,以素材为图像为例,将图像中的文字以及水印部分进行裁剪,以达到提取图像主体的目的,之后对裁剪后的图像根据不同的需求进行派生或者筛选,达到补充图像类型元素库的目的。The research found that in some creative design work, some materials, such as images, videos, etc., are often needed to complete the target design content based on these materials. However, because the source and quality of the materials are mixed, they cannot be used directly. Therefore, it is usually necessary to process the materials first, and then use the processed materials for the next design work. For example, taking the material as an image as an example, the text and watermark part in the image are cropped to achieve the purpose of extracting the main body of the image, and then the cropped image is derived or filtered according to different needs, so as to supplement the image type element library. Purpose.
在素材生产的过程中,一部分素材资源需要通过用户上传内容或是在本地创建的素材库中提取,但是无论是用户上传的内容还是本地素材,都较难直接对素材进行加工生成目标图像。其原因一方面是因为在大多数图像中,符合筛选条件的区域只占据图像的一部分,并非整张图像,一张图像中往往存在一些水印、图标或者搭配了一些与计划生成的图像内容无关的文案,如果不进行处理将会对展现的图像内容产生影响;另一方面由于某些特定的需要,可能倾向于提取图像中的某些特定元素,比如人脸、物品、环境等等。由此,需要对图像进行一定程度上的处理,以使可以获取满足预期标准的目标图像。In the process of material production, some material resources need to be uploaded by the user or extracted from the locally created material library. However, whether it is the content uploaded by the user or the local material, it is difficult to directly process the material to generate the target image. On the one hand, the reason is that in most images, the area that meets the filtering conditions only occupies a part of the image, not the entire image. There are often some watermarks, icons, or some unrelated images in an image. Copywriting, if not processed, will have an impact on the content of the displayed image; on the other hand, due to some specific needs, it may tend to extract some specific elements in the image, such as faces, objects, environments, and so on. Thus, the image needs to be processed to some extent so that a target image that meets the desired criteria can be acquired.
现有技术中,可以通过光学字符识别(Optical Character Recognition,OCR)等方法准确地识别图像中的文字区域,同时利用与水印识别相关的深度学习模型等对图像上的水印进行识别。但是,由于水印识别模型对于图像中文字的识别比较敏感,但是对于文字区域的识别又不是很准确,因此常常会框选多余的、文字或是水印周边的内容。因此,直接使用上述方法容易导致对图像暴力裁剪,那么得到的可用区域将会很小,不但损失了图像中大片可用的色彩区域,同时对于一些特殊区域的取舍也无法判别,导致图像的利用率较低,处理效率不高。In the prior art, a text area in an image can be accurately recognized by methods such as Optical Character Recognition (OCR), and a watermark on an image can be recognized by using a deep learning model related to watermark recognition. However, since the watermark recognition model is more sensitive to the recognition of text in the image, but is not very accurate for the recognition of the text area, it often selects redundant, text or content around the watermark. Therefore, directly using the above method will easily lead to violent cropping of the image, so the available area will be very small, which not only loses a large area of the available color area in the image, but also cannot distinguish the choice of some special areas, resulting in the utilization of the image. low, the processing efficiency is not high.
基于上述研究,本公开提供了一种图像处理方法,通过确定待处理图像中的裁剪位置,并基于裁剪位置以及每个裁剪位置对应的位置对该待处理图像进行剪裁,得到至少一个子图像,并对得到的子图像进行筛选,得到目标子图像。这样,通过对于待处理图像进行裁剪以及筛选过程,可以根据实际的素材使用需求,从中筛选符合质量的目标子图像,提升筛选得到的目标子图像的质量。Based on the above research, the present disclosure provides an image processing method, by determining a cropping position in an image to be processed, and cropping the to-be-processed image based on the cropping position and the position corresponding to each cropping position, to obtain at least one sub-image, The obtained sub-images are filtered to obtain the target sub-images. In this way, through the process of cropping and screening the to-be-processed image, target sub-images that meet the quality can be screened according to actual material usage requirements, and the quality of the target sub-image obtained by screening can be improved.
针对以上方案所存在的缺陷,均是发明人在经过实践并仔细研究后得出的结果,因此,上述问题的发现过程以及下文中本公开针对上述问题所提出的解决方案,都应该是发明人在本公开过程中对本公开做出的贡献。The defects existing in the above solutions are all the results obtained by the inventor after practice and careful research. Therefore, the discovery process of the above problems and the solutions to the above problems proposed by the present disclosure hereinafter should be the inventors Contributions made to this disclosure during the course of this disclosure.
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。It should be noted that like numerals and letters refer to like items in the following figures, so once an item is defined in one figure, it does not require further definition and explanation in subsequent figures.
为便于对本实施例进行理解,首先对本公开实施例所公开的一种图像处理方法进行详细介绍,本公开实施例所提供的图像处理方法的执行主体一般为具有一定计算能力的计算机设备,该计算机设备例如包括:终端设备或服务器或其它处理设备。在一些可能的实现方式中,该图像处理方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。In order to facilitate the understanding of this embodiment, an image processing method disclosed in the embodiment of the present disclosure is first introduced in detail. Devices include, for example, terminal devices or servers or other processing devices. In some possible implementations, the image processing method may be implemented by the processor calling computer-readable instructions stored in the memory.
下面以执行主体为终端设备为例对本公开实施例提供的一种图像处理方法加以说明。The following describes an image processing method provided by an embodiment of the present disclosure by taking the execution subject as a terminal device as an example.
参见图1所示,为本公开实施例提供的图像处理方法的流程图,所述方法包括步骤S101~S104,其中:Referring to FIG. 1, which is a flowchart of an image processing method provided by an embodiment of the present disclosure, the method includes steps S101-S104, wherein:
S101:确定待处理图像中的至少一个裁剪位置。S101: Determine at least one cropping position in the image to be processed.
其中,所述待处理图像中存在一些水印、图标或者搭配了一些与计划生成的图像内容无关的文字等。对应的,裁剪位置为水印、图标、文字等需要去除掉的图像内容对应的区域,在本公开实施例中,为了方便后续剪裁,可以确定该裁剪位置为矩形。Wherein, the to-be-processed image contains some watermarks, icons, or is matched with some texts that are not related to the content of the image to be generated. Correspondingly, the cropping position is the area corresponding to the image content that needs to be removed, such as watermarks, icons, texts, etc. In this embodiment of the present disclosure, in order to facilitate subsequent cropping, the cropping position may be determined to be a rectangle.
在本公开一可能的实施方式中,通过以下方法确定待处理图像中的至少一个裁剪位置:In a possible implementation manner of the present disclosure, at least one cropping position in the image to be processed is determined by the following method:
对所述待处理图像进行第一目标检测处理,确定待剪裁的第一目标对象在所述待处理图像中的位置信息;Perform a first target detection process on the to-be-processed image, and determine the position information of the to-be-cropped first target object in the to-be-processed image;
基于所述位置信息,确定所述裁剪位置。Based on the position information, the cropping position is determined.
在本公开实施例中,可以通过一定的目标对象检测方法对待处理图像进行检测,以确定待剪裁的第一目标对象对应的位置信息,并以此确定裁剪位置。In the embodiment of the present disclosure, the to-be-processed image may be detected by a certain target object detection method, so as to determine the position information corresponding to the first target object to be clipped, and then determine the clipping position.
示例性的,所述第一目标对象可以为水印、图标、文字等,当第一目标对象为水印时,可以利用水印检测模型对对待处理图像进行检测,以确定待处理图像中水印对应的位置信息,并以该水印为基准确定裁剪位置,具体的,可以通过确定该水印对应的坐标信息,绘制包括该水印的矩形框,并确定该矩形框为裁剪位置。Exemplarily, the first target object can be a watermark, an icon, a text, etc. When the first target object is a watermark, a watermark detection model can be used to detect the image to be processed to determine the position corresponding to the watermark in the image to be processed. information, and the cropping position is determined based on the watermark. Specifically, a rectangular frame including the watermark can be drawn by determining the coordinate information corresponding to the watermark, and the rectangular frame is determined as the cropping position.
此外,针对于待处理图像中的图标、文字等,可以利用图标检测模型、文字检测模型等对待处理图像进行检测,并确定对应的裁剪位置,在此不再赘述。In addition, for icons, text, etc. in the image to be processed, an icon detection model, a text detection model, etc. may be used to detect the to-be-processed image, and to determine the corresponding cropping position, which will not be repeated here.
承接于上述S101,在确定待处理图像中的至少一个裁剪位置之后,所述图像处理方法还包括:Following the above step S101, after determining at least one cropping position in the image to be processed, the image processing method further includes:
S102:基于所述裁剪位置,确定针对所述剪裁位置的至少一种剪裁顺序。S102: Based on the cropping position, determine at least one cropping order for the cropping position.
其中,所述剪裁顺序与预先确定的裁剪位置相关联,指示了对每个裁剪位置处理的先后顺序。Wherein, the clipping order is associated with a predetermined clipping position, and indicates the sequence of processing each clipping position.
在本公开一可能的实施方式中,通过下述步骤基于所述裁剪位置,确定剪裁顺序:In a possible implementation manner of the present disclosure, the trimming sequence is determined based on the trimming position through the following steps:
基于所述裁剪位置,为各个裁剪位置添加编号信息;Based on the clipping position, adding numbering information for each clipping position;
根据各个所述裁剪位置对应的编号信息,生成至少一组对所述裁剪位置进行剪裁的剪裁顺序;generating at least one set of trimming sequences for trimming the trimming positions according to the number information corresponding to each of the trimming positions;
基于所述剪裁顺序,确定所述剪裁顺序。Based on the clipping order, the clipping order is determined.
具体的,确定出所述待处理图像中包括的裁剪位置,并利用数字或字母等对每个裁剪位置进行编号,并根据各个裁剪位置对应的编号信息确定出剪裁顺序,并将该剪裁顺序作为剪裁顺序,对待处理图像进行剪裁处理。Specifically, the cropping positions included in the to-be-processed image are determined, and numbers or letters are used to number each cropping position, and the cropping order is determined according to the numbering information corresponding to each cropping position, and the cropping order is used as Cropping order, the image to be processed is cropped.
示例性的,参见图2所示,为本公开实施例所提供的图像处理方法的处理示意图之一。在图2中,包括两个裁剪位置,将其分别编号为A和B,由此可以确定剪裁顺序为先剪裁裁剪位置A再剪裁裁剪位置B,或者,先剪裁裁剪位置B再剪裁裁剪位置A,在确定出剪裁顺序后,将确定的剪裁顺序作为剪裁顺序。具体的,剪裁顺序可以随机进行确定,或者基于一定的属性信息进行确定,例如根据多个裁剪位置的面积大小或者相对位置的上下左右等确定剪裁顺序,并指定剪裁顺序,在此不作限定。Exemplarily, see FIG. 2 , which is one of the processing schematic diagrams of the image processing method provided by the embodiment of the present disclosure. In Fig. 2, two cropping positions are included, and they are numbered as A and B respectively, so that it can be determined that the cropping order is to crop cropping position A first and then crop cropping position B, or, first crop cropping position B and then crop cropping position A , after determining the trimming order, use the determined trimming order as the trimming order. Specifically, the cropping order may be determined randomly or based on certain attribute information, for example, the cropping order may be determined according to the area size of multiple cropping positions or the relative positions of the top, bottom, left, right, etc., and the cropping order is specified, which is not limited here.
承接于上述S102,在基于所述裁剪位置,确定剪裁顺序之后,所述图像处理方法还包括:Following the above step S102, after determining the cropping order based on the cropping position, the image processing method further includes:
S103:针对每种剪裁顺序,基于所述至少一个裁剪位置分别在所述待处理图像中的位置信息,对所述待处理图像进行剪裁,得到该所述剪裁顺序对应的至少一张子图像。S103: For each cropping order, based on the position information of the at least one cropping position in the to-be-processed image respectively, crop the to-be-processed image to obtain at least one sub-image corresponding to the cropping order.
其中,所述至少一个裁剪位置分别在所述待处理图像中的位置信息可以为基于预先建立好的坐标系而确定的每个裁剪位置对应的坐标位置。子图像为对待处理图像进行剪裁处理后,不包括任一第一目标对象的图像。Wherein, the position information of the at least one cropping position in the image to be processed may be a coordinate position corresponding to each cropping position determined based on a pre-established coordinate system. The sub-image is an image that does not include any first target object after the image to be processed is cropped.
在本公开一可能的实施方式中,通过下述方法针对每种剪裁顺序,基于所述至少一个裁剪位置分别在所述待处理图像中的位置信息,对所述待处理图像进行剪裁,得到该剪裁顺序对应的至少一张子图像:In a possible implementation manner of the present disclosure, for each cropping order, the following method is used to crop the to-be-processed image based on the position information of the at least one cropping position in the to-be-processed image, to obtain the At least one sub-image corresponding to the crop order:
针对每种剪裁顺序,基于该剪裁顺序所指示的剪裁顺序,确定当前裁剪位置;For each cropping order, determine the current cropping position based on the cropping order indicated by the cropping order;
确定与所述当前裁剪位置对应的待剪裁图像;其中,所述待剪裁图像包括:所述待处理图像,或者与其他裁剪位置对应的剪裁结果图像;determining an image to be cropped corresponding to the current cropping position; wherein the to-be-cropped image includes: the to-be-processed image, or a cropping result image corresponding to other cropping positions;
基于所述裁剪位置在所述待剪裁图像中的位置信息,对所述待剪裁图像进行剪裁处理,得到与所述当前裁剪位置对应的剪裁结果图像;Based on the position information of the cropping position in the to-be-cropped image, performing a cropping process on the to-be-cropped image to obtain a cropping result image corresponding to the current cropping position;
基于所述至少一个裁剪位置分别对应的剪裁结果图像,确定该剪裁顺序对应的至少一张子图像。Based on the cropping result images corresponding to the at least one cropping position respectively, at least one sub-image corresponding to the cropping sequence is determined.
在本公开实施例中,基于预先确定出的剪裁顺序,确定出在多个裁剪位置中首先处理的裁剪位置。之后,确定出该裁剪位置在待处理图像中对应的待剪裁图像,并基于该待剪裁图像相对于所述待处理图像的位置信息,对该待剪裁图像进行剪裁处理,得到与该裁剪位置对应的剪裁结果图像。在得到首先处理的裁剪位置对应的剪裁结果图像之后,基于剪裁顺序指示的后续处理的裁剪位置,对该裁剪位置对应的剪裁结果图像进行与上述处理过程相似的处理过程,直至完成对所有裁剪位置的处理过程,得到该剪裁顺序对应的至少一张子图像。也就是说,在对待处理图像基于第一个裁剪位置进行剪裁处理,得到剪裁结果图像之后,按照剪裁顺序指示的对裁剪位置进行处理的剪裁顺序,对包括裁剪位置的剪裁结果图像进行剪裁,直至对全部裁剪位置处理完成得到该剪裁顺序对应的至少一张子图像。In the embodiment of the present disclosure, based on the predetermined cropping order, the cropping position to be processed first among the plurality of cropping positions is determined. After that, determine the to-be-cropped image corresponding to the cropping position in the to-be-processed image, and based on the position information of the to-be-cropped image relative to the to-be-processed image, perform a cropping process on the to-be-cropped image to obtain a corresponding cropping position The cropped result image. After the cropping result image corresponding to the cropping position processed first is obtained, based on the cropping position of the subsequent processing indicated by the cropping order, the cropping result image corresponding to the cropping position is subjected to a processing process similar to the above processing process, until all cropping positions are completed. process to obtain at least one sub-image corresponding to the cropping sequence. That is to say, after the image to be processed is cropped based on the first cropping position and the cropping result image is obtained, the cropping result image including the cropping position is cropped according to the cropping order indicated by the cropping order for processing the cropping position, until After all the cropping positions are processed, at least one sub-image corresponding to the cropping order is obtained.
在本公开实施例中,通过下述方法基于所述裁剪位置在所述待剪裁图像中的位置信息,对所述待剪裁图像进行剪裁处理,得到与所述当前裁剪位置对应的剪裁结果图像:In an embodiment of the present disclosure, based on the position information of the cropping position in the to-be-cropped image, the cropping process is performed on the to-be-cropped image to obtain a cropping result image corresponding to the current cropping position:
基于所述裁剪位置在所述待剪裁图像中的位置信息,对所述待剪裁图像进行剪裁处理,得到与该剪裁位置对应的备选图像;Based on the position information of the cropping position in the to-be-cropped image, the cropping process is performed on the to-be-cropped image to obtain a candidate image corresponding to the cropping position;
响应于所述备选图像满足预设条件,将该张备图像确定为所述当前裁剪位置对应的剪裁结果图像。In response to the candidate image satisfying a preset condition, the candidate image is determined as the cropping result image corresponding to the current cropping position.
参见图3所示,为本公开实施例所提供的图像处理方法的处理示意图之二。Referring to FIG. 3 , the second schematic diagram of processing of the image processing method provided by the embodiment of the present disclosure is shown.
具体的,可以获取所述待处理图像的第一坐标,以及所述裁剪位置的第二坐标,基于所述第一坐标以及所述第二坐标,确定第三坐标,确定所述待处理图像中,去除所述第三坐标对应区域的图像为备选图像,也即该剪裁位置对应的备选图像。之后,确定每次剪裁得到的备选图像的面积,基于备选图像相对于所述待处理图像的面积占比,对备选图像进行筛选,直至得到该剪裁顺序对应的至少一张子图像。Specifically, the first coordinates of the image to be processed and the second coordinates of the cropping position can be obtained, and based on the first coordinates and the second coordinates, a third coordinate is determined, and a third coordinate is determined in the image to be processed. , the image from which the region corresponding to the third coordinate is removed is a candidate image, that is, the candidate image corresponding to the clipping position. After that, the area of the candidate image obtained by each cropping is determined, and based on the area ratio of the candidate image relative to the image to be processed, the candidate image is screened until at least one sub-image corresponding to the cropping order is obtained.
示例性的,针对任一裁剪位置,当该裁剪位置位于例如图3所示的位置上时,假设待裁剪区域坐标为(a1,b1,a2,b2),待处理图像的坐标为(x1,y1,x2,y2)。那么重合区域坐标可以如下式所示:Exemplarily, for any cropping position, when the cropping position is located at, for example, the position shown in FIG. 3 , assuming that the coordinates of the region to be cropped are (a1 , b1 , a2 , b2 ), the coordinates of the image to be processed are is (x1 , y1 , x2 , y2 ). Then the coordinates of the overlapping area can be expressed as follows:
m1=max(a1,x1),m2=min(a2,x2),n1=max(b1,y1),n2=min(b2,y2)m1 =max(a1 ,x1 ),m2 =min(a2 ,x2 ),n1 =max(b1 ,y1 ),n2 =min(b2 ,y2 )
m2>m1,n2>n1m2 >m1 ,n2 >n1
在得到重叠区域坐标(m1,n1,m2,n2)后,将其边缘从待处理图像中裁剪掉,最多可得4张备选图像,最少一张备选图像,在图3中,其对应的四张备选图像分别为1+2+3所表征的区域、1+4+7所表征的区域、7+8+9所表征的区域、3+6+9所表征的区域。之后,判断备选图像的面积是否大于待处理图像的1/3,如不满足则直接舍弃,否则将该备选图像添加至待处理队列中,准备对该备选图像所包括的其他裁剪位置进行剪裁处理,直到所有裁剪位置均被裁剪完毕,返回待处理队列中剩余的所有备选图像。After obtaining the coordinates of the overlapping area (m1 , n1 , m2 , n2 ), the edges are cropped from the image to be processed, and a maximum of 4 candidate images and a minimum of one candidate image can be obtained. In Figure 3, the corresponding The four candidate images are the area represented by 1+2+3, the area represented by 1+4+7, the area represented by 7+8+9, and the area represented by 3+6+9. After that, judge whether the area of the candidate image is larger than 1/3 of the image to be processed, if not, discard it directly, otherwise add the candidate image to the queue to be processed, and prepare for other cropping positions included in the candidate image The cropping process is performed until all cropping positions have been cropped, and all candidate images remaining in the queue to be processed are returned.
在本公开另一实施例中,在所有的待处理区域都被剪裁筛选完成后,若不存在满足要求的子图像,则进行下一张待处理图像的裁剪过程。当得到多张子图像时,此时可以根据需求以及实际情况,确定选取一张最合理的子图像,还是选取多张子图像。In another embodiment of the present disclosure, after all to-be-processed regions have been cropped and screened, if there is no sub-image that meets the requirements, a cropping process of the next to-be-processed image is performed. When multiple sub-images are obtained, at this time, it can be determined whether to select a most reasonable sub-image or to select multiple sub-images according to the requirements and the actual situation.
示例性的,当得到多张子图像,但是需要选取一张或多张合理的子图像时,可以输出面积最大的一张子图像,或者通过判断不同子图像之间的感兴趣区域(region ofinterest,ROI)进行选取。Exemplarily, when multiple sub-images are obtained, but one or more reasonable sub-images need to be selected, a sub-image with the largest area can be output, or by judging the region of interest between different sub-images. , ROI) to select.
示例性的,ROI指的是两个子图像重叠部分面积相对于两个子图像的面积减去重叠部分面积的面积数值的比例数值,若ROI<0.9则认为不同的子图像是归属于不同的裁剪方案,将其均进行输出。Exemplarily, ROI refers to the ratio of the area of the overlapping part of the two sub-images to the area of the two sub-images minus the area value of the overlapping part area. If ROI<0.9, it is considered that different sub-images belong to different cropping schemes. , and output them all.
在本公开实施例中,通过下述方法基于所述至少一个裁剪位置分别对应的剪裁结果图像,确定该剪裁顺序对应的至少一张子图像:In this embodiment of the present disclosure, at least one sub-image corresponding to the cropping sequence is determined based on the cropping result images corresponding to the at least one cropping position by the following method:
确定所述剪裁结果图像中是否包括第二目标对象;determining whether a second target object is included in the cropped result image;
响应于所述剪裁结果图像中包括所述第二目标对象,且所述第二目标对象的完整度满足预设的完整度条件,将所述剪裁结果图像确定为该剪裁顺序对应的子图像。In response to the cropping result image including the second target object and the integrity of the second target object satisfying a preset integrity condition, the cropping result image is determined as a sub-image corresponding to the cropping order.
其中,所述完整度是利用所述第二目标对象位于所述剪裁结果图像中的第一区域面积、以及所述第二目标对象位于所述待处理图像中的第二区域面积确定的。The completeness is determined by using the area of the first region of the second target object located in the cropped result image and the area of the second region of the second target object located in the image to be processed.
其中,所述第二目标对象可以为人脸、目标物品、环境标识等。Wherein, the second target object may be a human face, a target item, an environmental identifier, or the like.
在本公开实施例中,可以确定每个所述剪裁结果图像中第二目标对象的完整度信息,若所述子图像的完整度信息超过预设比例阈值,则确定该剪裁结果图像为该剪裁顺序对应的子图像。In this embodiment of the present disclosure, the completeness information of the second target object in each of the cropped result images may be determined, and if the completeness information of the sub-images exceeds a preset ratio threshold, the cropped result image is determined to be the cropped image Sequentially corresponding sub-images.
具体的,可以基于目标对象识别模块,确定任一所述目标对象在所述剪裁结果图像中的完整度信息,若存在任一所述剪裁结果图像的完整度信息超过预设阈值,则确定所述剪裁结果图像为该剪裁顺序对应的子图像。Specifically, the completeness information of any of the target objects in the cropped result image may be determined based on the target object recognition module, and if the completeness information of any of the cropped result images exceeds a preset threshold, then the completeness information of any of the cropped result images may be determined. The clipping result image is the sub-image corresponding to the clipping order.
示例性的,以第二目标对象为人脸为例,通过判断剪裁结果图像是否存在人脸,若规定裁剪后的子图像必须包含人脸,则去除裁剪后没有人脸的剪裁结果图像以及人脸覆盖率过低的剪裁结果图像,其中,人脸覆盖率为可选参数,默认裁剪后的子图像必须保证包含一定比例以上的人脸面积。在人脸识别部分,可以预先设置剪裁结果图像中所需包含的人脸比例(face_need),如为人脸比例设置为0,则无需调用人脸模块。如果face_need=0.8,则剪裁结果图像中至少涵盖每张脸的80%,但不保证所有的人脸都涵盖(至少一张脸)。也就是说,所截的人脸不一定是所有的人脸,但是一定保证每一张人脸的完整性。一般情况下,人脸比例在程序中默认为0.9。在face_need≠0的情况下,每张待处理图像仅支持输出一张子图像,因为在一般情况下程序认为最优裁剪方法是唯一确定,因此只输出一张子图像。Exemplarily, taking the second target object as a human face as an example, by judging whether there is a human face in the cropped result image, if it is stipulated that the cropped sub-image must contain a human face, then remove the cropped result image and the human face without a human face after the cropping. The cropped result image with too low coverage, in which the face coverage is an optional parameter, and the default cropped sub-image must ensure that it contains more than a certain proportion of the face area. In the face recognition part, the face ratio (face_need) that needs to be included in the cropped result image can be preset. If the face ratio is set to 0, there is no need to call the face module. If face_need=0.8, at least 80% of each face is covered in the cropped result image, but it is not guaranteed that all faces (at least one face) are covered. That is to say, the cut faces are not necessarily all faces, but the integrity of each face must be guaranteed. In general, the face ratio is 0.9 by default in the program. In the case of face_need≠0, each image to be processed only supports the output of one sub-image, because in general, the program considers that the optimal cropping method is uniquely determined, so only one sub-image is output.
承接于上述S103,在得到该剪裁顺序对应的至少一张子图像之后,所述图像处理方法还包括:Following the above step S103, after obtaining at least one sub-image corresponding to the cropping order, the image processing method further includes:
S104:从所述子图像中,筛选得到第一目标子图像。S104: From the sub-images, filter to obtain a first target sub-image.
其中,所述第一目标子图像中包括第二目标对象,且所包括的第二目标对象满足预设筛选条件。Wherein, the first target sub-image includes a second target object, and the included second target object satisfies a preset screening condition.
在本公开实施例中,通过以下步骤从所述子图像中,筛选得到第一目标子图像:In the embodiment of the present disclosure, the first target sub-image is obtained by screening the sub-images through the following steps:
针对每张子图像,响应于该张子图像包括第二目标对象,确定所述第二目标对象是否满足预设的筛选条件;For each sub-image, in response to the sub-image including the second target object, determining whether the second target object satisfies a preset screening condition;
响应于所述第二目标对象满足所述预设的筛选条件,将该张子图像确定为所述第一目标子图像。In response to the second target object satisfying the preset screening condition, the sub-image is determined as the first target sub-image.
其中,所述第二目标对象包括人脸;Wherein, the second target object includes a human face;
所述预设的筛选条件包括下述至少一种:The preset screening conditions include at least one of the following:
所述人脸占据的第一面积、与所述待处理图像的第二面积的比值,大于预设比值;The ratio of the first area occupied by the face to the second area of the image to be processed is greater than a preset ratio;
所述人脸的嘴部张开程度小于预设角度;The mouth opening degree of the face is less than the preset angle;
所述人脸的偏转角度位于预设偏转角度范围内;The deflection angle of the face is within a preset deflection angle range;
所述人脸的人眼宽高比位于预设的宽高比范围。The human-eye aspect ratio of the human face is within a preset aspect ratio range.
示例性的,对于一部分图像而言,其展示效果不佳,无法后续复用,因此需要加入一些特定的筛选条件,将通过筛选条件的图像作为保留图像,便于后续复用。具体的,筛选条件可以包括:Exemplarily, for some images, their display effect is not good and cannot be reused later, so some specific filtering conditions need to be added, and the images that pass the filtering conditions are used as reserved images for subsequent reuse. Specifically, the filter conditions can include:
(1)每张人脸面积必须大于整个待处理图像的1%(否则生成的图像五官不清晰);(1) The area of each face must be greater than 1% of the entire image to be processed (otherwise the facial features of the generated image will not be clear);
(2)嘴巴张开程度不能大于0.65(嘴巴张开过大生成图像处会生成断裂部分);(2) The degree of mouth opening should not be greater than 0.65 (a broken part will be generated where the mouth is too wide to generate an image);
(3)摇头程度(yaw)限定为-0.3≤x≤0.3(摇头程度对生成图像影响较大,取较为保守的值减少差图的产生);(3) The shaking degree (yaw) is limited to -0.3≤x≤0.3 (the shaking degree has a greater impact on the generated image, and a more conservative value is taken to reduce the generation of difference images);
(4)人眼宽高比保证x≤0.05或x≥0.2(为了去掉眯眼情况,否则生成的图像在人眼处会出现一条白色缝隙,观感较差)。(4) The aspect ratio of the human eye is guaranteed to be x≤0.05 or x≥0.2 (in order to remove the squinting situation, otherwise the generated image will have a white gap at the human eye, and the perception will be poor).
参见图4所示,为本公开实施例提供的另一种图像处理方法的流程图,所述方法包括步骤S401~S405,其中:Referring to FIG. 4, which is a flowchart of another image processing method provided by an embodiment of the present disclosure, the method includes steps S401-S405, wherein:
S401:确定待处理图像中的至少一个裁剪位置。S401: Determine at least one cropping position in the image to be processed.
S402:基于所述裁剪位置,确定针对所述剪裁位置的至少一种剪裁顺序。S402: Based on the cropping position, determine at least one cropping order for the cropping position.
S403:针对每种剪裁顺序,基于所述至少一个裁剪位置分别在所述待处理图像中的位置信息,对所述待处理图像进行剪裁,得到该所述剪裁顺序对应的至少一张子图像。S403: For each cropping order, based on the position information of the at least one cropping position in the to-be-processed image respectively, crop the to-be-processed image to obtain at least one sub-image corresponding to the cropped order.
S404:从所述子图像中,筛选得到第一目标子图像。S404: From the sub-images, filter to obtain a first target sub-image.
其中,步骤S401至步骤S404的描述可以参考步骤S101至步骤S104的描述,并且可以达到相同的技术效果,在此不再赘述。The descriptions of steps S401 to S404 may refer to the descriptions of steps S101 to S104, and the same technical effect can be achieved, which is not repeated here.
S405:对所述第一目标子图像进行预设风格迁移处理,得到第二目标子图像。S405: Perform preset style transfer processing on the first target sub-image to obtain a second target sub-image.
具体的,在一些第一目标子图像的纹理和质感不符合预期需求,但是第一目标子图像的图像内容又比较契合的情况下,还需要针对第一目标子图像进行不同纹理形式的生成过程。即基于预设的目标图像风格,对得到的第一目标子图像进行预设风格迁移处理,得到并输出处理后的具有预设风格的第二目标子图像。Specifically, in the case that the texture and texture of some first target sub-images do not meet the expected requirements, but the image content of the first target sub-image is relatively suitable, it is also necessary to perform the generation process of different texture forms for the first target sub-image. . That is, based on the preset target image style, a preset style transfer process is performed on the obtained first target sub-image, and a processed second target sub-image with a preset style is obtained and output.
示例性的,可以通过生成式对抗网络(Generative Adversarial Networks,GAN)对所述第一目标子图像进行预设风格迁移处理,生成多种不同风格迁移后的第二目标子图像。Exemplarily, a preset style transfer process may be performed on the first target sub-image through a generative adversarial network (Generative Adversarial Networks, GAN) to generate a plurality of second target sub-images with different styles after the transfer.
具体的,裁剪后的第一目标子图像填入GAN模型接口中,这样可以自动根据填入的第一目标子图像生成派生的第二目标子图像,派生图像一般包括三种类型:油画、复古、日漫原图类型,由于复古类型、油画类型的复用性较强,差图出现的概率较小,因此第一目标子图像将通过GAN模型产生上述两种类型的第二目标子图像。在加入一些图像判断规则后有部分图片不会产出日漫原图的派生。这样,便可以将第一目标子图像通过GAN模型批量生成第二目标子图像,将裁第一目标子图像和GAN派生的第二目标子图像同时返回,可以达到扩充素材库的目的Specifically, the cropped first target sub-image is filled in the GAN model interface, so that a derived second target sub-image can be automatically generated according to the filled first target sub-image. The derived image generally includes three types: oil painting, retro 、Riman original image type, due to the strong reusability of retro type and oil painting type, the probability of occurrence of difference images is small, so the first target sub-image will generate the above two types of second target sub-images through the GAN model. After adding some image judgment rules, some images will not be derived from the original Japanese image. In this way, the first target sub-image can be used to generate the second target sub-image in batches through the GAN model, and the cropped first target sub-image and the GAN-derived second target sub-image can be returned at the same time, which can achieve the purpose of expanding the material library.
本公开实施例可以有效地从一张待处理图像中获得多张可以复用的剪裁后的子图像,极大的扩充了素材库,丰富自动化生成的素材图像,增强了素材图像的多样性。通过本公开实施例所得到的子图像相比于之前寻找图源或者暴力抠图相比,一方面,由于其可以例行化执行,减少人力成本;另一方面,本实施例在预设的规则下尽可能的裁剪待处理图像中的最大区域,尽可能得保证裁剪后子图像的可用性。The embodiments of the present disclosure can effectively obtain multiple reusable cropped sub-images from an image to be processed, greatly expand the material library, enrich the automatically generated material images, and enhance the diversity of the material images. Compared with the previous image source search or violent matting, the sub-image obtained by the embodiment of the present disclosure can, on the one hand, reduce labor costs because it can be performed routinely; Crop the largest area in the image to be processed as much as possible under the rules, and ensure the availability of the cropped sub-image as much as possible.
本公开实施例通过确定待处理图像中的裁剪位置,并基于裁剪位置以及每个裁剪位置对应的位置对该待处理图像进行剪裁,得到至少一个子图像,并对得到的子图像进行筛选,得到目标子图像。这样,通过对于待处理图像进行裁剪以及筛选过程,可以根据实际的素材使用需求,从中筛选符合质量的目标子图像,提升筛选得到的目标子图像的质量。This embodiment of the present disclosure obtains at least one sub-image by determining the cropping position in the image to be processed, and cropping the to-be-processed image based on the cropping position and the position corresponding to each cropping position, and screening the obtained sub-images to obtain target subimage. In this way, through the process of cropping and screening the to-be-processed image, target sub-images that meet the quality can be screened according to actual material usage requirements, and the quality of the target sub-image obtained by screening can be improved.
本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的撰写顺序并不意味着严格的执行顺序而对实施过程构成任何限定,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。Those skilled in the art can understand that in the above method of the specific implementation, the writing order of each step does not mean a strict execution order but constitutes any limitation on the implementation process, and the specific execution order of each step should be based on its function and possible Internal logic is determined.
基于同一发明构思,本公开实施例中还提供了与图像处理方法对应的图像处理装置,由于本公开实施例中的装置解决问题的原理与本公开实施例上述图像处理方法相似,因此装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same inventive concept, the embodiment of the present disclosure also provides an image processing apparatus corresponding to the image processing method. Reference may be made to the implementation of the method, and repeated descriptions will not be repeated.
参照图5所示,为本公开实施例提供的一种图像处理装置的示意图,所述装置包括:第一确定模块510、第二确定模块520、剪裁模块530、筛选模块540;其中,Referring to FIG. 5 , which is a schematic diagram of an image processing apparatus according to an embodiment of the present disclosure, the apparatus includes: a
第一确定模块510,用于确定待处理图像中的至少一个裁剪位置;a first determining
第二确定模块520,用于基于所述裁剪位置,确定针对所述剪裁位置的至少一种剪裁顺序;a second determining
剪裁模块530,用于针对每种剪裁顺序,基于所述至少一个裁剪位置分别在所述待处理图像中的位置信息,对所述待处理图像进行剪裁,得到该所述剪裁顺序对应的至少一张子图像;The
筛选模块540,用于从所述子图像中,筛选得到第一目标子图像。The
一种可选的实施方式中,所述第一确定模块510具体用于:In an optional implementation manner, the first determining
对所述待处理图像进行第一目标检测处理,确定待剪裁的第一目标对象在所述待处理图像中的位置信息;Perform a first target detection process on the to-be-processed image, and determine the position information of the to-be-cropped first target object in the to-be-processed image;
基于所述位置信息,确定所述裁剪位置。Based on the position information, the cropping position is determined.
一种可选的实施方式中,所述第二确定模块520具体用于:In an optional implementation manner, the second determining
基于所述裁剪位置,为各个裁剪位置添加编号信息;Based on the clipping position, adding numbering information for each clipping position;
根据各个所述裁剪位置对应的编号信息,生成至少一组对所述裁剪位置进行剪裁的剪裁顺序;generating at least one set of trimming sequences for trimming the trimming positions according to the number information corresponding to each of the trimming positions;
基于所述剪裁顺序,确定所述剪裁顺序。Based on the clipping order, the clipping order is determined.
参照图6所示,为本公开实施例所提供的图像处理装置中,剪裁模块的具体示意图,一种可选的实施方式中,所述剪裁模块530包括:Referring to FIG. 6 , which is a specific schematic diagram of a cropping module in an image processing apparatus provided by an embodiment of the present disclosure, in an optional implementation manner, the
第一确定单元531,用于针对每种剪裁顺序,基于该剪裁顺序所指示的剪裁顺序,确定当前裁剪位置;The first determining
第二确定单元532,用于确定与所述当前裁剪位置对应的待剪裁图像;其中,所述待剪裁图像包括:所述待处理图像,或者与其他裁剪位置对应的剪裁结果图像;The second determining
第三确定单元533,用于基于所述至少一个裁剪位置分别对应的剪裁结果图像,确定该剪裁顺序对应的至少一张子图像。The third determining
一种可选的实施方式中,所述剪裁单元533具体用于:In an optional implementation manner, the
基于所述裁剪位置在所述待剪裁图像中的位置信息,确定对所述待剪裁图像进行剪裁时的剪裁位置;determining the cropping position when cropping the to-be-cropped image based on the position information of the cropping position in the to-be-cropped image;
响应于所述备选图像满足预设条件,将该张备图像确定为所述当前裁剪位置对应的剪裁结果图像。In response to the candidate image satisfying a preset condition, the candidate image is determined as the cropping result image corresponding to the current cropping position.
一种可选的实施方式中,所述第三确定单元534具体用于:In an optional implementation manner, the third determining unit 534 is specifically configured to:
确定所述剪裁结果图像中是否包括第二目标对象;determining whether a second target object is included in the cropped result image;
响应于所述剪裁结果图像中包括所述第二目标对象,且所述第二目标对象的完整度满足预设的完整度条件,将所述剪裁结果图像确定为该剪裁顺序对应的子图像。In response to the cropping result image including the second target object and the integrity of the second target object satisfying a preset integrity condition, the cropping result image is determined as a sub-image corresponding to the cropping order.
一种可选的实施方式中,所述筛选模块540具体用于:In an optional implementation manner, the
针对每张子图像,响应于该张子图像包括第二目标对象,确定所述第二目标对象是否满足预设的筛选条件;For each sub-image, in response to the sub-image including the second target object, determining whether the second target object satisfies a preset screening condition;
响应于所述第二目标对象满足所述预设的筛选条件,将该张子图像确定为所述第一目标子图像。In response to the second target object satisfying the preset screening condition, the sub-image is determined as the first target sub-image.
一种可选的实施方式中,所述第二目标对象包括人脸;In an optional implementation manner, the second target object includes a human face;
所述预设的筛选条件包括下述至少一种:The preset screening conditions include at least one of the following:
所述人脸占据的第一面积、与所述待处理图像的第二面积的比值,大于预设比值;The ratio of the first area occupied by the face to the second area of the image to be processed is greater than a preset ratio;
所述人脸的嘴部张开程度小于预设角度;The mouth opening degree of the face is less than the preset angle;
所述人脸的偏转角度位于预设偏转角度范围内;The deflection angle of the face is within a preset deflection angle range;
所述人脸的人眼宽高比位于预设的宽高比范围。The human-eye aspect ratio of the human face is within a preset aspect ratio range.
参照图7所示,为本公开实施例提供的另一种图像处理装置的示意图,一种可选的实施方式中,所述装置还包括:Referring to FIG. 7 , which is a schematic diagram of another image processing apparatus provided in an embodiment of the present disclosure, in an optional implementation manner, the apparatus further includes:
处理模块550,用于对所述第一目标子图像进行预设风格迁移处理,得到第二目标子图像。The
本公开实施例通过确定待处理图像中的裁剪位置,并基于裁剪位置以及每个裁剪位置对应的位置对该待处理图像进行剪裁,得到至少一个子图像,并对得到的子图像进行筛选,得到目标子图像。这样,通过对于待处理图像进行裁剪以及筛选过程,可以根据实际的素材使用需求,从中筛选符合质量的目标子图像,提升筛选得到的目标子图像的质量。This embodiment of the present disclosure obtains at least one sub-image by determining the cropping position in the image to be processed, and cropping the to-be-processed image based on the cropping position and the position corresponding to each cropping position, and screening the obtained sub-images to obtain target subimage. In this way, through the process of cropping and screening the to-be-processed image, target sub-images that meet the quality can be screened according to actual material usage requirements, and the quality of the target sub-image obtained by screening can be improved.
关于装置中的各模块的处理流程、以及各模块之间的交互流程的描述可以参照上述方法实施例中的相关说明,这里不再详述。For the description of the processing flow of each module in the apparatus and the interaction flow between the modules, reference may be made to the relevant descriptions in the foregoing method embodiments, which will not be described in detail here.
基于同一技术构思,本公开实施例还提供了一种计算机设备。参照图8所示,为本公开实施例提供的计算机设备的结构示意图,包括处理器801、存储器802、和总线803。其中,存储器802用于存储执行指令,包括内存8021和外部存储器8022;这里的内存8021也称内存储器,用于暂时存放处理器801中的运算数据,以及与硬盘等外部存储器8022交换的数据,处理器801通过内存8021与外部存储器8022进行数据交换,当计算机设备运行时,处理器801与存储器802之间通过总线803通信,使得处理器801在执行以下指令:Based on the same technical concept, an embodiment of the present disclosure also provides a computer device. Referring to FIG. 8 , a schematic structural diagram of a computer device provided by an embodiment of the present disclosure includes a
确定待处理图像中的至少一个裁剪位置;determining at least one cropping position in the image to be processed;
确定待处理图像中的至少一个裁剪位置;determining at least one cropping position in the image to be processed;
基于所述裁剪位置,确定针对所述剪裁位置的至少一种剪裁顺序;Based on the cropping positions, determining at least one cropping order for the cropping positions;
针对每种剪裁顺序,基于所述至少一个裁剪位置分别在所述待处理图像中的位置信息,对所述待处理图像进行剪裁,得到该所述剪裁顺序对应的至少一张子图像;For each cropping order, based on the position information of the at least one cropping position in the to-be-processed image, the to-be-processed image is cropped to obtain at least one sub-image corresponding to the cropped order;
从所述子图像中,筛选得到第一目标子图像。From the sub-images, a first target sub-image is obtained by screening.
本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述方法实施例中所述的图像处理方法的步骤。其中,该存储介质可以是易失性或非易失的计算机可读取存储介质。Embodiments of the present disclosure further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the steps of the image processing method described in the foregoing method embodiments are executed. Wherein, the storage medium may be a volatile or non-volatile computer-readable storage medium.
本公开实施例所提供的图像处理方法的计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令可用于执行上述方法实施例中所述的图像处理方法的步骤,具体可参见上述方法实施例,在此不再赘述。The computer program product of the image processing method provided by the embodiments of the present disclosure includes a computer-readable storage medium storing program codes, and the instructions included in the program codes can be used to execute the steps of the image processing methods described in the above method embodiments. , for details, refer to the foregoing method embodiments, which will not be repeated here.
本公开实施例还提供一种计算机程序,该计算机程序被处理器执行时实现前述实施例的任意一种方法。该计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software DevelopmentKit,SDK)等等。Embodiments of the present disclosure also provide a computer program, which implements any one of the methods in the foregoing embodiments when the computer program is executed by a processor. The computer program product can be specifically implemented by hardware, software or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), etc. .
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统和装置的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。在本公开所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。Those skilled in the art can clearly understand that, for the convenience and brevity of description, for the specific working process of the system and device described above, reference may be made to the corresponding process in the foregoing method embodiments, which will not be repeated here. In the several embodiments provided by the present disclosure, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. The apparatus embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces, indirect coupling or communication connection of devices or units, which may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个处理器可执行的非易失的计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-OnlyMemory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The functions, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a processor-executable non-volatile computer-readable storage medium. Based on this understanding, the technical solutions of the present disclosure can be embodied in the form of software products in essence, or the parts that make contributions to the prior art or the parts of the technical solutions. The computer software products are stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes.
最后应说明的是:以上所述实施例,仅为本公开的具体实施方式,用以说明本公开的技术方案,而非对其限制,本公开的保护范围并不局限于此,尽管参照前述实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本公开实施例技术方案的精神和范围,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应所述以权利要求的保护范围为准。Finally, it should be noted that the above-mentioned embodiments are only specific implementations of the present disclosure, and are used to illustrate the technical solutions of the present disclosure, but not to limit them. The protection scope of the present disclosure is not limited to this, although the aforementioned The embodiments describe the present disclosure in detail, and those skilled in the art should understand that: any person skilled in the art can still modify the technical solutions described in the foregoing embodiments within the technical scope disclosed by the present disclosure. Or can easily think of changes, or equivalently replace some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be covered in the present disclosure. within the scope of protection. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210853007.2ACN115222582A (en) | 2022-07-20 | 2022-07-20 | Image processing method and device, computer equipment and readable storage medium |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210853007.2ACN115222582A (en) | 2022-07-20 | 2022-07-20 | Image processing method and device, computer equipment and readable storage medium |
| Publication Number | Publication Date |
|---|---|
| CN115222582Atrue CN115222582A (en) | 2022-10-21 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202210853007.2APendingCN115222582A (en) | 2022-07-20 | 2022-07-20 | Image processing method and device, computer equipment and readable storage medium |
| Country | Link |
|---|---|
| CN (1) | CN115222582A (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104735364A (en)* | 2013-12-19 | 2015-06-24 | 中兴通讯股份有限公司 | Photo shooting method and device |
| CN110502961A (en)* | 2018-05-16 | 2019-11-26 | 腾讯科技(深圳)有限公司 | A kind of facial image detection method and device |
| CN112508773A (en)* | 2020-11-20 | 2021-03-16 | 小米科技(武汉)有限公司 | Image processing method and device, electronic device and storage medium |
| CN113570626A (en)* | 2021-09-27 | 2021-10-29 | 腾讯科技(深圳)有限公司 | Image cropping method and device, computer equipment and storage medium |
| CN114255344A (en)* | 2020-09-11 | 2022-03-29 | 同方威视技术股份有限公司 | Security inspection image segmentation method, device, electronic device and computer readable medium |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104735364A (en)* | 2013-12-19 | 2015-06-24 | 中兴通讯股份有限公司 | Photo shooting method and device |
| CN110502961A (en)* | 2018-05-16 | 2019-11-26 | 腾讯科技(深圳)有限公司 | A kind of facial image detection method and device |
| CN114255344A (en)* | 2020-09-11 | 2022-03-29 | 同方威视技术股份有限公司 | Security inspection image segmentation method, device, electronic device and computer readable medium |
| CN112508773A (en)* | 2020-11-20 | 2021-03-16 | 小米科技(武汉)有限公司 | Image processing method and device, electronic device and storage medium |
| CN113570626A (en)* | 2021-09-27 | 2021-10-29 | 腾讯科技(深圳)有限公司 | Image cropping method and device, computer equipment and storage medium |
| Publication | Publication Date | Title |
|---|---|---|
| JP6355746B2 (en) | Image editing techniques for devices | |
| CN110443140B (en) | Text positioning method, device, computer equipment and storage medium | |
| US8718401B2 (en) | Image processing device, method and program | |
| CN106445424A (en) | Information processing method and information processing apparatus | |
| CN112069341A (en) | Method, device, device and medium for generating background images and displaying search results | |
| CN106682560A (en) | Method, device and system for recognizing two-dimensional code | |
| CN111179287A (en) | Portrait instance segmentation method, device, equipment and storage medium | |
| CN114463367A (en) | An image processing method and device | |
| CN106156237A (en) | Information processing method, information processor and subscriber equipment | |
| CN113989531A (en) | An image processing method, apparatus, computer equipment and storage medium | |
| CN115222582A (en) | Image processing method and device, computer equipment and readable storage medium | |
| CN115689882A (en) | Image processing method and device and computer readable storage medium | |
| JP4967045B2 (en) | Background discriminating apparatus, method and program | |
| CN113256484A (en) | Method and device for stylizing image | |
| JP4334981B2 (en) | Image processing apparatus and image processing method | |
| CN111340914A (en) | Map generation method and device, storage medium and delivery vehicle | |
| JP7597646B2 (en) | Information processing device and image processing method | |
| CN116468736A (en) | Method, device, equipment and medium for segmenting foreground image based on spatial structure | |
| CN112257710B (en) | A method and device for detecting the tilt of a picture with text plane | |
| CN112785683B (en) | Face image adjusting method and device | |
| CN110751078B (en) | Method and equipment for determining non-skin color region of three-dimensional face | |
| US10380447B1 (en) | Providing regions of interest in an image | |
| CN115063578A (en) | Method and device for detecting and positioning target object in chip image and storage medium | |
| US9524553B2 (en) | Image processing apparatus, image processing method, and recording medium | |
| CN116584100A (en) | Image space detection suitable for overlay media content |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |