CN107123127A - A kind of image subject extracting method and device - Google Patents

A kind of image subject extracting method and device Download PDF

Info

Publication number
CN107123127A
CN107123127A CN201710287405.1A CN201710287405A CN107123127A CN 107123127 A CN107123127 A CN 107123127A CN 201710287405 A CN201710287405 A CN 201710287405A CN 107123127 A CN107123127 A CN 107123127A
Authority
CN
China
Prior art keywords
image
sliding window
detection
edge
pixel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201710287405.1A
Other languages
Chinese (zh)
Inventor
汪振华
陈宇
麻晓珍
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710287405.1A priority Critical patent/CN107123127A/en
Publication of CN107123127A publication Critical patent/CN107123127A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

本发明公开了一种图像主体提取方法及装置,涉及图像处理领域,其中方法包括:基于边缘检测算子对待处理图像进行边缘检测处理,得到边缘检测后的图像;生成检测滑窗,采用检测滑窗在边缘检测后的图像中进行滑窗检测;根据检测滑窗内的像素点数量以及图像主体识别规则在边缘检测后的图像中进行图像主体区域提取处理,将提取出的图像作为待处理图像的主体部分。本发明的图像主体提取方法及装置,能够大大提升了对图像主体检测、提取的处理效率,并且不需要准确设置前景和背景种子点,进行图像纯色检测,对于纯色图像的图像主体检测、提取的准确率高,使提取出的图像主体精确、可靠。

The invention discloses an image subject extraction method and device, which relate to the field of image processing. The method includes: performing edge detection processing on an image to be processed based on an edge detection operator to obtain an image after edge detection; generating a detection sliding window, using a detection sliding window Sliding window detection is carried out in the image after edge detection; according to the number of pixels in the detection sliding window and the image subject recognition rules, the image subject area extraction process is performed in the image after edge detection, and the extracted image is used as the image to be processed main part of . The image subject extraction method and device of the present invention can greatly improve the processing efficiency of image subject detection and extraction, and do not need to accurately set foreground and background seed points to perform image solid color detection. For the image subject detection and extraction of pure color images The accuracy rate is high, so that the extracted image subject is accurate and reliable.

Description

一种图像主体提取方法及装置Image subject extraction method and device

技术领域technical field

本发明涉及图像处理技术领域,尤其涉及一种图像主体提取方法及装置。The present invention relates to the technical field of image processing, in particular to an image subject extraction method and device.

背景技术Background technique

近年来网购平台取得了长足的发展,网购平台积累了大量的商品图像信息,如何更有效地实现对商品图像信息的组织、分析、检索和向消费者展示已经变得十分重要。商品图像的内容包括商品主体和背景,当用户上传一幅商品图像并期望搜索与该图相同或相似的商品时,用户更关注于商品本身,因此,提取商品图像中的商品主体成为非常重要的一项工作。目前,图像主体提取方法通常基于Graph cuts算法,Graph cuts算法的主要工作流程为:在图像四个角上设置背景种子点,执行Graph cuts算法得到主体mask,采用滑动窗口进行检测,获取图像主体的边距并得到主体外截矩形。但是,Graph cuts算法按像素分割,执行效率低,并且,固定设置背景种子点的做法使得主体占整个画幅较大且与背景种子点重叠时无法成功分割。In recent years, online shopping platforms have achieved considerable development. Online shopping platforms have accumulated a large amount of commodity image information. How to more effectively organize, analyze, retrieve and display commodity image information to consumers has become very important. The content of a product image includes the product body and background. When a user uploads a product image and expects to search for products that are the same or similar to the image, the user pays more attention to the product itself. Therefore, it is very important to extract the product body in the product image. a job. At present, image subject extraction methods are usually based on the Graph cuts algorithm. The main workflow of the Graph cuts algorithm is: set background seed points on the four corners of the image, execute the Graph cuts algorithm to obtain the subject mask, use sliding windows for detection, and obtain the image subject’s Margins and get the body's outer truncated rectangle. However, the Graph cuts algorithm is divided by pixels, and the execution efficiency is low. Moreover, the practice of setting the background seed point fixedly makes the subject occupy a large frame and cannot be successfully segmented when it overlaps with the background seed point.

发明内容Contents of the invention

有鉴于此,本发明要解决的一个技术问题是提供一种图像主体提取方法及装置。In view of this, a technical problem to be solved by the present invention is to provide an image subject extraction method and device.

根据本发明的一个方面,提供一种图像主体提取方法,包括:基于边缘检测算子对待处理图像进行边缘检测处理,得到边缘检测后的图像;生成检测滑窗,采用所述检测滑窗在所述边缘检测后的图像中进行滑窗检测;根据所述检测滑窗内的像素点数量以及图像主体识别规则在所述边缘检测后的图像中进行图像主体区域提取处理,将提取出的图像作为所述待处理图像的主体部分。According to one aspect of the present invention, an image subject extraction method is provided, including: performing edge detection processing on an image to be processed based on an edge detection operator to obtain an edge-detected image; generating a detection sliding window, and using the detection sliding window in the Sliding window detection is carried out in the image after the edge detection; according to the number of pixels in the detection sliding window and the image subject recognition rule, the image subject area extraction process is performed in the image after the edge detection, and the extracted image is used as The main part of the image to be processed.

可选地,获取所述待处理图像中包含的像素点的颜色值,根据所述像素点的颜色值以及图像纯色判断规则确定所述待处理图像是否为纯色图像;如果是,则基于所述边缘检测算子对所述待处理图像进行边缘检测处理;如果否,则结束对所述待处理图像的处理。Optionally, acquire the color value of the pixel contained in the image to be processed, and determine whether the image to be processed is a solid color image according to the color value of the pixel and the image solid color judgment rule; if so, based on the The edge detection operator performs edge detection processing on the image to be processed; if not, the processing on the image to be processed ends.

可选地,所述获取所述待处理图像中包含的像素点的颜色值、根据所述像素点的颜色值以及图像纯色判断规则确定所述待处理图像是否为纯色图像包括:在所述待处理图像的外围设置检测界限,确定所述检测界限内的图像检测区域;获取所述图像检测区域中包含的像素点的颜色值,统计具有相同颜色值的像素点在所述图像检测区域中包含的全部像素点中的占比;获取所述占比最高的颜色值以及占比值,判断所述占比值是否高于占比阈值;如果是,则确定所述待处理图像为纯色图像。Optionally, the acquiring the color value of the pixel contained in the image to be processed, and determining whether the image to be processed is a solid color image according to the color value of the pixel and an image solid color judgment rule includes: Processing the periphery of the image to set the detection limit, determining the image detection area within the detection limit; obtaining the color values of the pixels contained in the image detection area, and counting the pixels with the same color value included in the image detection area Proportion in all pixels of the pixel; obtain the color value and the proportion value with the highest proportion, and judge whether the proportion value is higher than the proportion threshold; if yes, then determine that the image to be processed is a solid color image.

可选地,所述生成检测滑窗、采用所述检测滑窗在所述边缘检测后的图像中进行滑窗检测包括:在所述边缘检测后的图像的边沿处分别设置水平滑窗和垂直滑窗;控制所述水平滑窗、所述垂直滑窗分别向所述边缘检测后的图像的中心滑动,用以确定所述图像主体区域的边界。Optionally, the generating a detection sliding window and using the detection sliding window to perform sliding window detection in the edge-detected image includes: respectively setting a horizontal sliding window and a vertical sliding window at the edge of the edge-detected image. Sliding window: controlling the horizontal sliding window and the vertical sliding window to slide towards the center of the image after edge detection respectively, so as to determine the boundary of the main body area of the image.

可选地,所述水平滑窗的高度像素数为所述边缘检测后的图像的宽度像素数,所述水平滑窗的宽度像素数为t1;所述垂直滑窗的宽度像素数为所述边缘检测后的图像的长度像素数,所述垂直滑窗的高度像素数为t2;其中,控制所述水平滑窗、所述垂直滑窗分别以步长t1和t1向所述边缘检测后的图像的中心滑动。Optionally, the height pixel number of the horizontal sliding window is the width pixel number of the image after the edge detection, and the width pixel number of the horizontal sliding window is t1; the width pixel number of the vertical sliding window is the The length pixel number of the image after the edge detection, the height pixel number of the vertical sliding window is t2; wherein, control the horizontal sliding window, the vertical sliding window to the edge detection after the step t1 and t1 respectively The center of the image slides.

可选地,在所述边缘检测后的图像的边沿处设置所述水平滑窗、所述垂直滑窗时,在所述水平滑窗、所述垂直滑窗中去除干扰区域,其中,所述干扰区域包括:商标区域。Optionally, when the horizontal sliding window and the vertical sliding window are set at the edge of the edge-detected image, interference regions are removed in the horizontal sliding window and the vertical sliding window, wherein the Interference areas include: trademark area.

可选地,所述根据所述检测滑窗内的像素点数量以及图像主体识别规则在所述边缘检测后的图像中进行图像主体区域提取处理包括:在所述水平滑窗、所述垂直滑窗向所述边缘检测后的图像的中心滑动的过程中,分别获取所述水平滑窗、所述垂直滑窗中所包含的像素数与在上一个滑动位置的所述水平滑窗、所述垂直滑窗中所包含的像素数的差值d1和d2;计算连续获取的两个d1的差值dk1,当确定dk1大于第一像素阈值时,则停止所述水平滑窗滑动并确定所述图像主体区域的垂直边界;计算连续获取的两个d2的差值dk2,当确定dk2大于第二像素阈值时,则停止所述垂直滑窗滑动并确定所述图像主体区域的水平边界。Optionally, the performing image subject area extraction processing in the image after edge detection according to the number of pixels in the detection sliding window and image subject recognition rules includes: In the process of sliding the window to the center of the image after edge detection, the number of pixels contained in the horizontal sliding window, the vertical sliding window and the horizontal sliding window at the previous sliding position, the The difference d1 and d2 of the number of pixels contained in the vertical sliding window; calculate the difference dk1 of two d1 obtained continuously, when it is determined that dk1 is greater than the first pixel threshold, then stop the sliding of the horizontal sliding window and determine the The vertical boundary of the main body area of the image; calculate the difference dk2 of two d2 acquired continuously, and when it is determined that dk2 is greater than the second pixel threshold, stop the vertical sliding window and determine the horizontal boundary of the main body area of the image.

可选地,在基于所述边缘检测算子对所述待处理图像进行边缘检测处理之前,采用平滑滤波器对对所述待处理图像进行滤波处理;其中,所述边缘检测算子包括:Canny算子。Optionally, before performing edge detection processing on the image to be processed based on the edge detection operator, a smoothing filter is used to perform filtering processing on the image to be processed; wherein the edge detection operator includes: Canny operator.

根据本发明的又一方面,提供一种图像主体提取装置,包括:边缘检测模块,用于基于边缘检测算子对待处理图像进行边缘检测处理,得到边缘检测后的图像;滑窗检测模块,用于生成检测滑窗,采用所述检测滑窗在所述边缘检测后的图像中进行滑窗检测;主体提取模块,用于根据所述检测滑窗内的像素点数量以及图像主体识别规则在所述边缘检测后的图像中进行图像主体区域提取处理,将提取出的图像作为所述待处理图像的主体部分。According to yet another aspect of the present invention, an image subject extraction device is provided, including: an edge detection module for performing edge detection processing on an image to be processed based on an edge detection operator to obtain an image after edge detection; a sliding window detection module for In generating the detection sliding window, the detection sliding window is used to perform sliding window detection in the image after the edge detection; the subject extraction module is used to identify the image subject according to the number of pixels in the detection sliding window and the image subject recognition rule. The main body area of the image is extracted from the image after the edge detection, and the extracted image is used as the main part of the image to be processed.

可选地,纯色确定模块,用于获取所述待处理图像中包含的像素点的颜色值,根据所述像素点的颜色值以及图像纯色判断规则确定所述待处理图像是否为纯色图像;如果所述纯色确定模块确定所述待处理图像为纯色图像,则所述边缘检测模块基于所述边缘检测算子对所述待处理图像进行边缘检测处理;如果所述纯色确定模块确定所述待处理图像不为纯色图像,则结束对所述待处理图像的处理。Optionally, the solid color determination module is configured to acquire the color value of the pixel contained in the image to be processed, and determine whether the image to be processed is a solid color image according to the color value of the pixel and an image solid color judgment rule; if The solid color determination module determines that the image to be processed is a solid color image, then the edge detection module performs edge detection processing on the image to be processed based on the edge detection operator; if the solid color determination module determines that the image to be processed is If the image is not a solid color image, the processing of the image to be processed ends.

可选地,所述纯色确定模块,还用于在所述待处理图像的外围设置检测界限,确定所述检测界限内的图像检测区域;获取所述图像检测区域中包含的像素点的颜色值,统计具有相同颜色值的像素点在所述图像检测区域中包含的全部像素点中的占比;获取所述占比最高的颜色值以及占比值,判断所述占比值是否高于占比阈值;如果是,则确定所述待处理图像为纯色图像。Optionally, the pure color determination module is further configured to set a detection limit on the periphery of the image to be processed, determine an image detection area within the detection limit; acquire color values of pixels contained in the image detection area , counting the ratio of pixels with the same color value in all pixels included in the image detection area; obtaining the color value and the ratio with the highest ratio, and judging whether the ratio is higher than the ratio threshold ; If yes, then determine that the image to be processed is a solid color image.

可选地,所述滑窗检测模块,还用于在所述边缘检测后的图像的边沿处分别设置水平滑窗和垂直滑窗,控制所述水平滑窗、所述垂直滑窗分别向所述边缘检测后的图像的中心滑动,用以确定所述图像主体区域的边界。Optionally, the sliding window detection module is further configured to respectively set a horizontal sliding window and a vertical sliding window at the edge of the edge detected image, and control the horizontal sliding window and the vertical sliding window to The center of the image after the edge detection is slid to determine the boundary of the main body area of the image.

可选地,所述水平滑窗的高度像素数为所述边缘检测后的图像的宽度像素数,所述水平滑窗的宽度像素数为t1;所述垂直滑窗的宽度像素数为所述边缘检测后的图像的长度像素数,所述垂直滑窗的高度像素数为t2;所述滑窗检测模块,还用于控制所述水平滑窗、所述垂直滑窗分别以步长t1和t1向所述边缘检测后的图像的中心滑动。Optionally, the height pixel number of the horizontal sliding window is the width pixel number of the image after the edge detection, and the width pixel number of the horizontal sliding window is t1; the width pixel number of the vertical sliding window is the The length pixel number of the image after edge detection, the height pixel number of the vertical sliding window is t2; the sliding window detection module is also used to control the horizontal sliding window and the vertical sliding window with step size t1 and t1 slides toward the center of the image after edge detection.

可选地,所述滑窗检测模块,还用于在所述边缘检测后的图像的边沿处设置所述水平滑窗、所述垂直滑窗时,在所述水平滑窗、所述垂直滑窗中去除干扰区域,其中,所述干扰区域包括:商标区域。Optionally, the sliding window detection module is further configured to set the horizontal sliding window and the vertical sliding window at the edge of the image after the edge detection, when the horizontal sliding window and the vertical sliding window The interference area is removed from the window, wherein the interference area includes: a trademark area.

可选地,所述主体提取模块,还用于在所述水平滑窗、所述垂直滑窗向所述边缘检测后的图像的中心滑动的过程中,分别获取所述水平滑窗、所述垂直滑窗中所包含的像素数与在上一个滑动位置的所述水平滑窗、所述垂直滑窗中所包含的像素数的差值d1和d2;计算连续获取的两个d1的差值dk1,当确定dk1大于第一像素阈值时,则停止所述水平滑窗滑动并确定所述图像主体区域的垂直边界;计算连续获取的两个d2的差值dk2,当确定dk2大于第二像素阈值时,则停止所述垂直滑窗滑动并确定所述图像主体区域的水平边界。Optionally, the subject extraction module is further configured to respectively acquire the horizontal sliding window, the vertical sliding window, and the Differences d1 and d2 between the number of pixels contained in the vertical sliding window and the number of pixels contained in the horizontal sliding window and the vertical sliding window at the previous sliding position; calculate the difference between two d1 obtained continuously dk1, when it is determined that dk1 is greater than the first pixel threshold, then stop the horizontal sliding window sliding and determine the vertical boundary of the image subject area; calculate the difference dk2 of two d2 acquired continuously, when it is determined that dk2 is greater than the second pixel When the threshold is reached, stop the vertical sliding window from sliding and determine the horizontal boundary of the main body area of the image.

可选地,所述边缘检测模块,用于在基于所述边缘检测算子对所述待处理图像进行边缘检测处理之前,采用平滑滤波器对对所述待处理图像进行滤波处理;其中,所述边缘检测算子包括:Canny算子。Optionally, the edge detection module is configured to use a smoothing filter to filter the image to be processed before performing edge detection processing on the image to be processed based on the edge detection operator; wherein, the The above-mentioned edge detection operators include: Canny operator.

根据本发明的又一方面,提供一种图像主体提取装置,包括:存储器;以及耦接至所述存储器的处理器,所述处理器被配置为基于存储在所述存储器中的指令,执行如上所述的图像主体提取方法。According to still another aspect of the present invention, there is provided an image subject extraction device, comprising: a memory; and a processor coupled to the memory, the processor is configured to perform the above-mentioned operations based on instructions stored in the memory The image subject extraction method described above.

根据本发明的再一方面,提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机指令,所述指令被处理器执行时实现如上所述任一项所述的图像主体提取方法。According to still another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium stores computer instructions, and when the instructions are executed by a processor, the image subject extraction described in any one of the above is realized. method.

本发明的图像主体提取方法及装置,基于边缘检测算子对图像进行边缘检测处理并通过滑窗检测的方式提取图像主体,大大提升了对图像主体检测、提取的处理效率,并且不需要准确设置前景和背景种子点的限制,对于纯色图像的图像主体检测、提取的准确率高,使提取出的图像主体精确、可靠。The image subject extraction method and device of the present invention perform edge detection processing on the image based on the edge detection operator and extract the image subject through sliding window detection, which greatly improves the processing efficiency of image subject detection and extraction, and does not require accurate settings. Foreground and background seed points are limited, and the accuracy of image subject detection and extraction for solid-color images is high, making the extracted image subject accurate and reliable.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description These are only some embodiments of the present invention, and those skilled in the art can also obtain other drawings based on these drawings without any creative effort.

图1为根据本发明的图像主体提取方法的一个实施例的流程示意图;Fig. 1 is a schematic flow chart of an embodiment of an image subject extraction method according to the present invention;

图2为根据本发明的图像主体提取方法的另一个实施例的流程示意图;FIG. 2 is a schematic flow diagram of another embodiment of the image subject extraction method according to the present invention;

图3为根据本发明的图像主体提取方法的一个实施例中的设置纯色检测区域的示意图;3 is a schematic diagram of setting a solid color detection area in an embodiment of the image subject extraction method according to the present invention;

图4A至4E为根据本发明的图像主体提取方法的一个实施例中的通过滑窗确定图像主体区域边界的示意图;4A to 4E are schematic diagrams of determining the boundary of the image subject area through a sliding window in an embodiment of the image subject extraction method according to the present invention;

图5为根据本发明的图像主体提取装置的一个实施例的模块示意图;Fig. 5 is a schematic module diagram of an embodiment of an image subject extraction device according to the present invention;

图6为根据本发明的图像主体提取装置的另一个实施例的模块示意图。Fig. 6 is a block diagram of another embodiment of an image subject extraction device according to the present invention.

具体实施方式detailed description

下面参照附图对本发明进行更全面的描述,其中说明本发明的示例性实施例。下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。下面结合各个图和实施例对本发明的技术方案进行多方面的描述。The present invention will be described more fully hereinafter with reference to the accompanying drawings, in which exemplary embodiments of the invention are illustrated. The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention. The technical solution of the present invention will be described in various aspects below in conjunction with various figures and embodiments.

下文中的“第一”、“第二”等仅用于描述上相区别,并没有其它特殊的含义。The "first", "second" and so on in the following are only used to describe the difference, and have no other special meanings.

图1为根据本发明的图像主体提取方法的一个实施例的流程示意图,如图1所示:Fig. 1 is a schematic flow chart of an embodiment of the image subject extraction method according to the present invention, as shown in Fig. 1:

步骤101,基于边缘检测算子对待处理图像进行边缘检测处理,得到边缘检测后的图像。Step 101: Perform edge detection processing on the image to be processed based on an edge detection operator to obtain an edge-detected image.

待处理图像可以为商品图像等,格式可以包括:bmp、jpeg、png等。边缘检测算子可以采用多种,例如拉普拉斯算子、Canny算子等。为了保证边缘检测处理的可靠性,在基于边缘检测算子对待处理图像进行边缘检测处理之前,采用平滑滤波器对对待处理图像进行滤波处理。The image to be processed can be a commodity image, etc., and the format can include: bmp, jpeg, png, etc. There are many kinds of edge detection operators, such as Laplacian operator, Canny operator and so on. In order to ensure the reliability of the edge detection process, the image to be processed is filtered by a smoothing filter before the edge detection process is performed on the image to be processed based on the edge detection operator.

可以采用多种平滑滤波器,例如采用高斯滤波器,基于高斯函数以及滤波器尺度σ生成高斯滤波模板,采用高斯滤波模板对待处理图像进行卷积运算,可以在抑制待处理图像表面图像噪声的同时,使待处理图像的边缘更加锐利。A variety of smoothing filters can be used, such as a Gaussian filter, which generates a Gaussian filter template based on the Gaussian function and the filter scale σ, and uses the Gaussian filter template to perform convolution operations on the image to be processed, which can suppress image noise on the surface of the image to be processed , to make the edges of the image to be processed sharper.

步骤102,生成检测滑窗,采用检测滑窗在边缘检测后的图像中进行滑窗检测。Step 102, generate a detection sliding window, and use the detection sliding window to perform sliding window detection in the edge-detected image.

步骤103,根据检测滑窗内的像素点数量以及图像主体识别规则在边缘检测后的图像中进行图像主体区域提取处理,将提取出的图像作为待处理图像的主体部分。Step 103 , according to the detection of the number of pixels in the sliding window and the image subject recognition rule, the image subject area extraction process is performed in the image after edge detection, and the extracted image is used as the main part of the image to be processed.

上述实施例提供的图像主体提取方法及装置,基于边缘检测算子对图像进行边缘检测处理并通过滑窗检测的方式提取图像主体,不需要准确设置前景和背景的种子点,提升了检测、提取的处理效率。The image subject extraction method and device provided in the above embodiments perform edge detection processing on the image based on the edge detection operator and extract the image subject through sliding window detection. It is not necessary to accurately set the seed points of the foreground and background, which improves the detection and extraction. processing efficiency.

图2为根据本发明的图像主体提取方法的另一个实施例的流程示意图,如图2所示:Fig. 2 is a schematic flow chart of another embodiment of the image subject extraction method according to the present invention, as shown in Fig. 2:

步骤201,对待处理图像进行纯色检测。Step 201, performing solid color detection on the image to be processed.

纯色检测可以采用多种方法。例如,获取待处理图像中包含的像素点的颜色值,根据像素点的颜色值以及图像纯色判断规则确定待处理图像是否为纯色图像。待处理图像(例如实际商品图像)的外沿经常出现商标、介绍、地址等,在检测中需要排除商标、介绍等的干扰,设置检测区域以此提高检测的准确性。Solid color detection can be done in a number of ways. For example, the color value of the pixel contained in the image to be processed is obtained, and whether the image to be processed is a solid color image is determined according to the color value of the pixel and the image solid color judgment rule. Trademarks, introductions, addresses, etc. often appear on the outer edge of the image to be processed (such as the actual product image). During the detection, it is necessary to eliminate the interference of trademarks, introductions, etc., and set the detection area to improve the accuracy of detection.

如图3所示,从图像的最外沿向内缩进指定的像素,形成图像检测区域32和空白区域31,将图像的最外沿边线向内缩进是为了避免位于图像周边的商标、介绍、地址等的干扰。图像的最外沿向内收缩的像素可以根据不同图像进行设置,例如为10像素等,表示图像的最外围边线往内缩进10像素。As shown in Figure 3, the specified pixels are indented from the outermost edge of the image to form an image detection area 32 and a blank area 31. The outermost edge of the image is indented inward to avoid trademarks, Interference with introductions, addresses, etc. The pixels that the outermost edge of the image shrinks inward can be set according to different images, for example, 10 pixels, etc., which means that the outermost edge of the image shrinks inward by 10 pixels.

在一个实施例中,在待处理图像的外围设置检测界限,确定检测界限内的图像检测区域。获取图像检测区域中包含的像素点的颜色值,统计具有相同颜色值的像素点在图像检测区域中包含的全部像素点中的占比,获取占比最高的颜色值以及占比值,判断占比值是否高于占比阈值,如果是,则确定待处理图像为纯色图像。In one embodiment, a detection limit is set on the periphery of the image to be processed, and an image detection area within the detection limit is determined. Obtain the color value of the pixels contained in the image detection area, count the proportion of pixels with the same color value among all the pixels contained in the image detection area, obtain the color value with the highest proportion and the proportion value, and judge the proportion value Whether it is higher than the proportion threshold, if yes, determine that the image to be processed is a solid color image.

例如,遍历图像检测区域32所包含的像素,构建256个颜色直方图(256个桶,颜色值的范围为[0-255]),统计图像检测区域32中具有相同颜色值的像素点,每个直方图代表具有一种颜色的像素点数量。在统计完成之后,按直方图的高度(每个直方图的高度代表具有直方图所对应颜色的像素点的总数)排序,获取最高的直方图。For example, traverse the pixels included in the image detection area 32, construct 256 color histograms (256 buckets, the range of color values is [0-255]), count the pixels with the same color value in the image detection area 32, each A histogram represents the number of pixels with a color. After the statistics are completed, sort by the height of the histogram (the height of each histogram represents the total number of pixels with the color corresponding to the histogram) to obtain the highest histogram.

例如,0号直方图最高(像素值0表示黑色),则表示图像检测区域32中具有黑色的像素点最多,根据全部直方图的高度计算出图像检测区域32中为黑色的像素点在图像检测区域32中的所有像素点中的所占的比例。占比阈值R可以预先设置,例如为80%等。For example, the No. 0 histogram is the highest (pixel value 0 represents black), which means that there are the most black pixels in the image detection area 32, and the pixel points that are black in the image detection area 32 are calculated according to the height of all histograms in the image detection area 32. The proportion of all pixels in the area 32. The proportion threshold R can be preset, for example, 80%.

如果图像检测区域32中为黑色的像素点在图像检测区域32中的所有像素点中的数量占比值超过80%,则表示待处理图像为纯色图像,即待处理图像具有背景纯色的特点。如果图像具有背景纯色的特点,则采用本发明的图像主体提取方法提取图像主体的准确度高。If the number of black pixels in the image detection area 32 exceeds 80% of all pixels in the image detection area 32, it means that the image to be processed is a solid color image, that is, the image to be processed has the characteristics of a solid background color. If the image has the characteristics of a solid background color, the accuracy of extracting the image subject by using the image subject extraction method of the present invention is high.

步骤202,确定待处理图像是否为纯色图像,如果是,则进入步骤204,如果否,则进入步骤203,退出操作,结束对待处理图像的处理。Step 202, determine whether the image to be processed is a solid color image, if yes, go to step 204, if not, go to step 203, exit the operation, and end the processing of the to-be-processed image.

步骤204,基于Canny算子对待处理图像进行边缘检测处理。Step 204, performing edge detection processing on the image to be processed based on the Canny operator.

Canny算子是一个具有滤波、增强、检测功能的多阶段的优化算子。在进行处理前,Canny算子利用高斯平滑滤波器来平滑图像以除去噪声。Canny分割算法采用一阶偏导的有限差分来计算梯度幅值和方向,对梯度幅值进行非极大值抑制,用双阈值算法检测和连接边缘,搜索待处理图像的边缘。采用Canny算子的边缘检测算法将不同颜色区域的边界用轮廓线条输出,边缘检测后的图像中可以显示待处理图像的边缘轮廓线条,采用Canny算子的边缘检测算法能将主体和背景(不同颜色区域)之间的分界用轮廓线条输出。Canny operator is a multi-stage optimization operator with filtering, enhancement and detection functions. Before processing, the Canny operator uses a Gaussian smoothing filter to smooth the image to remove noise. The Canny segmentation algorithm uses the finite difference of the first-order partial derivative to calculate the gradient magnitude and direction, suppresses the non-maximum value of the gradient magnitude, uses the double threshold algorithm to detect and connect the edges, and searches for the edges of the image to be processed. The edge detection algorithm of the Canny operator is used to output the boundaries of different color regions with contour lines, and the edge contour lines of the image to be processed can be displayed in the image after edge detection. The edge detection algorithm of the Canny operator can separate the subject and the background (different Color regions) are output as contour lines.

步骤205,在边缘检测后的图像的边沿处分别设置水平滑窗和垂直滑窗。Step 205, respectively setting a horizontal sliding window and a vertical sliding window at the edge of the image after edge detection.

在边缘检测后的图像的四边边沿分别取具有固定大小的四个滑窗。水平滑窗为在水平方向上滑动的滑窗,垂直滑窗为在垂直方向上滑动的滑窗。水平滑窗的高度取整图高度,宽度取固定大小(根据设定的阈值t1),水平滑窗的高度像素数为边缘检测后的图像的宽度像素数,水平滑窗的宽度像素数为t1。垂直滑窗的高度取整图宽度,高度取固定大小(根据设定的阈值t2)。垂直滑窗的宽度像素数为边缘检测后的图像的长度像素数,垂直滑窗的高度像素数为t2。Four sliding windows with fixed sizes are respectively taken at the four edges of the image after edge detection. The horizontal sliding window is a sliding window that slides in the horizontal direction, and the vertical sliding window is a sliding window that slides in the vertical direction. The height of the horizontal sliding window is rounded to the height of the image, and the width is fixed (according to the set threshold t1). The height pixels of the horizontal sliding window are the width pixels of the image after edge detection, and the width pixels of the horizontal sliding window are t1 . The height of the vertical sliding window is rounded to the whole image width, and the height is taken as a fixed size (according to the set threshold t2). The width pixels of the vertical sliding window are the length pixels of the image after edge detection, and the height pixels of the vertical sliding window are t2.

在一个实施例中,在边缘检测后的图像的边沿处设置水平滑窗、垂直滑窗时,需要在水平滑窗、垂直滑窗中去除干扰区域,干扰区域包In one embodiment, when a horizontal sliding window and a vertical sliding window are set at the edge of the image after edge detection, it is necessary to remove the interference area in the horizontal sliding window and the vertical sliding window, and the interference area includes

括:商标区域、介绍区域等。去除干扰区域的目的是为了减少由于此干扰区域的轮廓线条(边缘检测结果)造成图像主体检测的不准确。Including: trademark area, introduction area, etc. The purpose of removing the interference area is to reduce the inaccuracy of image subject detection caused by the contour line (edge detection result) of the interference area.

例如,电商的商品图像的左上角经常出现商标,高度约为商品图像四分之一高度,宽度约为商品图像三分之一宽度。为统一排除左上角商标位干扰,在上述设置的四个滑窗中,在位于左边的水平滑窗的顶上裁剪一定高度(裁剪的高度像素数可以设置),在位于上方的垂直滑窗的左边裁剪一定宽度(裁剪的宽度像素数可以设置)。For example, a trademark often appears in the upper left corner of an e-commerce product image, with a height of about a quarter of the height of the product image and a width of about one third of the width of the product image. In order to uniformly eliminate the interference of the trademark position in the upper left corner, among the four sliding windows set above, a certain height is cut on the top of the horizontal sliding window on the left (the number of pixels of the height of the clipping can be set), and the vertical sliding window at the top Crop a certain width on the left (the number of pixels of the cropped width can be set).

步骤206,控制水平滑窗、垂直滑窗分别向边缘检测后的图像的中心滑动,根据滑窗中所包含的像素数和像素阈值确定图像主体区域的边界。Step 206, controlling the horizontal sliding window and the vertical sliding window to slide towards the center of the edge-detected image respectively, and determining the boundary of the main body area of the image according to the number of pixels contained in the sliding window and the pixel threshold.

图像主体识别规则可以有多种规则。例如,控制水平滑窗、垂直滑窗分别以步长t1和t1向边缘检测后的图像的中心滑动。在水平滑窗、垂直滑窗向边缘检测后的图像的中心滑动的过程中,分别获取水平滑窗、垂直滑窗中所包含的像素数与在上一个滑动位置的水平滑窗、垂直滑窗中所包含的像素数的差值d1和d2。The image subject recognition rule may have various rules. For example, the horizontal sliding window and the vertical sliding window are controlled to slide toward the center of the edge-detected image with steps t1 and t1 respectively. In the process of sliding the horizontal sliding window and vertical sliding window to the center of the image after edge detection, obtain the number of pixels contained in the horizontal sliding window and vertical sliding window and the horizontal sliding window and vertical sliding window at the previous sliding position The difference between the number of pixels contained in d1 and d2.

计算连续获取的两个d1的差值dk1,当确定dk1大于第一像素阈值时,则停止水平滑窗滑动并确定图像主体区域的垂直边界。计算连续获取的两个d2的差值dk2,当确定dk2大于第二像素阈值时,则停止垂直滑窗滑动并确定图像主体区域的水平边界。Calculate the difference dk1 between two d1 acquired continuously, and when it is determined that dk1 is greater than the first pixel threshold, stop the horizontal sliding window and determine the vertical boundary of the image main body area. Calculate the difference dk2 between two d2 obtained continuously, and when it is determined that dk2 is greater than the second pixel threshold, stop the vertical sliding window and determine the horizontal boundary of the image main body area.

如图4A所示,位于左边的水平滑窗可以视为一个以图像高度为高,固定宽度为2像素的滑动矩形区域。以步长为2像素滑动,水平滑窗左上角水平坐标在第一时刻的位置为0,下一时刻水平坐标位置为2。水平滑窗每滑动一步,计算水平滑窗内像素数与上一步的水平滑窗内像素数的差d。As shown in FIG. 4A , the horizontal sliding window on the left can be regarded as a sliding rectangular area with the height of the image as the height and a fixed width of 2 pixels. Sliding with a step size of 2 pixels, the horizontal coordinate position of the upper left corner of the horizontal sliding window is 0 at the first moment, and the horizontal coordinate position is 2 at the next moment. Every time the horizontal sliding window slides one step, calculate the difference d between the number of pixels in the horizontal sliding window and the number of pixels in the horizontal sliding window in the previous step.

例如,由于在执行完边缘检测算法后,待检测图像转变为只有主体边沿轮廓线条显示的图像,其中的线条颜色为白色,则计算水平滑窗内白色像素数与上一步的水平滑窗内白色像素数的差d。For example, since after the edge detection algorithm is executed, the image to be detected turns into an image that only shows the outline lines of the subject, and the color of the lines is white, then calculate the number of white pixels in the horizontal sliding window and the white color in the horizontal sliding window in the previous step The difference in number of pixels d.

dk记为最近连续两次d的差,当判断dk>阈值a,则停止滑动,计算水平滑窗所滑动的距离,获得图像主体的外截矩形左侧边到图像边缘的距离。箭头所示为确定dk>阈值a的位置,即水平滑窗滑动4步,设步长为2像素,则图像主体的外截矩形左侧边到图像边缘的边距为8像素。dk is recorded as the difference between the last two consecutive d, when it is judged that dk>threshold a, stop sliding, calculate the sliding distance of the horizontal sliding window, and obtain the distance from the left side of the outer truncated rectangle of the image subject to the edge of the image. The arrow shows the position where dk>threshold a is determined, that is, the horizontal sliding window slides 4 steps, and the step size is 2 pixels, then the margin from the left side of the outer truncated rectangle of the image main body to the edge of the image is 8 pixels.

如图4B所示,箭头所示为确定dk>阈值a的位置,即垂直滑窗滑动3步,设步长为2像素,则图像主体的外截矩形上侧边到图像边缘的边距为6像素。如图4C所示,箭头所示为确定dk>阈值a的位置,即水平滑窗滑动3步,设步长为2像素,则图像主体的外截矩形右侧边到图像边缘的边距为6像素。如图4D所示,箭头所示为确定dk>阈值a的位置,即垂直滑窗滑动3步,设步长为2像素,则图像主体的外截矩形底边到图像边缘的边距为6像素。如图4E所示,获取由图像主体的四条外截矩形边围成的图像主体区域,将从图像主体区域提取出的图像作为待处理图像的主体部分。As shown in Figure 4B, the arrow shows the position where dk>threshold a is determined, that is, the vertical sliding window slides for 3 steps, and the step size is 2 pixels, then the distance from the upper side of the outer truncated rectangle of the image body to the edge of the image is 6 pixels. As shown in Figure 4C, the arrow shows the position where dk>threshold a is determined, that is, the horizontal sliding window slides for 3 steps, and the step size is 2 pixels, then the distance from the right side of the outer truncated rectangle of the image body to the edge of the image is 6 pixels. As shown in Figure 4D, the arrow shows the position where dk>threshold a is determined, that is, the vertical sliding window slides for 3 steps, and the step size is 2 pixels, then the distance from the bottom edge of the outer truncated rectangle of the image body to the edge of the image is 6 pixels. As shown in FIG. 4E , the main body area of the image surrounded by four truncated rectangular sides of the main body of the image is obtained, and the image extracted from the main body area of the image is used as the main part of the image to be processed.

根据实验表明,采用本发明的图像主体提取方法进行图像主体检测、提取的效率大大提升。例如,以400x400的商品图像为例,在Mac OSX、2.6GHz Intel Core i5、单线程的实验条件下,进行Graph cuts分割需要约1869毫秒,而在相同的实验条件下使用本发明的图像主体提取方法,对同一图像进行图像主体检测、提取仅仅需要约35毫秒。According to experiments, the efficiency of image subject detection and extraction by using the image subject extraction method of the present invention is greatly improved. For example, taking a 400x400 commodity image as an example, under the experimental conditions of Mac OSX, 2.6GHz Intel Core i5, and single thread, it takes about 1869 milliseconds to perform Graph cuts segmentation, but under the same experimental conditions, using the image subject extraction method of the present invention method, it only takes about 35 milliseconds to perform image subject detection and extraction on the same image.

上述实施例提供的图像主体提取方法及装置,大大提升了对图像主体检测、提取的处理效率,并且,不受现有的Graph Cuts算法依赖交互需要准确设置前景和背景种子点的限制,对于纯色图像的图像主体检测、提取的准确率高。The image subject extraction method and device provided by the above embodiments greatly improve the processing efficiency of image subject detection and extraction, and are not limited by the existing Graph Cuts algorithm that relies on interaction and needs to accurately set the foreground and background seed points. For pure color The image subject detection and extraction accuracy of the image is high.

在一个实施例中,如图5所示,本发明提供一种图像主体提取装置50,包括:边缘检测模块51、滑窗检测模块52、主体提取模块53和纯色确定模块54。In one embodiment, as shown in FIG. 5 , the present invention provides an image subject extraction device 50 , including: an edge detection module 51 , a sliding window detection module 52 , a subject extraction module 53 and a solid color determination module 54 .

边缘检测模块51基于边缘检测算子对待处理图像进行边缘检测处理,得到边缘检测后的图像。边缘检测模块51在基于边缘检测算子对待处理图像进行边缘检测处理之前,采用平滑滤波器对对待处理图像进行滤波处理;其中,边缘检测算子包括:Canny算子等。The edge detection module 51 performs edge detection processing on the image to be processed based on an edge detection operator to obtain an edge-detected image. The edge detection module 51 uses a smoothing filter to perform filtering processing on the image to be processed before performing edge detection processing on the image to be processed based on an edge detection operator; wherein, the edge detection operator includes: Canny operator and the like.

滑窗检测模块52生成检测滑窗,采用检测滑窗在边缘检测后的图像中进行滑窗检测。主体提取模块53根据检测滑窗内的像素点数量以及图像主体识别规则在边缘检测后的图像中进行图像主体区域提取处理,将提取出的图像作为待处理图像的主体部分。The sliding window detection module 52 generates a detection sliding window, and uses the detection sliding window to perform sliding window detection in the edge-detected image. The subject extraction module 53 performs image subject area extraction processing in the image after edge detection according to the number of pixels in the detection sliding window and image subject recognition rules, and takes the extracted image as the main part of the image to be processed.

纯色确定模块54获取待处理图像中包含的像素点的颜色值,根据像素点的颜色值以及图像纯色判断规则确定待处理图像是否为纯色图像。如果纯色确定模块54确定待处理图像为纯色图像,则边缘检测模块51基于边缘检测算子对待处理图像进行边缘检测处理。如果纯色确定模块54确定待处理图像不为纯色图像,则结束对待处理图像的处理。The solid color determination module 54 acquires the color values of the pixels contained in the image to be processed, and determines whether the image to be processed is a solid color image according to the color values of the pixels and the image solid color judgment rule. If the solid color determination module 54 determines that the image to be processed is a solid color image, the edge detection module 51 performs edge detection processing on the image to be processed based on an edge detection operator. If the solid-color determining module 54 determines that the image to be processed is not a solid-color image, the processing of the image to be processed ends.

纯色确定模块54在待处理图像的外围设置检测界限,确定检测界限内的图像检测区域。纯色确定模块54获取图像检测区域中包含的像素点的颜色值,统计具有相同颜色值的像素点在图像检测区域中包含的全部像素点中的占比。纯色确定模块54获取占比最高的颜色值以及占比值,判断占比值是否高于占比阈值,如果是,则确定待处理图像为纯色图像。The pure color determining module 54 sets a detection limit on the periphery of the image to be processed, and determines an image detection area within the detection limit. The pure color determination module 54 acquires the color values of the pixels included in the image detection area, and counts the proportion of pixels with the same color value in all the pixels included in the image detection area. The solid color determination module 54 acquires the color value with the highest proportion and the proportion value, and judges whether the proportion value is higher than the proportion threshold, and if so, determines that the image to be processed is a solid color image.

滑窗检测模块52在边缘检测后的图像的边沿处分别设置水平滑窗和垂直滑窗,控制水平滑窗、垂直滑窗分别向边缘检测后的图像的中心滑动,用以确定图像主体区域的边界。水平滑窗的高度像素数为边缘检测后的图像的宽度像素数,水平滑窗的宽度像素数为t1。垂直滑窗的宽度像素数为边缘检测后的图像的长度像素数,垂直滑窗的高度像素数为t2。Sliding window detection module 52 sets horizontal sliding window and vertical sliding window respectively at the edge of the image after edge detection, and controls horizontal sliding window and vertical sliding window to slide to the center of the image after edge detection respectively, in order to determine the area of the main body area of the image. boundary. The height pixel number of the horizontal sliding window is the width pixel number of the image after the edge detection, and the width pixel number of the horizontal sliding window is t1. The width pixels of the vertical sliding window are the length pixels of the image after edge detection, and the height pixels of the vertical sliding window are t2.

滑窗检测模块52在边缘检测后的图像的边沿处设置水平滑窗、垂直滑窗时,在水平滑窗、垂直滑窗中去除干扰区域,其中,干扰区域包括:商标区域。滑窗检测模块52控制水平滑窗、垂直滑窗分别以步长t1和t1向边缘检测后的图像的中心滑动。When the sliding window detection module 52 sets the horizontal sliding window and the vertical sliding window at the edge of the image after the edge detection, the interference area is removed from the horizontal sliding window and the vertical sliding window, wherein the interference area includes: a trademark area. The sliding window detection module 52 controls the horizontal sliding window and the vertical sliding window to slide towards the center of the edge-detected image with steps t1 and t1 respectively.

主体提取模块53在水平滑窗、垂直滑窗向边缘检测后的图像的中心滑动的过程中,分别获取水平滑窗、垂直滑窗中所包含的像素数与在上一个滑动位置的水平滑窗、垂直滑窗中所包含的像素数的差值d1和d2。主体提取模块53计算连续获取的两个d1的差值dk1,当确定dk1大于第一像素阈值时,则停止水平滑窗滑动并确定图像主体区域的垂直边界。主体提取模块53计算连续获取的两个d2的差值dk2,当确定dk2大于第二像素阈值时,则停止垂直滑窗滑动并确定图像主体区域的水平边界。Subject extraction module 53 obtains respectively the number of pixels contained in the horizontal sliding window and the vertical sliding window and the horizontal sliding window at the last sliding position during the sliding process of the horizontal sliding window and the vertical sliding window to the center of the image after edge detection. , the difference d1 and d2 of the number of pixels included in the vertical sliding window. The subject extraction module 53 calculates the difference dk1 between two d1 obtained continuously, and when it is determined that dk1 is greater than the first pixel threshold, the horizontal sliding window is stopped and the vertical boundary of the main body area of the image is determined. The subject extraction module 53 calculates the difference dk2 between two d2 acquired continuously, and when it is determined that dk2 is greater than the second pixel threshold, the vertical sliding window is stopped and the horizontal boundary of the subject area of the image is determined.

图6为根据本发明的图像主体提取装置的另一个实施例的模块示意图。如图6所示,该装置可包括存储器61、处理器62、通信接口63以及总线64。存储器61用于存储指令,处理器62耦合到存储器61,处理器62被配置为基于存储器61存储的指令执行实现上述的图像主体提取方法。Fig. 6 is a block diagram of another embodiment of an image subject extraction device according to the present invention. As shown in FIG. 6 , the device may include a memory 61 , a processor 62 , a communication interface 63 and a bus 64 . The memory 61 is used to store instructions, and the processor 62 is coupled to the memory 61 , and the processor 62 is configured to implement the above image subject extraction method based on the instructions stored in the memory 61 .

存储器61可以为高速RAM存储器、非易失性存储器(non-volatile memory)等,存储器61也可以是存储器阵列。存储器61还可能被分块,并且块可按一定的规则组合成虚拟卷。处理器62可以为中央处理器CPU,或专用集成电路ASIC(Application SpecificIntegrated Circuit),或者是被配置成实施本发明的图像主体提取方法的一个或多个集成电路。The memory 61 can be a high-speed RAM memory, a non-volatile memory (non-volatile memory), etc., and the memory 61 can also be a memory array. The memory 61 may also be partitioned, and the blocks may be combined into virtual volumes according to certain rules. The processor 62 may be a central processing unit CPU, or an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement the image subject extraction method of the present invention.

在一个实施例中,本发明提供一种计算机可读存储介质,计算机可读存储介质存储有计算机指令,指令被处理器执行时实现如上任一个实施例中的图像主体提取方法。In one embodiment, the present invention provides a computer-readable storage medium. The computer-readable storage medium stores computer instructions. When the instructions are executed by a processor, the image subject extraction method in any one of the above embodiments is implemented.

上述实施例提供的图像主体提取方法及装置,基于边缘检测算子对图像进行边缘检测处理并通过滑窗检测的方式提取图像主体,大大提升了对图像主体检测、提取的处理效率,并且,不受现有的Graph Cuts算法依赖交互需要准确设置前景和背景种子点的限制,进行图像纯色检测,对于纯色图像的图像主体检测、提取的准确率更高,使提取出的图像主体精确、可靠。The image subject extraction method and device provided in the above-mentioned embodiments perform edge detection processing on the image based on the edge detection operator and extract the image subject through sliding window detection, which greatly improves the processing efficiency of image subject detection and extraction, and does not Due to the limitation that the existing Graph Cuts algorithm relies on interaction and needs to accurately set the foreground and background seed points, the image solid color detection is performed, and the accuracy of the image subject detection and extraction of the pure color image is higher, so that the extracted image subject is accurate and reliable.

可能以许多方式来实现本发明的方法和系统。例如,可通过软件、硬件、固件或者软件、硬件、固件的任何组合来实现本发明的方法和系统。用于方法的步骤的上述顺序仅是为了进行说明,本发明的方法的步骤不限于以上具体描述的顺序,除非以其它方式特别说明。此外,在一些实施例中,还可将本发明实施为记录在记录介质中的程序,这些程序包括用于实现根据本发明的方法的机器可读指令。因而,本发明还覆盖存储用于执行根据本发明的方法的程序的记录介质。It is possible to implement the methods and systems of the present invention in many ways. For example, the method and system of the present invention may be implemented by software, hardware, firmware or any combination of software, hardware, and firmware. The above sequence of steps used in the method is for illustration only, and the steps of the method of the present invention are not limited to the sequence described above unless specifically stated otherwise. Furthermore, in some embodiments, the present invention can also be implemented as programs recorded in recording media including machine-readable instructions for realizing the method according to the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to the present invention.

本发明的描述是为了示例和描述起见而给出的,而并不是无遗漏的或者将本发明限于所公开的形式。很多修改和变化对于本领域的普通技术人员而言是显然的。选择和描述实施例是为了更好说明本发明的原理和实际应用,并且使本领域的普通技术人员能够理解本发明从而设计适于特定用途的带有各种修改的各种实施例。The description of the present invention has been presented for purposes of illustration and description, but is not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and changes will be apparent to those of ordinary skill in the art. The embodiment was chosen and described in order to better explain the principles of the invention and the practical application, and to enable others of ordinary skill in the art to understand the invention and design various embodiments with various modifications as are suited to the particular use.

Claims (18)

1. a kind of image subject extracting method, it is characterised in that including:
Edge detection process is carried out to pending image based on edge detection operator, the image after rim detection is obtained;
Generation detection sliding window, using progress sliding window detection in image of the detection sliding window after the rim detection;
According to image of the pixel quantity and image subject recognition rule in the detection sliding window after the rim detection It is middle progress image subject extracted region processing, using the image extracted as the pending image main part.
2. the method as described in claim 1, it is characterised in that also include:
The color value of the pixel included in the pending image is obtained, it is pure according to the color value and image of the pixel Color judgment rule determines whether the pending image is solid-color image;
If it is, carrying out edge detection process to the pending image based on the edge detection operator;If it is not, then knot Processing of the beam to the pending image.
3. method as claimed in claim 2, it is characterised in that the pixel included in the acquisition pending image Color value, the color value according to the pixel and image pure color judgment rule determine whether the pending image is pure color Image includes:
Detection boundary is set in the periphery of the pending image, the image detection region in the detection boundary is determined;
The color value of the pixel included in described image detection zone is obtained, pixel of the statistics with same color value is in institute State the accounting in the whole pixels included in image detection region;
The accounting highest color value and accounting value are obtained, judges whether the accounting value is higher than accounting threshold value;
If it is, determining that the pending image is solid-color image.
4. the method as described in claim 1, it is characterised in that the generation detects sliding window, using the detection sliding window in institute Stating progress sliding window detection in the image after rim detection includes:
The edge of image after the rim detection sets horizontal sliding window and vertical sliding window respectively;
The horizontal sliding window, the vertical sliding window are controlled respectively to the central slide of the image after the rim detection, to true Determine the border of described image body region.
5. method as claimed in claim 4, it is characterised in that also include:
The height pixel count of the horizontal sliding window be the rim detection after image width pixel count, the horizontal sliding window Width pixel count is t1;
The width pixel count of the vertical sliding window be the rim detection after image length pixel count, the vertical sliding window Height pixel count is t2;
Wherein, the horizontal sliding window, the vertical sliding window are controlled respectively with step-length t1 and t1 to the image after the rim detection Central slide.
6. method as claimed in claim 4, it is characterised in that also include:
When the edge of image after the rim detection sets the horizontal sliding window, the vertical sliding window, in the level Interference region is removed in sliding window, the vertical sliding window, wherein, the interference region includes:Trade mark region.
7. method as claimed in claim 5, it is characterised in that the pixel quantity according in the detection sliding window and The processing of image subject extracted region is carried out in image of the image subject recognition rule after the rim detection to be included:
The horizontal sliding window, central slide from the vertical sliding window to the image after the rim detection during, respectively The horizontal sliding window, the pixel count included in the vertical sliding window is obtained to slide with the level in a upper sliding position The difference d1 and d2 of pixel count included in window, the vertical sliding window;
Two d1 continuously acquired difference dk1 is calculated, when it is determined that dk1 is more than the first pixel threshold, then stops the level Sliding window is slided and determines the vertical boundary of described image body region;
Two d2 continuously acquired difference dk2 is calculated, when it is determined that dk2 is more than the second pixel threshold, is then stopped described vertical Sliding window is slided and determines the horizontal boundary of described image body region.
8. the method as described in claim 1, it is characterised in that also include:
Before edge detection process is carried out to the pending image based on the edge detection operator, using smoothing filter To being filtered processing to the pending image;
Wherein, the edge detection operator includes:Canny operators.
9. a kind of image subject extraction element, it is characterised in that including:
Edge detection module, for carrying out edge detection process to pending image based on edge detection operator, obtains edge inspection Image after survey;
Sliding window detection module, for generating detection sliding window, using entering in the image of the detection sliding window after the rim detection Row sliding window is detected;
Main body extraction module, for according to it is described detection sliding window in pixel quantity and image subject recognition rule described Image subject extracted region processing is carried out in image after rim detection, the image extracted is regard as the pending image Main part.
10. device as claimed in claim 9, it is characterised in that
Pure color determining module, the color value for obtaining the pixel included in the pending image, according to the pixel Color value and image pure color judgment rule determine whether the pending image is solid-color image;
If the pure color determining module determines that the pending image is solid-color image, the edge detection module is based on institute State edge detection operator and edge detection process is carried out to the pending image;If the pure color determining module is treated described in determining It is not solid-color image to handle image, then terminates the processing to the pending image.
11. device as claimed in claim 10, it is characterised in that
The pure color determining module, is additionally operable to set detection boundary in the periphery of the pending image, determines detection circle Image detection region in limit;The color value of the pixel included in described image detection zone is obtained, statistics has identical face Accounting in whole pixels that the pixel of colour is included in described image detection zone;Obtain the accounting highest face Colour and accounting value, judge whether the accounting value is higher than accounting threshold value;If it is, determining that the pending image is pure Color image.
12. device as claimed in claim 9, it is characterised in that
The horizontal sliding window of setting and hang down respectively the sliding window detection module, the edge of the image being additionally operable to after the rim detection Straight sliding window, controls the horizontal sliding window, the vertical sliding window respectively to the central slide of the image after the rim detection, is used to Determine the border of described image body region.
13. device as claimed in claim 12, it is characterised in that the height pixel count of the horizontal sliding window is examined for the edge The width pixel count of image after survey, the width pixel count of the horizontal sliding window is t1;The width pixel count of the vertical sliding window For the length pixel count of the image after the rim detection, the height pixel count of the vertical sliding window is t2;
The sliding window detection module, is additionally operable to the control horizontal sliding window, the vertical sliding window respectively with step-length t1 and t1 to institute State the central slide of the image after rim detection.
14. device as claimed in claim 12, it is characterised in that
The sliding window detection module, the edge for the image being additionally operable to after the rim detection sets the horizontal sliding window, institute When stating vertical sliding window, interference region is removed in the horizontal sliding window, the vertical sliding window, wherein, the interference region includes: Trade mark region.
15. device as claimed in claim 13, it is characterised in that
The main body extraction module, is additionally operable in the horizontal sliding window, the vertical sliding window to the image after the rim detection Central slide during, obtain respectively the horizontal sliding window, the pixel count included in the vertical sliding window with upper one The difference d1 and d2 of pixel count included in the horizontal sliding window of individual sliding position, the vertical sliding window;Calculating is continuously obtained Two d1 taken difference dk1, when it is determined that dk1 is more than the first pixel threshold, then stops the horizontal sliding window and slides and determine The vertical boundary of described image body region;Two d2 continuously acquired difference dk2 is calculated, when it is determined that dk2 is more than the second picture During plain threshold value, then stop the vertical sliding window and slide and determine the horizontal boundary of described image body region.
16. device as claimed in claim 9, it is characterised in that also include:
The edge detection module, for being carried out based on the edge detection operator to the pending image at rim detection Before reason, using smoothing filter to being filtered processing to the pending image;
Wherein, the edge detection operator includes:Canny operators.
17. a kind of image subject extraction element, it is characterised in that including:
Memory;And
The processor of the memory is coupled to, the processor is configured as based on the instruction being stored in the memory, Perform the image subject extracting method as any one of claim 1 to 8.
18. a kind of computer-readable recording medium, it is characterised in that the computer-readable recording medium storage has computer to refer to The image subject extracting method as any one of claim 1 to 8 is realized in order, the instruction when being executed by processor.
CN201710287405.1A 2017-04-27 2017-04-27 A kind of image subject extracting method and device Pending CN107123127A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710287405.1A CN107123127A (en) 2017-04-27 2017-04-27 A kind of image subject extracting method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710287405.1A CN107123127A (en) 2017-04-27 2017-04-27 A kind of image subject extracting method and device

Publications (1)

Publication Number Publication Date
CN107123127A true CN107123127A (en) 2017-09-01

Family

ID=59726475

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710287405.1A Pending CN107123127A (en) 2017-04-27 2017-04-27 A kind of image subject extracting method and device

Country Status (1)

Country Link
CN (1) CN107123127A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108322788A (en) * 2018-02-09 2018-07-24 武汉斗鱼网络科技有限公司 Advertisement demonstration method and device in a kind of net cast
CN110472578A (en) * 2019-08-15 2019-11-19 宁波中车时代传感技术有限公司 Lane line keeping method based on lane curvature
CN111539913A (en) * 2020-03-24 2020-08-14 上海交通大学 A method, system and terminal for evaluating the quality of photographing clarity of a mobile device
CN112153373A (en) * 2020-09-23 2020-12-29 平安国际智慧城市科技股份有限公司 Fault identification method and device for bright kitchen range equipment and storage medium
CN115841478A (en) * 2022-12-16 2023-03-24 浙江科达利实业有限公司 Quality detection system applied to vehicle-mounted air conditioner hose production management and control

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101799922A (en) * 2009-02-09 2010-08-11 北京新岸线网络技术有限公司 Method and device for detecting strokes of characters, method and device for locating lines of characters, and method and device for judging repeat of subtitles
CN105096330A (en) * 2015-08-20 2015-11-25 厦门美图之家科技有限公司 Image processing method capable of automatically recognizing pure-color borders, system and a photographing terminal
US20160267675A1 (en) * 2014-06-23 2016-09-15 Boe Technology Group Co., Ltd. Image edge detection method and apparatus thereof, image target identification method and apparatus thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101799922A (en) * 2009-02-09 2010-08-11 北京新岸线网络技术有限公司 Method and device for detecting strokes of characters, method and device for locating lines of characters, and method and device for judging repeat of subtitles
US20160267675A1 (en) * 2014-06-23 2016-09-15 Boe Technology Group Co., Ltd. Image edge detection method and apparatus thereof, image target identification method and apparatus thereof
CN105096330A (en) * 2015-08-20 2015-11-25 厦门美图之家科技有限公司 Image processing method capable of automatically recognizing pure-color borders, system and a photographing terminal

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
宁书年等编著: "《遥感图像处理与应用》", 30 June 1995, 地震出版社 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108322788A (en) * 2018-02-09 2018-07-24 武汉斗鱼网络科技有限公司 Advertisement demonstration method and device in a kind of net cast
CN108322788B (en) * 2018-02-09 2021-03-16 武汉斗鱼网络科技有限公司 Advertisement display method and device in live video
CN110472578A (en) * 2019-08-15 2019-11-19 宁波中车时代传感技术有限公司 Lane line keeping method based on lane curvature
CN111539913A (en) * 2020-03-24 2020-08-14 上海交通大学 A method, system and terminal for evaluating the quality of photographing clarity of a mobile device
CN111539913B (en) * 2020-03-24 2022-12-20 上海交通大学 Mobile device photographing definition quality evaluation method, system and terminal
CN112153373A (en) * 2020-09-23 2020-12-29 平安国际智慧城市科技股份有限公司 Fault identification method and device for bright kitchen range equipment and storage medium
CN115841478A (en) * 2022-12-16 2023-03-24 浙江科达利实业有限公司 Quality detection system applied to vehicle-mounted air conditioner hose production management and control

Similar Documents

Publication Publication Date Title
CN107123127A (en) A kind of image subject extracting method and device
WO2021109697A1 (en) Character segmentation method and apparatus, and computer-readable storage medium
EP2833288B1 (en) Face calibration method and system, and computer storage medium
CN107871319B (en) Method and device for detecting beam limiter area, X-ray system and storage medium
CN110992326A (en) A fast tilt correction method for QFN chip pin image
JP4528309B2 (en) Object detection method, object detection apparatus, and object detection program
AU2013206597A1 (en) Depth constrained superpixel-based depth map refinement
CN109544583B (en) Method, device and equipment for extracting interested area of leather image
KR102587710B1 (en) Methods, computer program products, and computer readable media for generating masks for camera streams
CN110415208A (en) An adaptive target detection method and its device, equipment, and storage medium
CN105894464A (en) Median filtering image processing method and apparatus
JP2016505185A (en) Image processor having edge selection function
CN109716355B (en) Particle boundary identification
WO2017128646A1 (en) Image processing method and device
Phoulady et al. An approach for overlapping cell segmentation in multi-layer cervical cell volumes
CN110084818B (en) Dynamic down-sampling image segmentation method
Senturk et al. A performance analysis for seam carving algorithm
JP2004362381A (en) Image processor and image processing method
CN111783807A (en) Picture extraction method and device and computer-readable storage medium
CN113128435B (en) Hand region segmentation method, device, medium and computer equipment in image
CN110942437B (en) Adaptive Top Hat Transform Method Based on Otsu-SSIM
KR101310078B1 (en) Apparatus and method for detecting edge of image
CN118840383A (en) Method and device for improving positioning accuracy of deflection tray based on image segmentation
CN119131075A (en) Infrared camera shielding detection method, device, equipment and storage medium
CN108734178A (en) A kind of HOG feature extracting methods of rule-basedization template

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 1237974

Country of ref document: HK

RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20170901

REG Reference to a national code

Ref country code: HK

Ref legal event code: WD

Ref document number: 1237974

Country of ref document: HK