CN104484892A - Image background color identification method - Google Patents
Image background color identification method Download PDFInfo
- Publication number
- CN104484892A CN104484892A CN201410753072.3A CN201410753072A CN104484892A CN 104484892 A CN104484892 A CN 104484892A CN 201410753072 A CN201410753072 A CN 201410753072A CN 104484892 A CN104484892 A CN 104484892A
- Authority
- CN
- China
- Prior art keywords
- image
- foreground
- background color
- background
- original image
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/90—Determination of colour characteristics
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Analysis (AREA)
- Image Processing (AREA)
Abstract
本发明实施例公开一种图像背景颜色识别方法,应用于计算机领域,能够避免现有的靠人工识别商品的图像背景颜色识别效率极低且缺乏智能化的问题。该方法包括:通过高通滤波器提取原始图像的前景;去掉所述前景获得所述原始图像的背景;根据所述前景和所述背景识别背景颜色。本发明的实施例应用于图像背景颜色识别。
The embodiment of the present invention discloses an image background color recognition method, which is applied in the computer field, and can avoid the problems of extremely low efficiency and lack of intelligence in the existing image background color recognition of goods that rely on manual recognition. The method includes: extracting the foreground of the original image through a high-pass filter; removing the foreground to obtain the background of the original image; identifying the background color according to the foreground and the background. Embodiments of the present invention are applied to image background color recognition.
Description
技术领域technical field
本发明涉及计算机领域,尤其涉及一种图像背景颜色识别方法。The invention relates to the field of computers, in particular to an image background color recognition method.
背景技术Background technique
随着人类进入信息时代,计算机越来越广泛应用于各种领域。基于数字图像处理的模式识别的研究越来越受到关注,但目前在商品的背景颜色识别方面的应用研究还存在大量空白。背景颜色识别的作用和意义:提取给定图像的背景成分并对其颜色的识别,最终输出视觉颜色的名称,如“红色”。目前主要还是靠人工识别商品的背景颜色,效率极低,且缺乏智能化。As humans enter the information age, computers are increasingly used in various fields. The research on pattern recognition based on digital image processing has attracted more and more attention, but there are still a lot of gaps in the application research on the background color recognition of commodities. The role and significance of background color recognition: extract the background component of a given image and recognize its color, and finally output the name of the visual color, such as "red". At present, it mainly relies on manual identification of the background color of the product, which is extremely inefficient and lacks intelligence.
发明内容Contents of the invention
本发明实施例提供一种图像背景颜色识别方法,以解决现有的靠人工识别商品的图像背景颜色识别效率极低且缺乏智能化的问题。An embodiment of the present invention provides an image background color recognition method to solve the problem of low efficiency and lack of intelligence in the existing image background color recognition of commodities by manual recognition.
本发明的第一方面提供一种图像背景颜色识别方法,包括:A first aspect of the present invention provides an image background color recognition method, comprising:
通过高通滤波器提取原始图像的前景;Extract the foreground of the original image through a high-pass filter;
去掉所述前景获得所述原始图像的背景;remove the foreground to obtain the background of the original image;
根据所述前景和所述背景识别背景颜色。A background color is identified from the foreground and the background.
根据第一方面,在第一种可能的实现方式中,所述根据所述前景和所述背景识别背景颜色,包括:According to the first aspect, in a first possible implementation manner, the identifying the background color according to the foreground and the background includes:
分别提取所述前景和所述背景的平均RGB分量,根据预设的RGB分量比例关系和预设的阀值识别背景颜色。The average RGB components of the foreground and the background are respectively extracted, and the background color is identified according to a preset ratio relationship of the RGB components and a preset threshold.
根据第一方面,在第二种可能的实现方式中,所述通过高通滤波器提取原始图像的前景,包括:According to the first aspect, in a second possible implementation manner, the extracting the foreground of the original image through a high-pass filter includes:
将所述原始图像进行RGB通道分离,获得黑白图像;The original image is subjected to RGB channel separation to obtain a black and white image;
通过高通滤波增强所述黑白图像的边缘,获得高频图像;Enhancing the edge of the black-and-white image by high-pass filtering to obtain a high-frequency image;
扩充所述高频图像,获得原始图像的前景。The high-frequency image is augmented to obtain the foreground of the original image.
本发明实施例提供的图像背景颜色识别方法,通过运用图像处理算法使计算机代替人工对标志进行定位,极大的提高了效率。The image background color recognition method provided by the embodiment of the present invention greatly improves efficiency by using an image processing algorithm to enable a computer to replace manual positioning of signs.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings that are required in the description of the embodiments or the prior art.
图1为本发明实施例提供的图像背景颜色识别方法的流程示意图;FIG. 1 is a schematic flow chart of an image background color recognition method provided by an embodiment of the present invention;
图2为本发明实施例提供的图像背景颜色识别方法中的膨胀的示意图;Fig. 2 is a schematic diagram of expansion in the image background color recognition method provided by the embodiment of the present invention;
图3为本发明实施例提供的图像背景颜色识别方法中的填充的示意图。Fig. 3 is a schematic diagram of filling in the image background color recognition method provided by the embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。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.
图1为本发明实施例提供的图像背景颜色识别方法的流程示意图。该方法主要用于识别商品标志的背景颜色,例如服装的标志,本实施例为方便说明仅以服装的标志进行说明。参考图1所示,该方法包括以下步骤:FIG. 1 is a schematic flowchart of an image background color recognition method provided by an embodiment of the present invention. This method is mainly used to identify the background color of a product logo, such as a clothing logo, and this embodiment only uses the clothing logo for illustration. Shown in Fig. 1 with reference to, this method comprises the following steps:
10、通过高通滤波器提取原始图像的前景。10. Extract the foreground of the original image through a high-pass filter.
其中,原始图像是指待识别的商品标志。前景是指原始图像中标志区域。Wherein, the original image refers to the commodity logo to be recognized. The foreground refers to the landmark area in the original image.
高通滤波器能够滤除输入中的低频信息,它接受的输入须是频率信号,因此需要通过二维离散傅里叶变换(DFT)将图像从空间域转换到频率域。The high-pass filter can filter out low-frequency information in the input, and the input it accepts must be a frequency signal, so it is necessary to convert the image from the spatial domain to the frequency domain through a two-dimensional discrete Fourier transform (DFT).
图像的频率是表征图像中灰度变换剧烈程度的指标,DFT的物理意义是将图像的灰度分布函数变为频率分布函数,DFT的逆变换是将图像的频率分布函数变为灰度分布函数。The frequency of an image is an index that characterizes the intensity of the grayscale transformation in the image. The physical meaning of DFT is to change the grayscale distribution function of the image into a frequency distribution function. The inverse transformation of DFT is to change the frequency distribution function of the image into a grayscale distribution function. .
将原始图像进行二维离散傅里叶变换之后,还可以对变换后的图像进行频域中心的平移操作,使中心的区域成为平移操作后的新图像的低频分量,使得后续处理频域图像更加方便直观。After the two-dimensional discrete Fourier transform is performed on the original image, the frequency domain center translation operation can also be performed on the transformed image, so that the center area becomes the low frequency component of the new image after the translation operation, making the subsequent processing of the frequency domain image easier. Convenient and intuitive.
通过高通滤波可以抑制图像中心的低频成分,提取高频成分,从而获得图像的边缘。The low-frequency components in the center of the image can be suppressed by high-pass filtering, and the high-frequency components can be extracted to obtain the edge of the image.
具体地,先进行离散傅里叶变换(DFT),在进行高通滤波操作。DFT的作用是将图像从空间域转换到频率域,本质是将图像的灰度分布函数变为频率分布函数,得到的频率信息用高通滤波器进行处理,高通滤波器的作用就是滤除(抑制)低频成分,而是高频成分通过。Specifically, a discrete Fourier transform (DFT) is performed first, and then a high-pass filtering operation is performed. The function of DFT is to transform the image from the spatial domain to the frequency domain. The essence is to change the gray distribution function of the image into a frequency distribution function. The obtained frequency information is processed with a high-pass filter. The function of the high-pass filter is to filter out (suppress ) low-frequency components, but high-frequency components pass.
本方案可优选Cooley-Turkey快速傅里叶变换算法。其优点是:In this scheme, the Cooley-Turkey fast Fourier transform algorithm can be optimized. Its advantages are:
能使计算机计算离散傅里叶变换所需要的乘法次数大为减少,特别是被变换的抽样点数N越多,快速傅里叶变换算法计算量的节省就越显著。在数字图像处理中,这种算法能够提高效率。The number of multiplications required by the computer to calculate the discrete Fourier transform can be greatly reduced, especially the more the number of sampling points N to be transformed, the more significant the saving of the calculation amount of the fast Fourier transform algorithm is. In digital image processing, this algorithm can improve efficiency.
20、去掉前景获得原始图像的背景。20. Remove the foreground to obtain the background of the original image.
背景是原始图像中标志周围的区域。The background is the area around the logo in the original image.
用图像增强方法得到了原始图像中用户感兴趣的前景部分,而去掉了这些前景部分后,就剩下图像的背景。The foreground part of the user's interest in the original image is obtained by image enhancement method, and after removing these foreground parts, only the background of the image remains.
图像增强是指增强图像中的有用信息,有目的地强调图像的整体或局部特性,强调某些感兴趣的特征,扩大图像中不同物体特征之间的差别,抑制不感兴趣的特征。Image enhancement refers to enhancing the useful information in the image, emphasizing the overall or local characteristics of the image purposefully, emphasizing some interesting features, expanding the difference between different object features in the image, and suppressing uninteresting features.
上面运到的高通滤波器方法就是频率域中的图像增强方法,可以得到图像中的高频信息。The high-pass filter method carried above is an image enhancement method in the frequency domain, which can obtain high-frequency information in the image.
在得到了图像前景区域之后,由于这个区域的像素灰度值较大,视觉上表现为更亮,因此可以计算整幅图像的像素灰度值均值,然后将灰度值大于均值的像素点设置为NaN(not a number)类型,使得整个前景部分都变成了NaN类型,从而实现前景的去除。因为在之后的处理中,NaN类型的区域都不会被纳入在处理范围内,可以看做是已被去除。After obtaining the foreground area of the image, since the gray value of the pixels in this area is larger, it is visually brighter, so the average value of the pixel gray value of the entire image can be calculated, and then the pixels whose gray value is greater than the average value can be set. It is a NaN (not a number) type, so that the entire foreground part becomes a NaN type, thereby realizing the removal of the foreground. Because in the subsequent processing, the area of NaN type will not be included in the processing range, which can be regarded as being removed.
30、根据前景和背景识别背景颜色。30. Identify the background color from the foreground and background.
进一步地,步骤30中,所述根据所述前景和所述背景识别背景颜色,可以包括:Further, in step 30, the identifying the background color according to the foreground and the background may include:
分别提取前景和背景的平均RGB分量,根据预设的RGB分量比例关系和预设的阀值识别背景颜色。The average RGB components of the foreground and background are extracted respectively, and the background color is identified according to the preset ratio relationship of the RGB components and the preset threshold.
计算指定区域所有像素的RGB平均值。Calculates the RGB average of all pixels in the specified area.
在RGB颜色空间中,视觉颜色和RGB各分量的值有着必然联系,本实施例使用的阈值举例如下:In the RGB color space, there is an inevitable relationship between the visual color and the values of the RGB components. The threshold used in this embodiment is exemplified as follows:
红色(r-g)>35&(r-b)>120;Red(r-g)>35&(r-b)>120;
绿色(g-b)>33&(g-r)>60;Green(g-b)>33&(g-r)>60;
蓝色(b-g)>33&(b-r)>60;Blue(b-g)>33&(b-r)>60;
注:RGB的取值范围为0~255。Note: The value range of RGB is 0~255.
进一步地,步骤10中,通过高通滤波器提取原始图像的前景,可以优选包括以下步骤:Further, in step 10, extracting the foreground of the original image through a high-pass filter may preferably include the following steps:
101、将原始图像进行RGB通道分离,获得黑白图像;101. Separating the original image into RGB channels to obtain a black and white image;
RGB通道分离可以将彩色图像变成黑白图像。RGB channel separation can turn a color image into a black and white image.
102、通过高通滤波增强所述黑白图像的边缘,获得高频图像;102. Enhance the edge of the black and white image by high-pass filtering to obtain a high-frequency image;
背景和前景之间由于不平滑的过渡会在视觉上形成轮廓,在频域上,图像的边缘因为灰度值的巨变表现为高频,通过高通滤波可以提取并强化这些边缘。The unsmooth transition between the background and the foreground will form a visual outline. In the frequency domain, the edges of the image appear as high frequencies due to the drastic changes in the gray value. These edges can be extracted and strengthened by high-pass filtering.
103、扩充所述高频图像,获得原始图像的前景。103. Expand the high-frequency image to obtain a foreground of the original image.
在上一步的高通滤波中得到了图像的高频信息,即前景的边缘,对该前景边缘进行扩展(膨胀),并对其中的闭合区域进行填充,可使前景图像形成一个整体,从而得到原始图像的前景。扩展的方法用的是形态学膨胀和填充。In the high-pass filtering of the previous step, the high-frequency information of the image is obtained, that is, the edge of the foreground. The foreground edge is expanded (expanded) and the closed area is filled to make the foreground image form a whole, thus obtaining the original The foreground of the image. The expansion method uses morphological dilation and filling.
膨胀和填充操作在图像处理中属于基本的操作,通常不需要再做详细说明。为了表述完整,此处列出其原理,供代理人参考。Dilation and filling operations are basic operations in image processing, and usually do not need to be described in detail. For the sake of completeness, the principles are listed here for the reference of the agent.
膨胀用于填补标志边缘的断点,桥接边缘的裂缝,使标志边缘连续和闭合。Swelling is used to fill breaks in the edge of the sign, bridge cracks in the edge, and make the edge of the sign continuous and closed.
其中,为结构元素,A被B膨胀后的元素是所有位移z的集合。in, As a structural element, the element after A is expanded by B is the set of all displacements z.
参考图2,图2为本发明实施例提供的图像背景颜色识别方法中的膨胀的示意图。Referring to FIG. 2 , FIG. 2 is a schematic diagram of dilation in an image background color recognition method provided by an embodiment of the present invention.
填充是一个要达成的目标,使用的方法是基于形态重构的算法,所谓重构就是对原始图像进行一定处理,使之生成新的图像,是一种涉及两幅图像和一个结构元素的形态变换,其中一个图像作为标记,称为变换的起点,另一幅图像是掩膜(掩膜图像即需要重构的原始图像),用来约束变化过程。结构元素用来定义连接性。参考图3,图3为本发明实施例提供的图像背景颜色识别方法中的填充的示意图。Filling is a goal to be achieved. The method used is an algorithm based on morphological reconstruction. The so-called reconstruction is to process the original image to make it generate a new image. It is a form involving two images and a structural element. Transformation, one of the images is used as a marker, which is called the starting point of the transformation, and the other image is a mask (the mask image is the original image that needs to be reconstructed), which is used to constrain the change process. Structural elements are used to define connectivity. Referring to FIG. 3 , FIG. 3 is a schematic diagram of filling in an image background color recognition method provided by an embodiment of the present invention.
本实施例,在静态图像的背景提取上使用的是高通滤波方法,而不是常规的图像二值化结合图像加减运算的方法,使用高通滤波得到边缘信息,加以形态学操作实现前景和背景的分割,避免了简单图像二值化阈值不当导致的分割不正确,特别是在背景和前景颜色接近时,图像中的细小噪声就足以导致二值化分割不正确,而高通滤波的方法是基于边缘的,对噪声并不敏感,适应性更强。另外,在颜色识别方面,本实施例,根据RGB分量的规则化关系,直接映射为视觉颜色的名称,计算简便高效,避免了使用分类器识别颜色而带来的巨大开销,使用分类器识别颜色需要对分类器进行训练,在后续识别过程中同样需要较大的开销。In this embodiment, the high-pass filtering method is used to extract the background of the static image, instead of the conventional method of image binarization combined with image addition and subtraction, the edge information is obtained by high-pass filtering, and the foreground and background are realized by morphological operations. Segmentation avoids incorrect segmentation caused by improper threshold of simple image binarization, especially when the background and foreground colors are close, the small noise in the image is enough to cause incorrect binarization segmentation, and the high-pass filtering method is based on the edge It is not sensitive to noise and more adaptable. In addition, in terms of color recognition, this embodiment, according to the regularization relationship of the RGB components, is directly mapped to the name of the visual color, which is simple and efficient in calculation, and avoids the huge overhead caused by using the classifier to identify the color. Using the classifier to identify the color The classifier needs to be trained, and a large overhead is also required in the subsequent recognition process.
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应所述以权利要求的保护范围为准。The above is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Anyone skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present invention. Should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims (3)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410753072.3A CN104484892A (en) | 2014-12-09 | 2014-12-09 | Image background color identification method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410753072.3A CN104484892A (en) | 2014-12-09 | 2014-12-09 | Image background color identification method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104484892A true CN104484892A (en) | 2015-04-01 |
Family
ID=52759432
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410753072.3A Pending CN104484892A (en) | 2014-12-09 | 2014-12-09 | Image background color identification method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104484892A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114612497A (en) * | 2022-02-21 | 2022-06-10 | 北京百度网讯科技有限公司 | Method, device, equipment, medium and product for identifying image background color |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050286795A1 (en) * | 2004-06-23 | 2005-12-29 | Samsung Electronics Co., Ltd. | Deblocking method and apparatus using edge flow-directed filter and curvelet transform |
CN101551853A (en) * | 2008-11-14 | 2009-10-07 | 重庆大学 | Human ear detection method under complex static color background |
-
2014
- 2014-12-09 CN CN201410753072.3A patent/CN104484892A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050286795A1 (en) * | 2004-06-23 | 2005-12-29 | Samsung Electronics Co., Ltd. | Deblocking method and apparatus using edge flow-directed filter and curvelet transform |
CN101551853A (en) * | 2008-11-14 | 2009-10-07 | 重庆大学 | Human ear detection method under complex static color background |
Non-Patent Citations (1)
Title |
---|
姜林等: ""不同形状植物成熟果实的识别提取方法"", 《科学技术与工程》 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114612497A (en) * | 2022-02-21 | 2022-06-10 | 北京百度网讯科技有限公司 | Method, device, equipment, medium and product for identifying image background color |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109558806B (en) | Method for detecting high-resolution remote sensing image change | |
Ma et al. | Shadow segmentation and compensation in high resolution satellite images | |
CN103218832B (en) | Based on the vision significance algorithm of global color contrast and spatial distribution in image | |
CN109544583B (en) | Method, device and equipment for extracting interested area of leather image | |
CN109961416B (en) | A business license information extraction method based on multi-scale fusion of morphological gradients | |
CN103020965A (en) | Foreground segmentation method based on significance detection | |
CN104537622B (en) | The method and system that raindrop influence is removed in single image | |
CN105761260B (en) | A kind of skin image affected part dividing method | |
CN103745468A (en) | Significant object detecting method based on graph structure and boundary apriority | |
CN104537634A (en) | Method and system for removing raindrop influences in dynamic image | |
CN104766344B (en) | Vehicle checking method based on movement edge extractor | |
CN104933728A (en) | Mixed motion target detection method | |
Lee et al. | Color image enhancement using histogram equalization method without changing hue and saturation | |
CN104574325A (en) | Skylight estimation method and system as well as image defogging method thereof | |
CN110599553B (en) | A kind of skin color extraction and detection method based on YCbCr | |
CN113724164A (en) | Visible light image noise removing method based on fusion reconstruction guidance filtering | |
CN103927759A (en) | Automatic cloud detection method of aerial images | |
CN108711160B (en) | Target segmentation method based on HSI (high speed input/output) enhanced model | |
CN106446920B (en) | A kind of stroke width transform method based on gradient amplitude constraint | |
CN103425973A (en) | Method and apparatus for performing enhancement processing on text-containing image, and video display device | |
CN103955691A (en) | Multi-resolution LBP textural feature extracting method | |
Nagarathinam et al. | Moving shadow detection based on stationary wavelet transform and Zernike moments | |
CN106228553B (en) | High-resolution remote sensing image shadow Detection apparatus and method | |
CN105373798A (en) | A calligraphy character extraction method based on K-nearest neighbor matting and mathematical morphology | |
CN113379785B (en) | Saliency target detection method integrating boundary priori and frequency domain information |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20150401 |