CN114723602A - Image processing method, image processing device, terminal and readable storage medium - Google Patents
Image processing method, image processing device, terminal and readable storage medium Download PDFInfo
- Publication number
- CN114723602A CN114723602A CN202210369140.0A CN202210369140A CN114723602A CN 114723602 A CN114723602 A CN 114723602A CN 202210369140 A CN202210369140 A CN 202210369140A CN 114723602 A CN114723602 A CN 114723602A
- Authority
- CN
- China
- Prior art keywords
- color
- image
- value
- clustering
- image processing
- 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.)
- Granted
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 45
- 238000012545 processing Methods 0.000 title claims abstract description 39
- 238000000034 method Methods 0.000 claims description 40
- 239000003086 colorant Substances 0.000 claims description 35
- 230000008569 process Effects 0.000 claims description 12
- 238000004590 computer program Methods 0.000 claims description 7
- 238000013507 mapping Methods 0.000 claims description 4
- 238000005070 sampling Methods 0.000 claims description 3
- 230000008447 perception Effects 0.000 abstract description 6
- 230000004075 alteration Effects 0.000 abstract description 2
- 238000010586 diagram Methods 0.000 description 10
- 230000006870 function Effects 0.000 description 6
- 230000000007 visual effect Effects 0.000 description 6
- 239000000463 material Substances 0.000 description 2
- 230000016776 visual perception Effects 0.000 description 2
- 230000008859 change Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 230000004456 color vision Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/04—Context-preserving transformations, e.g. by using an importance map
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/23—Clustering techniques
- G06F18/232—Non-hierarchical techniques
- G06F18/2321—Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions
- G06F18/23213—Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions with fixed number of clusters, e.g. K-means clustering
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/241—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Artificial Intelligence (AREA)
- Bioinformatics & Computational Biology (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Evolutionary Biology (AREA)
- Evolutionary Computation (AREA)
- General Engineering & Computer Science (AREA)
- Life Sciences & Earth Sciences (AREA)
- Probability & Statistics with Applications (AREA)
- Image Processing (AREA)
Abstract
本申请公开了一种图像处理方法、图像处理装置、终端及非易失性计算机可读存储介质。图像处理方法包括:将待处理图像转换至LAB色彩空间以获取第一图像;对第一图像做聚类处理以获取多个聚类结果;及根据多个聚类结果及每个聚类结果对应的色差总和获取主题颜色。本申请实施方式的图像处理方法、图像处理装置、终端及非易失性计算机可读存储介质通过将待处理图像转换至LAB色彩空间进行聚类处理,并根据聚类结果对应的色差总和获取主题颜色,以生成符合人眼感知的主题颜色。
The present application discloses an image processing method, an image processing device, a terminal and a non-volatile computer-readable storage medium. The image processing method includes: converting the image to be processed into the LAB color space to obtain a first image; performing clustering processing on the first image to obtain multiple clustering results; and corresponding to the multiple clustering results and each clustering result The sum of the chromatic aberrations gets the theme color. The image processing method, image processing device, terminal, and non-volatile computer-readable storage medium of the embodiments of the present application perform clustering processing by converting the image to be processed into the LAB color space, and obtain the theme according to the color difference sum corresponding to the clustering result color to generate a theme color that matches the perception of the human eye.
Description
技术领域technical field
本申请涉及图像处理技术领域,特别涉及一种图像处理方法、图像处理装置、终端及非易失性计算机可读存储介质。The present application relates to the technical field of image processing, and in particular, to an image processing method, an image processing device, a terminal, and a non-volatile computer-readable storage medium.
背景技术Background technique
图像主题色是从一张图像中提取出来最能代表这张图片主色调的多种颜色。也就是说在一幅色彩斑斓的图片里面,各种不同颜色的数量就对应着该颜色在图片中的比例,通过计算图片中不同颜色的像素数来算出主题色。色彩水印(调色盘)的主色调往往并不是单纯的出现次数最多的RGB值,它应该符合人眼的习惯,是视觉焦点。Image theme color is a variety of colors extracted from an image that best represent the main color of the image. That is to say, in a colorful picture, the number of different colors corresponds to the proportion of the color in the picture, and the theme color is calculated by calculating the number of pixels of different colors in the picture. The main color of the color watermark (color palette) is often not simply the RGB value that appears the most, it should conform to the habits of the human eye and be the visual focus.
发明内容SUMMARY OF THE INVENTION
本申请实施方式提供了一种图像处理方法、图像处理装置、终端及非易失性计算机可读存储介质,用于生成符合人眼感知的主题颜色。Embodiments of the present application provide an image processing method, an image processing apparatus, a terminal, and a non-volatile computer-readable storage medium, which are used to generate a theme color that conforms to human eye perception.
本申请实施方式的图像处理方法包括:将待处理图像转换至LAB色彩空间以获取第一图像;对所述第一图像做聚类处理以获取多个聚类结果;及根据多个所述聚类结果及每个所述聚类结果对应的色差总和获取主题颜色。The image processing method of the embodiment of the present application includes: converting the image to be processed into the LAB color space to obtain a first image; performing clustering processing on the first image to obtain multiple clustering results; The class result and the sum of the color differences corresponding to each of the clustering results obtain the theme color.
本申请实施方式的图像处理装置包括:第一获取模块,用于将待处理图像转换至LAB色彩空间以获取第一图像;聚类模块,用于对所述第一图像做聚类处理以获取多个聚类结果;及颜色获取模块,用于根据多个所述聚类结果及每个所述聚类结果对应的色差总和获取主题颜色。The image processing apparatus according to the embodiment of the present application includes: a first acquisition module, configured to convert the to-be-processed image to the LAB color space to acquire the first image; and a clustering module, configured to perform clustering processing on the first image to acquire a plurality of clustering results; and a color obtaining module, configured to obtain the theme color according to the plurality of the clustering results and the sum of the color differences corresponding to each of the clustering results.
本申请实施方式的终端包括:一个或多个处理器、存储器;和一个或多个程序,其中所述一个或多个程序被存储在所述存储器中,并且被所述一个或多个处理器执行,所述程序包括用于本申请实施方式的图像处理方法的指令。本申请实施方式的图像处理方法包括:将待处理图像转换至LAB色彩空间以获取第一图像;对所述第一图像做聚类处理以获取多个聚类结果;及根据多个所述聚类结果及每个所述聚类结果对应的色差总和获取主题颜色。。A terminal according to an embodiment of the present application includes: one or more processors, a memory; and one or more programs, wherein the one or more programs are stored in the memory and are processed by the one or more processors Executed, the program includes instructions for the image processing method of the embodiment of the present application. The image processing method of the embodiment of the present application includes: converting the image to be processed into the LAB color space to obtain a first image; performing clustering processing on the first image to obtain multiple clustering results; The class result and the sum of the color differences corresponding to each of the clustering results obtain the theme color. .
本申请实施方式的包含计算机程序的非易失性计算机可读存储介质,当计算机程序被一个或多个处理器执行时,使得处理器实现本申请实施方式的图像处理方法的指令。图像处理方法包括:将待处理图像转换至LAB色彩空间以获取第一图像;对所述第一图像做聚类处理以获取多个聚类结果;及根据多个所述聚类结果及每个所述聚类结果对应的色差总和获取主题颜色。The non-volatile computer-readable storage medium containing the computer program of the embodiment of the present application, when the computer program is executed by one or more processors, causes the processor to implement the instructions of the image processing method of the embodiment of the present application. The image processing method includes: converting an image to be processed into a LAB color space to obtain a first image; performing clustering processing on the first image to obtain a plurality of clustering results; and according to a plurality of the clustering results and each The color difference sum corresponding to the clustering result obtains the theme color.
本申请实施方式的图像处理方法、图像处理装置、终端及非易失性计算机可读存储介质通过将待处理图像转换至LAB色彩空间进行聚类处理,并根据聚类结果对应的色差总和获取主题颜色。LAB色彩空间是最为贴合人眼视觉感受的色彩空间,在LAB色彩空间进行聚类处理能够使聚类结果对应的颜色符合人眼的感知,以生成符合人眼感知的主题颜色。The image processing method, image processing device, terminal, and non-volatile computer-readable storage medium of the embodiments of the present application perform clustering processing by converting the image to be processed into the LAB color space, and obtain the theme according to the color difference sum corresponding to the clustering result color. The LAB color space is the most suitable color space for the visual perception of the human eye. Clustering in the LAB color space can make the color corresponding to the clustering result conform to the perception of the human eye, so as to generate the theme color that conforms to the perception of the human eye.
本申请实施方式的附加方面和优点将在下面的描述中部分给出,部分将从下面的描述中变得明显,或通过本申请的实践了解到。Additional aspects and advantages of embodiments of the present application will be set forth, in part, in the following description, and in part will be apparent from the following description, or learned by practice of the present application.
附图说明Description of drawings
本申请的上述和/或附加的方面和优点可以从结合下面附图对实施方式的描述中将变得明显和容易理解,其中:The above and/or additional aspects and advantages of the present application will become apparent and readily understood from the following description of embodiments in conjunction with the accompanying drawings, wherein:
图1是本申请某些实施方式的图像处理方法的流程示意图;1 is a schematic flowchart of an image processing method according to some embodiments of the present application;
图2是本申请某些实施方式的图像处理装置的结构示意图;2 is a schematic structural diagram of an image processing apparatus according to some embodiments of the present application;
图3是本申请某些实施方式的终端的结构示意图;3 is a schematic structural diagram of a terminal according to some embodiments of the present application;
图4是本申请某些实施方式的图像处理方法的流程示意图;4 is a schematic flowchart of an image processing method according to some embodiments of the present application;
图5是本申请某些实施方式的图像处理方法的流程示意图;5 is a schematic flowchart of an image processing method according to some embodiments of the present application;
图6是本申请某些实施方式的图像处理方法的流程示意图;6 is a schematic flowchart of an image processing method according to some embodiments of the present application;
图7是本申请某些实施方式的图像处理方法的中心点位置示意图;7 is a schematic diagram of the position of the center point of the image processing method according to some embodiments of the present application;
图8是本申请某些实施方式的图像处理方法的聚类场景示意图;8 is a schematic diagram of a clustering scene of an image processing method according to some embodiments of the present application;
图9是本申请某些实施方式的图像处理方法的流程示意图;9 is a schematic flowchart of an image processing method according to some embodiments of the present application;
图10是本申请某些实施方式的图像处理方法的聚类场景示意图;10 is a schematic diagram of a clustering scene of an image processing method according to some embodiments of the present application;
图11是本申请某些实施方式的图像处理方法的聚类场景示意图;11 is a schematic diagram of a clustering scene of an image processing method according to some embodiments of the present application;
图12是本申请某些实施方式的图像处理方法的聚类场景示意图;12 is a schematic diagram of a clustering scene of an image processing method according to some embodiments of the present application;
图13是本申请某些实施方式的图像处理方法的流程示意图;13 is a schematic flowchart of an image processing method according to some embodiments of the present application;
图14是本申请某些实施方式的图像处理方法的聚类场景示意图;14 is a schematic diagram of a clustering scene of an image processing method according to some embodiments of the present application;
图15是本申请某些实施方式的图像处理方法的流程示意图;15 is a schematic flowchart of an image processing method according to some embodiments of the present application;
图16是本申请某些实施方式的图像处理方法的流程示意图;16 is a schematic flowchart of an image processing method according to some embodiments of the present application;
图17是本申请某些实施方式的YUV图像及对应的色彩水印的示意图;17 is a schematic diagram of a YUV image and a corresponding color watermark of some embodiments of the present application;
图18是本申请某些实施方式的计算机可读存储介质与处理器的连接关系示意图。FIG. 18 is a schematic diagram of a connection relationship between a computer-readable storage medium and a processor according to some embodiments of the present application.
具体实施方式Detailed ways
下面详细描述本申请的实施方式,实施方式的示例在附图中示出,其中,相同或类似的标号自始至终表示相同或类似的元件或具有相同或类似功能的元件。下面通过参考附图描述的实施方式是示例性的,仅用于解释本申请的实施方式,而不能理解为对本申请的实施方式的限制。Embodiments of the present application are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals refer to the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary, only used to explain the embodiments of the present application, and should not be construed as limitations on the embodiments of the present application.
请参阅图1,本申请实施方式提供一种图像处理方法。图像处理方法包括:Referring to FIG. 1 , an embodiment of the present application provides an image processing method. Image processing methods include:
02:将待处理图像转换至LAB色彩空间以获取第一图像;02: Convert the image to be processed to the LAB color space to obtain the first image;
03:对第一图像做聚类处理以获取多个聚类结果;及03: perform clustering processing on the first image to obtain a plurality of clustering results; and
04:根据多个聚类结果及每个聚类结果对应的色差总和获取主题颜色。04: Obtain the theme color according to multiple clustering results and the sum of the color differences corresponding to each clustering result.
请参阅图2,本申请实施方式还提供一种图像处理装置10。图像处理装置10包括第一获取模块11、聚类模块13及颜色获取模块14。第一获取模块11用于实现02中的方法。聚类模块13用于实现03中的方法。颜色获取模块14用于实现04中的方法。即,第一获取模块10用于将待处理图像转换至LAB色彩空间以获取第一图像。聚类模块13用于对第一图像做聚类处理以获取多个聚类结果。颜色获取模块14用于根据多个聚类结果及每个聚类结果对应的色差总和获取主题颜色。Referring to FIG. 2 , an embodiment of the present application further provides an
请参阅图3,本申请实施方式还提供一种终端100。终端100可以是手机、台式电脑、笔记本电脑、服务器、智能家电、智能穿戴设备、游戏机、数码相机等,在此不一一列举。终端100包括一个或多个处理器80、存储器90及一个或多个程序。其中一个或多个程序被存储在存储器90中,并且被一个或多个处理器80执行。请结合图1,程序包括用于执行本申请实施方式的图像处理方法的指令。即,程序包括用于执行02、03及04中的方法的指令。Referring to FIG. 3 , an embodiment of the present application further provides a
其中,图像主题色是从一张图像中提取出来最能代表这张图片主色调的多种颜色。在本申请实施例中,待处理图像及第一图像为同一帧图像在不同色彩空间的表现形式。本申请实施方式的图像处理方法、图像处理装置10及终端100通过将待处理图像转换至LAB色彩空间进行聚类处理,并根据聚类结果对应的色差总和获取主题颜色。Among them, the image theme color is a variety of colors extracted from an image that can best represent the main color of the image. In this embodiment of the present application, the image to be processed and the first image are representations of the same frame of image in different color spaces. The image processing method, the
LAB色彩空间是颜色-对立空间,包括L、a、b三个分量。,其中,维度L表示亮度,a和b表示颜色对立维度,a代表从绿色到红色的分量,b代表从蓝色到黄色的分量。LAB是基于人对颜色的感觉来设计的,人眼接受光的刺激会产生三种颜色感觉:白色到黑色的感觉、红色到绿色的感觉、黄色到蓝色的感觉,而LAB色彩空间的L、a、b三个分量正是对应这三种视觉感觉设计的颜色通道。如果L、a、b这三个参数变化的幅度接近,那么它给人带来视觉上的变化幅度也差不多。因此,LAB色彩空间是最为贴合人眼视觉感受的色彩空间。在LAB色彩空间进行聚类处理能够使聚类结果对应的颜色符合人眼的感知。根据聚类结果对应的色差总和获取主题颜色,能够减少主题颜色中的渐变色,得到色相分明、特征鲜明、具有视觉焦点的主题颜色。The LAB color space is a color-opposite space, including three components L, a, and b. , where dimension L represents luminance, a and b represent color-opposite dimensions, a represents the component from green to red, and b represents the component from blue to yellow. LAB is designed based on human perception of color. The human eye will produce three color perceptions when stimulated by light: white to black, red to green, yellow to blue, and L of LAB color space. The three components of , a and b are the color channels corresponding to these three visual sense designs. If the three parameters of L, a, and b have a similar range of change, then it will bring about a similar range of visual changes. Therefore, the LAB color space is the most suitable color space for human visual perception. Clustering in the LAB color space can make the color corresponding to the clustering result conform to the perception of the human eye. The theme color is obtained according to the sum of the color differences corresponding to the clustering results, which can reduce the gradient color in the theme color, and obtain a theme color with distinct hue, distinctive features, and visual focus.
下面结合附图做进一步说明。Further description will be given below in conjunction with the accompanying drawings.
待处理图像可包括各种格式的图像。在一个实施例中,待处理图像为LAB色彩空间的图像,则将待处理图像之间作为第一图像进行后续的处理。The images to be processed may include images in various formats. In one embodiment, the image to be processed is an image in the LAB color space, and subsequent processing is performed between the images to be processed as the first image.
请参阅图4,在某些实施方式中,待处理图像为XYZ色彩空间的图像,待处理图像的像素包括第一XYZ分量、第二XYZ分量及第三XYZ分量。02:将待处理图像转换至LAB色彩空间以获取第一图像,包括:Referring to FIG. 4 , in some embodiments, the image to be processed is an image in the XYZ color space, and the pixels of the image to be processed include a first XYZ component, a second XYZ component and a third XYZ component. 02: Convert the image to be processed to the LAB color space to obtain the first image, including:
021:根据待处理图像的像素第一XYZ分量、第二XYZ分量、第三XYZ分量、预设的映射关系及预设的超参数,获取待处理图像的像素的LAB三通道值;及021: Obtain the LAB three-channel value of the pixel of the image to be processed according to the first XYZ component, the second XYZ component, the third XYZ component, the preset mapping relationship and the preset hyperparameter of the image to be processed; and
022:根据待处理图像的每个像素的LAB三通道值,获取第一图像。022: Acquire a first image according to the LAB three-channel value of each pixel of the image to be processed.
请结合图2,某些实施方式中,第一获取模块11还可用于实现021及022中的方法,即,第一获取模块11还可用于:根据待处理图像的像素第一XYZ分量、第二XYZ分量、第三XYZ分量、预设的映射关系及预设的超参数,获取待处理图像的像素的LAB三通道值;及022:根据待处理图像的每个像素的LAB三通道值,获取第一图像。Please refer to FIG. 2 , in some embodiments, the
请结合图3,某些实施方式中,程序还包括用于执行021及022中的方法的指令。Referring to FIG. 3 , in some embodiments, the program further includes instructions for executing the methods in 021 and 022 .
XYZ色彩空间是在RGB色彩系统的基础上,用三个理想的原色代替实际的RGB三原色。XYZ色彩空间包括X轴、Y轴、Z轴个坐标轴,某一颜色在X轴的坐标表示其红色的比例,在Y轴的坐标表示其绿色的比例,在Z轴的坐标表示其蓝色的比例。XYZ色彩空间的图像像素包括第一XYZ分量、第二XYZ分量及第三XYZ分量,分别表示该像素的红色、绿色、蓝色的比例。下面分别设第一XYZ分量为X、第二XYZ分量为Y、第三XYZ分量为Z进行说明。The XYZ color space is based on the RGB color system, replacing the actual RGB three primary colors with three ideal primary colors. The XYZ color space includes X-axis, Y-axis, and Z-axis. The coordinates of a certain color on the X-axis represent the proportion of its red color, the coordinates on the Y-axis represent its green ratio, and the coordinates on the Z-axis represent its blue color. proportion. An image pixel in the XYZ color space includes a first XYZ component, a second XYZ component, and a third XYZ component, which represent the ratio of red, green, and blue to the pixel, respectively. Hereinafter, the first XYZ component is designated as X, the second XYZ component is designated as Y, and the third XYZ component is designated as Z for description.
设LAB色彩空间的L、A、B三个通道的通道值分别为L*、a*、b*,可利用如下公式一、公式二及公式三将XYZ色彩空间的待处理图像转换为LAB色彩空间的第一图像。Let the channel values of the L, A, and B channels of the LAB color space be L*, a*, and b* respectively, and the following
公式一: Formula one:
公式二: Formula two:
公式三: Formula three:
其中,Xn、Yn、Zn为超参数。在一个实施例中,Xn的取值为95.047,Yn的取值为100.000,Zn的取值为108.883,以准确地得到XYZ色彩空间到LAB色彩空间的映射。in, X n , Y n , and Z n are hyperparameters. In one embodiment, the value of X n is 95.047, the value of Y n is 100.000, and the value of Z n is 108.883, so as to accurately obtain the mapping from the XYZ color space to the LAB color space.
如公式一,LAB色彩空间中L*表示亮度,而XYZ色彩空间中亮度由Y分量的值表示。公式一将LAB色彩空间和XYZ色彩空间的亮度关系联系起来,以得到LAB色彩空间中的L*通道值。As in formula 1, L* in the LAB color space represents the brightness, and the brightness in the XYZ color space is represented by the value of the Y component. Formula 1 associates the luminance relationship between the LAB color space and the XYZ color space to obtain the L* channel value in the LAB color space.
如公式二,LAB色彩空间中a*代表从绿色到红色的分量,而XYZ色彩空间中X分量代表红色的比例、Y分量代表绿色的比例。公式二将LAB色彩空间和XYZ色彩空间的红绿色关系联系起来,以得到LAB色彩空间中的a*通道值。As in
如公式三,LAB色彩空间中b*代表从蓝色到黄色的分量,而XYZ色彩空间中Z分量代表蓝色的比例、Y分量代表绿色的比例,绿色与黄色临近。公式三将LAB色彩空间和XYZ色彩空间的蓝绿色关系联系起来,以得到LAB色彩空间中的b*通道值。As in formula 3, b* in the LAB color space represents the component from blue to yellow, while in the XYZ color space the Z component represents the proportion of blue, the Y component represents the proportion of green, and green and yellow are adjacent. Equation 3 associates the blue-green relationship between the LAB color space and the XYZ color space to obtain the b* channel value in the LAB color space.
请参阅图1,在某些实施方式中,待处理图像是RGB色彩空间中的图像,RGB色彩空间是基于红、绿、蓝三原色的色彩空间。将RGB色彩空间中的图像转换至LAB色彩空间需要利用XYZ色彩空间做媒介。设待处理图像分别在R、G、B三个色彩通道的像素值取值范围均为[0,255],将取值范围设为range,则可利用如下公式四,根据RGB色彩空间的待处理图像获取XYZ色彩空间的第一图像。Referring to FIG. 1 , in some embodiments, the image to be processed is an image in an RGB color space, and the RGB color space is a color space based on three primary colors of red, green, and blue. Converting an image in the RGB color space to the LAB color space requires the use of the XYZ color space as a medium. Assuming that the pixel values of the image to be processed in the three color channels of R, G, and B are in the range of [0, 255], and the value range is set to range, the following formula 4 can be used. Process the image to obtain the first image in XYZ color space.
公式四: Formula four:
其中, in,
整理可得: Arrange to get:
如此,根据待处理图像在R、G、B三个色彩通道的像素值可以确定对应的XYZ色彩空间中的X、Y、Z分量值,以获取对应的第一图像。In this way, the X, Y, and Z component values in the corresponding XYZ color space can be determined according to the pixel values of the image to be processed in the three color channels of R, G, and B, so as to obtain the corresponding first image.
在某些实施方式中,由于XYZ色彩空间与LAB色彩空间之间的转换关系较为明确,因此,任意色彩空间的待处理图像均可转化为XYZ色彩空间的图像,再转换至LAB色彩空间以获取第一图像。In some embodiments, since the conversion relationship between the XYZ color space and the LAB color space is relatively clear, any image to be processed in any color space can be converted into an image in the XYZ color space, and then converted to the LAB color space to obtain first image.
请参阅图5,在某些实施方式中,图像处理方法还包括:Referring to FIG. 5, in some embodiments, the image processing method further includes:
05:获取YUV图像;05: Get YUV image;
06:将YUV图像进行降采样处理以获取第二图像;06: Downsampling the YUV image to obtain the second image;
07:将第二图像转换至RGB色彩空间以获取第三图像;及07: Convert the second image to the RGB color space to obtain the third image; and
08:将第三图像转换至XYZ色彩空间以获取待处理图像。08: Convert the third image to XYZ color space to obtain the image to be processed.
请结合图2,某些实施方式中,图像处理装置10还包括第二获取模块12、第三获取模块15、降采样模块16及第四获取模块17。第二处理模块12用于实现05中的方法。降采样模块16用于实现06中的方法。第三获取模块15用于实现07中的方法。第四获取模块17用于实现08中的方法。即,第二处理模块12用于获取YUV图像。降采样模块16用于将YUV图像进行降采样处理以获取第二图像。第三获取模块15用于将第二图像转换至RGB色彩空间以获取第三图像。第四获取模块17用于将第三图像转换至XYZ色彩空间以获取待处理图像。请结合图3,某些实施方式中,程序还包括用于执行05、06、07及08中的方法的指令。Referring to FIG. 2 , in some embodiments, the
通常,手机或相机拍摄获取的图像为YUV图像。根据05、06、07、08中的方法,可以将YUV图像转化为RGB色彩空间的图像,以进行后续的图像处理。对YUV图像进行降采样处理可以提高后续图像处理的速度,减少用户等待生成主题颜色的时间。在一个实施例中,对YUV图像缩小16倍以获取第三图像,在其他实施例中,还可以是缩小8倍、4倍、2倍、32倍等倍率,在此不一一列举。Usually, images captured by mobile phones or cameras are YUV images. According to the methods in 05, 06, 07, and 08, the YUV image can be converted into an image in the RGB color space for subsequent image processing. Downsampling YUV images can improve the speed of subsequent image processing and reduce the time users spend waiting to generate theme colors. In one embodiment, the YUV image is reduced by 16 times to obtain the third image, and in other embodiments, it can also be reduced by 8 times, 4 times, 2 times, 32 times, etc., which are not listed here.
在某些实施方式中,可根据如下公式五将第二图像转换至RGB色彩空间以获取第三图像。In some embodiments, the second image can be converted to the RGB color space according to the following formula 5 to obtain the third image.
公式五: Formula five:
其中,Y、Cb、Cγ分别为第三图像在YUV色彩空间中三个通道的分量,R、G、B分别为第三图像转换至RGB色彩空间后对应的三个通道的分量。Wherein, Y, C b , and C γ are the components of the three channels of the third image in the YUV color space, respectively, and R, G, and B are the components of the three channels corresponding to the third image converted to the RGB color space.
第三图像是RGB色彩空间中的图像,请结合公式四,可以将RGB色彩空间中的第三图像转化为XYZ色彩空间的待处理图像,以结合公式一、公式二、公式三,将XYZ色彩空间的待处理图像转化为LAB色彩空间的第一图像进行处理。The third image is an image in the RGB color space. Please combine the formula 4 to convert the third image in the RGB color space into the image to be processed in the XYZ color space. Combine the formula 1,
请参阅图6,在某些实施方式中,03:对第一图像做聚类处理以获取多个聚类结果,包括:Please refer to FIG. 6, in some embodiments, 03: perform clustering processing on the first image to obtain a plurality of clustering results, including:
031:根据颜色分类的数量在第一图像中确定多个中心点,每个中心点对应一个颜色分类;031: Determine a plurality of center points in the first image according to the number of color classifications, and each center point corresponds to a color classification;
032:获取每个颜色分类的第一颜色值及第一图像中各像素点的第二颜色值;032: Obtain the first color value of each color classification and the second color value of each pixel in the first image;
033:根据每个像素点的第二颜色值与每个颜色分类的第一颜色值之间的差异值将像素点划分至对应的颜色分类;033: Divide the pixel into corresponding color classifications according to the difference between the second color value of each pixel and the first color value of each color classification;
034:获取每个颜色分类中各个像素点的第二颜色值的平均值;及034: obtain the average value of the second color value of each pixel in each color classification; and
035:根据每个颜色分类对应的平均值更新每个颜色分类对应的中心点及第一颜色值。035: Update the center point and the first color value corresponding to each color classification according to the average value corresponding to each color classification.
请结合图2,某些实施方式中,聚类模块13还可用于实现031、032、033、034及035中的方法,即,聚类模块13还可用于:获取每个颜色分类的第一颜色值及第一图像中各像素点的第二颜色值;根据每个像素点的第二颜色值与每个颜色分类的第一颜色值之间的差异值将像素点划分至对应的颜色分类;获取每个颜色分类中各个像素点的第二颜色值的平均值;及根据每个颜色分类对应的平均值更新每个颜色分类对应的中心点及第一颜色值。请结合图3,某些实施方式中,程序还包括用于执行031、032、033、034及035中的方法的指令。Please refer to FIG. 2, in some embodiments, the
在某些实施方式中,颜色分类的数量是主题颜色的目标数量的两倍。主题颜色的目标数量为预设值,表示用多少种颜色来反映一张图像的主色调。例如,主题颜色的数量为5,则表示用5种不同的颜色来反映一张图像的主色调。聚类结果的数量与颜色分类的数量相同,即有多少种颜色分类,最终就能获取多少种聚类结果。请结合图1,颜色分类的数量是主题颜色数量的两倍,即聚类结果的数量是主题颜色数量的两倍,如此,在根据多个聚类结果及每个聚类结果对应的色差总和获取主题颜色时,可以从多个聚类结果对应的颜色中筛选出合适的颜色作为主题颜色,例如筛除多个聚类结果中色差相近的颜色,以使最终获取的主题颜色之间有明显的差异,得到鲜明的主题颜色。在其他实施例中,颜色分类的数量不局限于主题颜色的目标数量的两倍,可以是大于主题颜色的目标数量的任意数量,例如,颜色分类的数量比主题颜色的目标数量多1个、2个、3个等,再例如,颜色分类的数量是主题颜色的目标数量的3倍、4倍、5倍等,在此不一一列举。In some embodiments, the number of color classifications is twice the target number of theme colors. The target number of theme colors is a preset value, indicating how many colors are used to reflect the main color of an image. For example, the number of theme colors is 5, which means that 5 different colors are used to reflect the main color of an image. The number of clustering results is the same as the number of color classifications, that is, how many kinds of color classifications there are, how many kinds of clustering results can be obtained in the end. Please refer to Figure 1. The number of color classifications is twice the number of theme colors, that is, the number of clustering results is twice the number of theme colors. In this way, according to multiple clustering results and the sum of the color differences corresponding to each clustering result When obtaining the theme color, you can select the appropriate color from the colors corresponding to the multiple clustering results as the theme color, for example, filter out the colors with similar color difference in the multiple clustering results, so that the finally obtained theme colors have obvious differences. difference to get a bright theme color. In other embodiments, the number of color classifications is not limited to twice the target number of the theme color, and can be any number greater than the target number of the theme color, for example, the number of color classifications is 1 more than the theme color target number, 2, 3, etc., for another example, the number of color classifications is 3 times, 4 times, 5 times, etc., the target number of the theme colors, etc., which are not listed here.
请结合图7,中心点是在第一图像中选取的位置点,图像可以是RGB色彩空间的待处理图像,或者其他色彩空间的初始图像,在此不作限制。在图5示意的实施例中,主题颜色的目标数量为5个,颜色分类的数量为10个,中心点的数量为10个。在确定中心点时,通过3条分界线将图像沿横向均分为4份,及通过另外3条分界线将图像沿纵向均分为4份,在上述6条分界线形成的交点D1、D2、D3、D4、D5、D6、D7、D8、D9中,将交点D1、D2、D3、D4、D5、D7、D8、D9设置为中心点,以及将交点D4和交点D5的中点D10、交点D6和交点D5的中点D11设置为中心点,得到10个中心点。在其他实施例中,中心点的分布可以不局限于图5示意的分布方式,在此不作限制。例如,在又一个实施例中,中心点在图像中均匀分布。Please refer to FIG. 7 , the center point is a position point selected in the first image, and the image may be a to-be-processed image in an RGB color space, or an initial image in other color spaces, which is not limited here. In the embodiment illustrated in FIG. 5 , the number of targets for theme colors is 5, the number of color classifications is 10, and the number of center points is 10. When determining the center point, the image is divided into 4 parts in the horizontal direction by 3 dividing lines, and the image is divided into 4 parts in the vertical direction by the other 3 dividing lines. At the intersections D1 and D2 formed by the above 6 dividing lines , D3, D4, D5, D6, D7, D8, D9, set the intersection D1, D2, D3, D4, D5, D7, D8, D9 as the center point, and set the intersection D4 and D5 at the midpoint D10, The midpoint D11 of the intersection D6 and the intersection D5 is set as the center point, and 10 center points are obtained. In other embodiments, the distribution of the center points may not be limited to the distribution manner illustrated in FIG. 5 , which is not limited here. For example, in yet another embodiment, the center points are uniformly distributed in the image.
聚类的过程是将第一图像中的各像素点按颜色划分至颜色最接近的颜色分类中。其中,第一颜色值是中心点所在的位置处对应的颜色,第一颜色值由L*、A*、B*通道值体现。例如,设中心点Ai对应的第一颜色值为Yai=(Li*,Ai*,Bi*)。第二颜色值是像素点所在的位置处对应的颜色,第二颜色值由L*、A*、B*通道值体现。例如,设像素点Pj对应的第二颜色值为Ypj=(Lj*,Aj*,Bj*)。差异值反映第一颜色值Yai和第二颜色值Ypj之间的颜色差异,差异值越小,则对应的第一颜色值Yai对应的颜色和第二颜色值Ypj对应的颜色越接近。在聚类的过程中,将每个像素点Pj划分至颜色最接近的中心点Ai所在的颜色分类。The process of clustering is to classify each pixel in the first image by color into the color classification with the closest color. The first color value is the color corresponding to the position where the center point is located, and the first color value is represented by the L*, A*, and B* channel values. For example, assume that the first color value corresponding to the center point Ai is Yai=(Li*, Ai*, Bi*). The second color value is the color corresponding to the position of the pixel point, and the second color value is represented by the L*, A*, and B* channel values. For example, it is assumed that the second color value corresponding to the pixel point Pj is Ypj=(Lj*, Aj*, Bj*). The difference value reflects the color difference between the first color value Yai and the second color value Ypj. The smaller the difference value is, the closer the corresponding color of the first color value Yai is to the color corresponding to the second color value Ypj. In the clustering process, each pixel point Pj is divided into the color classification where the center point Ai with the closest color is located.
以像素点P1为例,分别获取像素点P1与各个中心点Ai之间的差异值,以确定与像素点P1颜色最接近的聚类。设像素点P1与中心点A2对应的颜色之间的差异值最小,中心点A2对应颜色分类S2,则将像素点P1划分至颜色分类S2。依此类推,分别获取各个像素点Pj与各个中心点Ai之间的差异值,以分别确定每个像素点Pj对应的颜色分类Sk,k∈[1,i]。Taking the pixel point P1 as an example, the difference values between the pixel point P1 and each center point Ai are obtained respectively to determine the cluster with the closest color to the pixel point P1. Assuming that the difference value between the colors corresponding to the pixel point P1 and the center point A2 is the smallest, and the center point A2 corresponds to the color classification S2, the pixel point P1 is divided into the color classification S2. By analogy, the difference values between each pixel point Pj and each center point Ai are obtained respectively to determine the color classification Sk,k∈[1,i] corresponding to each pixel point Pj, respectively.
请参阅图8,作为一个示例,第一图像中有已经确定的中心点A1及中心点A2,分别对应颜色分类S1和颜色分类S2。为了便于说明,在图6的示例中省略第一图像中的其他像素点,对以像素点P1、P2、P3、P4、P5、P6的聚类进行说明。设与中心点A1对应的颜色之间的差异值最小的像素点为P1、P2、P3,与中心点A2对应的颜色之间的差异值最小的像素点为P4、P5、P6,则将P1、P2、P3划分至颜色分类S1,将P4、P5、P6划分至颜色分类S2。图6中,分隔线O1上侧为颜色分类S1,分隔线O1下侧为颜色分类S2。Referring to FIG. 8 , as an example, there are determined center points A1 and A2 in the first image, which correspond to color classification S1 and color classification S2 respectively. For convenience of description, other pixel points in the first image are omitted in the example of FIG. 6 , and the clustering of pixel points P1 , P2 , P3 , P4 , P5 , and P6 will be described. Let the pixels with the smallest difference values between the colors corresponding to the center point A1 be P1, P2, and P3, and the pixels with the smallest difference values between the colors corresponding to the center point A2 be P4, P5, and P6, then P1 , P2, P3 are divided into color classification S1, and P4, P5, P6 are divided into color classification S2. In FIG. 6, the upper side of the dividing line O1 is the color classification S1, and the lower side of the dividing line O1 is the color classification S2.
在进行一次划分后,获取每个颜色分类Sk中各像素点Pj的第二颜色值Ypj的平均值,根据每个颜色分类Sk对应的平均值更新每个颜色分类Sk对应的中心点Ai及第一颜色值Yai。如此,以划分后颜色分类Sk包含的像素点Pj的第二颜色值Ypj的平均值作为该颜色分类Sk对应的第一颜色值Yai,能够更准确地代表划分后颜色分类Sk整体的颜色特点。更新后的中心点Ai是更新后的第一颜色值Yai在LAB色彩空间对应的位置点。After a division is performed, the average value of the second color value Ypj of each pixel point Pj in each color classification Sk is obtained, and the center point Ai and the first color corresponding to each color classification Sk are updated according to the average value corresponding to each color classification Sk. A color value Yai. In this way, taking the average value of the second color values Ypj of the pixels Pj included in the divided color classification Sk as the first color value Yai corresponding to the color classification Sk can more accurately represent the color characteristics of the divided color classification Sk as a whole. The updated center point Ai is the position point corresponding to the updated first color value Yai in the LAB color space.
请参阅图8,作为一个示例,设每个颜色分类Sk中各像素点Pj的第二颜色值Ypj的平均值为Ydk。在进行一次划分后,颜色分类S1中像素点P1、P2、P3的第二颜色值Yp1、Yp2、Yp3的平均值为Yd1,将Yd1作为更新后颜色分类S1的第一颜色值Ya1的取值,更新后颜色分类S1对应的中心点为A3;颜色分类S2中像素点P4、P5、P6的第二颜色值Yp4、Yp5、Yp6的平均值为Yd2,将Yd2作为更新后颜色分类S2的第一颜色值第一颜色值Ya2的取值,更新后颜色分类S1对应的中心点为A4。Referring to FIG. 8 , as an example, let the average value of the second color values Ypj of each pixel point Pj in each color classification Sk be Ydk. After one division, the average value of the second color values Yp1, Yp2, and Yp3 of the pixels P1, P2, and P3 in the color classification S1 is Yd1, and Yd1 is taken as the value of the first color value Ya1 of the updated color classification S1. , the center point corresponding to the updated color classification S1 is A3; the average value of the second color values Yp4, Yp5, and Yp6 of the pixel points P4, P5, and P6 in the color classification S2 is Yd2, and Yd2 is used as the first color of the updated color classification S2. A color value The value of the first color value Ya2, the center point corresponding to the updated color classification S1 is A4.
请参阅图9,在某些实施方式中,03:对第一图像做聚类处理以获取多个聚类结果,还包括:Referring to FIG. 9, in some embodiments, 03: perform clustering processing on the first image to obtain multiple clustering results, further comprising:
036:根据每个像素点的第二颜色值与每个颜色分类更新后的第一颜色值之间的差异值将像素点划分至对应的颜色分类;036: according to the difference value between the second color value of each pixel and the updated first color value of each color classification, the pixel is divided into the corresponding color classification;
037:在颜色分类对应的中心点的更新次数达到预设的次数阈值的情况下结束聚类处理,将中心点对应的第一颜色值作为聚类结果输出;或037: End the clustering process when the number of updates of the center point corresponding to the color classification reaches a preset number of times threshold, and output the first color value corresponding to the center point as the clustering result; or
038:在更新前后颜色分类对应的中心点不变的情况下结束聚类处理,将中心点对应的第一颜色值作为聚类结果输出。038: End the clustering process when the center point corresponding to the color classification before and after the update is unchanged, and output the first color value corresponding to the center point as the clustering result.
请结合图2,某些实施方式中,聚类模块13还可用于实现036、037或038中的方法,即,聚类模块13还可用于:根据每个像素点的第二颜色值与每个颜色分类更新后的第一颜色值之间的差异值将像素点划分至对应的颜色分类;在颜色分类对应的中心点的更新次数达到预设的次数阈值的情况下结束聚类处理,将中心点对应的第一颜色值作为聚类结果输出;或在更新前后颜色分类对应的中心点不变的情况下结束聚类处理,将中心点对应的第一颜色值作为聚类结果输出。请结合图3,某些实施方式中,程序还包括用于执行026、027或028中的方法的指令。Please refer to FIG. 2 , in some embodiments, the
请结合图8、图10、及图11,在完成一次中心点Ai及第一颜色值Yai的更新后,根据各个颜色分类Sk更新后的第一颜色值Yai对每个像素点Pi的第二颜色值Ypj进行下一次聚类,直到中心点Ai的更新次数达到预设的次数阈值的情况下结束聚类,或者在更新后的第一颜色值Yai与更新前的第一颜色值Yai相同的情况下结束聚类。结束聚类意味着接受颜色分类Sk对应的第一颜色值Yai作为聚类结果,即接收第一颜色值Yai作为代表该颜色分类Sk的代表色。Please refer to FIG. 8, FIG. 10, and FIG. 11, after completing the update of the center point Ai and the first color value Yai, the second color value Yai of each pixel point Pi is updated according to the updated first color value Yai of each color classification Sk. The color value Ypj performs the next clustering, and the clustering ends when the number of updates of the center point Ai reaches the preset number threshold, or when the updated first color value Yai is the same as the first color value before the update Yai end clustering. Ending the clustering means accepting the first color value Yai corresponding to the color classification Sk as the clustering result, that is, receiving the first color value Yai as the representative color representing the color classification Sk.
请参阅图8、图10及图11,图10是在图8的聚类基础上进行的下一次聚类。设此次聚类中:与中心点A3对应的颜色之间的差异值最小的像素点为P1、P2、P4,与中心点A2对应的颜色之间的差异值最小的像素点为P3、P5、P6,则将P1、P2、P4划分至颜色分类S1,将P3、P5、P6划分至颜色分类S2。图10中,分隔线O1左侧为颜色分类S1,分隔线O1右侧为颜色分类S2。如图11所示,在划分并更新中心点后,颜色分类S1的中心点为A5,对应的第一颜色值Ya1的取值Yd1为像素点P1、P2、P4的第二颜色值Yp1、Yp2、Yp4的平均值;颜色分类S2的中心点为A6,对应的第一颜色值Ya2的取值Yd2为像素点P3、P5、P6的第二颜色值Yp3、Yp5、Yp6的平均值。Please refer to FIG. 8 , FIG. 10 and FIG. 11 . FIG. 10 is the next clustering based on the clustering of FIG. 8 . In this clustering, the pixels with the smallest difference value between the colors corresponding to the center point A3 are P1, P2, and P4, and the pixels with the smallest difference value between the colors corresponding to the center point A2 are P3 and P5. , P6, P1, P2, P4 are divided into color classification S1, P3, P5, P6 are divided into color classification S2. In FIG. 10, the left side of the dividing line O1 is the color classification S1, and the right side of the dividing line O1 is the color classification S2. As shown in Figure 11, after dividing and updating the center point, the center point of the color classification S1 is A5, and the value Yd1 of the corresponding first color value Ya1 is the second color value Yp1, Yp2 of the pixel points P1, P2, and P4. The center point of the color classification S2 is A6, and the value Yd2 of the corresponding first color value Ya2 is the average value of the second color values Yp3, Yp5, and Yp6 of the pixel points P3, P5, and P6.
请结合图12,图12是在图11的聚类基础上进行的下一次聚类。设此次聚类后将颜色分类S1的中心点更新为A7,颜色分类S2的中心点更新为A8。在一个实施例中,A7在LAB色彩空间中的位置与A5在色彩空间中的位置相同,且A8在LAB色彩空间中的位置与A6在色彩空间中的位置相同,则结束聚类,将本次聚类后颜色分类S1对应的第一颜色值Ya1和颜色分类S2对应的第一颜色值Ya2作为聚类结果输出。在又一个实施例中,A7在LAB色彩空间中的位置与A5在色彩空间中的位置不同,A8在LAB色彩空间中的位置与A6在色彩空间中的位置不同,但中心点的更新次数已经达到预设的次数阈值,则结束聚类,将本次聚类后颜色分类S1对应的第一颜色值Ya1和颜色分类S2对应的第一颜色值Ya2作为聚类结果输出。Please refer to FIG. 12 , which is the next clustering based on the clustering in FIG. 11 . Suppose that after this clustering, the center point of color classification S1 is updated to A7, and the center point of color classification S2 is updated to A8. In one embodiment, the position of A7 in the LAB color space is the same as the position of A5 in the color space, and the position of A8 in the LAB color space is the same as the position of A6 in the color space, then the clustering is ended, and this After the sub-clustering, the first color value Ya1 corresponding to the color classification S1 and the first color value Ya2 corresponding to the color classification S2 are output as the clustering result. In yet another embodiment, the position of A7 in the LAB color space is different from the position of A5 in the color space, and the position of A8 in the LAB color space is different from the position of A6 in the color space, but the number of updates of the center point has been When the preset number of times threshold is reached, the clustering is ended, and the first color value Ya1 corresponding to the color classification S1 and the first color value Ya2 corresponding to the color classification S2 after this clustering are output as the clustering result.
请参阅图13,在某些实施方式中,033:根据每个像素点的第二颜色值与每个颜色分类的第一颜色值之间的差异值将像素点划分至对应的颜色分类,包括:Referring to FIG. 13, in some embodiments, 033: Divide the pixels into corresponding color categories according to the difference between the second color value of each pixel and the first color value of each color category, including :
0331:获取第一颜色值的第一LAB分量和第二颜色值的第二LAB分量;0331: Obtain the first LAB component of the first color value and the second LAB component of the second color value;
0332:根据第一LAB分量和第二LAB分量获取色调旋转项、亮度补偿值、色度补偿值及色调补偿值;0332: Obtain the hue rotation item, the luminance compensation value, the chrominance compensation value and the hue compensation value according to the first LAB component and the second LAB component;
0333:根据第一LAB分量、第二LAB分量、色调旋转项、亮度补偿值、色度补偿值及色调补偿值获取差异值;及0333: Obtain a difference value according to the first LAB component, the second LAB component, the hue rotation term, the luminance compensation value, the chrominance compensation value, and the hue compensation value; and
0334:挑选像素点的第二颜色值与多个第一颜色值之间的多个差异值中的最小差异值,将像素点划分至最小差异值对应的颜色分类。0334: Select the smallest difference value among the plurality of difference values between the second color value of the pixel point and the plurality of first color values, and divide the pixel point into a color classification corresponding to the smallest difference value.
请结合图2,某些实施方式中,聚类模块13还可用于实现0331、0332、0333及0334中的方法,即,聚类模块13还可用于:获取第一颜色值的第一LAB分量和第二颜色值的第二LAB分量;根据第一LAB分量和第二LAB分量获取色调旋转项、亮度补偿值、色度补偿值及色调补偿值;根据第一LAB分量、第二LAB分量、色调旋转项、亮度补偿值、色度补偿值及色调补偿值获取差异值;及挑选像素点的第二颜色值与多个第一颜色值之间的多个差异值中的最小差异值,将像素点划分至最小差异值对应的颜色分类。请结合图3,某些实施方式中,程序还包括用于执行0231、0232、0233及0234中的方法的指令。Please refer to FIG. 2 , in some embodiments, the
请结合图14,设中心点A1的第一颜色值Ya1=(L1,a1,b1),中心点A2的第一颜色值Ya2=(L2,a2,b2),像素点P1的第二颜色值Yp1=(L1 *,a1 *,b1 *),中心点A1与像素点P1之间的差异值为E1,中心点A2与像素点P1之间的差异值为E2。差异值E1可通过如下公式六计算:Please refer to Fig. 14, set the first color value Ya1 of the center point A1 = (L 1 , a 1 , b 1 ), the first color value of the center point A2 Ya2 = (L 2 , a 2 , b 2 ), the pixel point The second color value Yp1 of P1=(L 1 * , a 1 * , b 1 * ), the difference between the center point A1 and the pixel point P1 is E1, and the difference between the center point A2 and the pixel point P1 is the value of E1 E2. The difference value E1 can be calculated by the following formula 6:
公式六: Formula six:
其中,KL、KC、KH均为预设值,在一个实施例中,KL、KC、KH的取值均为1。Wherein, K L , K C , and K H are all preset values, and in one embodiment, the values of K L , K C , and K H are all 1.
△L=L1-L1 *,△C=C1-C2, △L=L 1 -L 1 * , △C=C1-C2,
h1=atan2(b1,a1)mod360°,h2=atan2(b1 *,a1 *)mod360°;h1=atan2(b 1 , a 1 ) mod 360°, h2=atan2(b 1 * , a 1 * ) mod 360°;
其中,RT为色调旋转项,引入色调旋转项RT使差异值E1可以较好地适应色相角度275°附近的蓝色区域,避免蓝色区域的差异不准确。SL为亮度补偿值,使差异值E1能够准确地反映亮度差异。SC为色度补偿值,使差异值E1能够准确地反映色度差异。SH为色调补偿值,使差异值E1能够准确地反映色调差异。与计算差异值E1的方法类似,将公式五中的分量L1、a1、b1替换为L2、a2、b2,即可计算出计算差异值E2。在分别计算出差异值E1和差异值E2后,将像素点P1划分至差异值E1和差异值E2中最小的差异值对应的颜色分类。例如,E1<E2,则将像素点P1划分至颜色分类S1。类似地,在中心点的数量为i个时,分别计算像素点P1的第二颜色值Yp1与每个第一颜色值Yai之间的差异值Ek,将像素点P1划分至最小差异值Ekmin对应的颜色分类Skmin。其中,k∈[1,i]。以此类推,可以将每个像素点Pj划分至对应的颜色分类Sk中。Among them, RT is the hue rotation term, and the introduction of the hue rotation term RT allows the difference value E1 to better adapt to the blue area near the hue angle of 275°, avoiding inaccurate differences in the blue area. S L is a brightness compensation value, so that the difference value E1 can accurately reflect the brightness difference. S C is the chromaticity compensation value, so that the difference value E1 can accurately reflect the chromaticity difference. S H is the hue compensation value, so that the difference value E1 can accurately reflect the hue difference. Similar to the method for calculating the difference value E1, the calculated difference value E2 can be calculated by replacing the components L 1 , a 1 , and b 1 in formula 5 with L 2 , a 2 , and b 2 . After the difference value E1 and the difference value E2 are calculated respectively, the pixel point P1 is divided into the color classification corresponding to the smallest difference value among the difference value E1 and the difference value E2. For example, if E1<E2, the pixel point P1 is divided into the color classification S1. Similarly, when the number of center points is i, the difference value Ek between the second color value Yp1 of the pixel point P1 and each first color value Yai is calculated respectively, and the pixel point P1 is divided into the minimum difference value Ekmin corresponding to The color classification of Skmin. where k∈[1,i]. By analogy, each pixel point Pj can be divided into the corresponding color classification Sk.
在获取聚类结果后,从聚类结果中挑选出与其他聚类结果之间的色差总和最大的n个聚类结果生成n个主题颜色,以确保多个主题颜色之间特点鲜明、具有代表性,避免将颜色近似的渐变色选为主题颜色。After obtaining the clustering results, select n clustering results with the largest sum of color differences with other clustering results from the clustering results to generate n theme colors to ensure that the multiple theme colors are distinct and representative to avoid choosing similar-colored gradients as the theme color.
请参阅图15,在某些实施方式中,04:根据多个聚类结果及每个聚类结果对应的色差总和获取主题颜色,包括:Please refer to FIG. 15, in some embodiments, 04: obtain the theme color according to a plurality of clustering results and the sum of the color differences corresponding to each clustering result, including:
041:分别获取每个聚类结果对应的色差总和;及041: Obtain the color difference sum corresponding to each clustering result respectively; and
042:以色差总和由大到小的顺序获取前n个聚类结果分别生成n个主题颜色,n的取值为主题颜色的目标数量。042: Obtain the first n clustering results in descending order of the sum of color differences to generate n theme colors, where n is the target number of theme colors.
请结合图2,某些实施方式中,颜色获取模块14还可用于实现041及042中的方法,即,聚类模块13还可用于:分别获取每个聚类结果对应的色差总和;及以色差总和由大到小的顺序获取前n个聚类结果分别生成n个主题颜色,n的取值为主题颜色的目标数量。请结合图3,某些实施方式中,程序还包括用于执行041及042中的方法的指令。Please refer to FIG. 2, in some embodiments, the
在某些实施方式中,设聚类结果为Jm,聚类结果Jm对应的色差总和为Zm,设m=6,即聚类后获得了6个聚类结果,n=3,即生成3个主题颜色。首先,将聚类结果Jm映射回RGB色彩空间以获取聚类结果Jm对应的RGB色彩值Um,色彩值Um的色差总和Zm为色彩值Um与其他色彩值之间的各个色差之和。例如,请参阅下表:In some embodiments, let the clustering result be Jm, the sum of the color differences corresponding to the clustering result Jm is Zm, and m=6, that is, 6 clustering results are obtained after clustering, and n=3, that is, 3 clustering results are generated. Theme color. First, the clustering result Jm is mapped back to the RGB color space to obtain the RGB color value Um corresponding to the clustering result Jm, and the color difference sum Zm of the color value Um is the sum of the color differences between the color value Um and other color values. For example, see the table below:
其中,横纵坐标相交的数字代表横轴的色彩值与纵轴的色彩值之间的色差,例如,色彩值U1与色彩值U1之间的色差的值为0,色彩值U1与色彩值U2之间的色差的值为1。最后统计的Z1、Z2、Z3、Z4、Z5、Z6分别是色彩值U1、U2、U3、U4、U5、U6对应的色差总和。其中,色差总和Z6最大,表示聚类结果J6对应的色彩值U6与其他每个聚类结果对应的色彩值的颜色差异最大;色差总和Z1最小,表示聚类结果J1对应的色彩值U1与其他每个聚类结果对应的色彩值的颜色差异最小。在n=3的情况下,取色差总和最大的前3个聚类结果生成主题颜色,在本例中,色差总和最大的前3个聚类结果分别为聚类结果J6、聚类结果J5、聚类结果J4,将聚类结果J6、聚类结果J5、聚类结果J4分别对应的色彩值U6、色彩值U5、色彩值U4作为主题颜色。在其他实施例中,在获取色差总和最大的前n个聚类结果后,不局限于将聚类结果对应的RGB色彩空间中的色彩值作为主题颜色,还可以为其他色彩空间的色彩值,例如HSV色彩空间的色彩值、LAB色彩空间的色彩值、YUV空间的色彩值等,在此不作限制。Among them, the number where the horizontal and vertical coordinates intersect represents the color difference between the color value of the horizontal axis and the color value of the vertical axis. For example, the value of the color difference between the color value U1 and the color value U1 is 0, and the color value U1 and the color value U2 The value of the color difference between is 1. The final statistics of Z1, Z2, Z3, Z4, Z5, and Z6 are the sum of the color differences corresponding to the color values U1, U2, U3, U4, U5, and U6, respectively. Among them, the color difference sum Z6 is the largest, indicating that the color value U6 corresponding to the clustering result J6 has the largest color difference between the color value corresponding to each other clustering result; the color difference sum Z1 is the smallest, indicating that the color value U1 corresponding to the clustering result J1 is different from other The color difference of the color value corresponding to each clustering result is the smallest. In the case of n=3, the first 3 clustering results with the largest sum of color differences are selected to generate the theme color. In this example, the first 3 clustering results with the largest sum of color differences are clustering results J6, clustering results J5, For the clustering result J4, the color value U6, the color value U5, and the color value U4 corresponding to the clustering result J6, the clustering result J5, and the clustering result J4, respectively, are used as the theme color. In other embodiments, after obtaining the top n clustering results with the largest sum of color differences, the color value in the RGB color space corresponding to the clustering result is not limited to be used as the theme color, but can also be the color value of other color spaces, For example, the color value of the HSV color space, the color value of the LAB color space, the color value of the YUV space, etc., are not limited here.
请参阅图16,在某些实施方式中,图像处理方法还包括:Referring to FIG. 16, in some embodiments, the image processing method further includes:
09:将主题颜色对应的第三颜色值转换至YUV色彩空间以生成色彩水印;及09: Convert the third color value corresponding to the theme color to the YUV color space to generate a color watermark; and
010:根据第三颜色值的亮度值大小对色彩水印排序并与YUV图像一并显示。010: Sort the color watermarks according to the brightness value of the third color value and display them together with the YUV image.
请结合图2,某些实施方式中,图像处理装置10还包括水印生成模块18及排序模块19。水印生成模块18用于实现09中的方法。排序模块19用于实现010中的方法。即,水印生成模块18用于将主题颜色对应的第三颜色值转换至YUV色彩空间以生成色彩水印。排序模块19模块用于根据第三颜射值的亮度值大小对色彩水印排序并与YUV图像一并显示。请结合图3,某些实施方式中,程序还包括用于执行09及010中的方法的指令。Referring to FIG. 2 , in some embodiments, the
其中,第三颜色值是主题颜色在RGB色彩空间对应的颜色值。色彩水印通常通过手机、相机、电脑等终端100的显示屏进行显示,这类终端100拍摄物体得到的图像通常为YUV图像,因此,生成YUV格式的色彩水印能够便于利用色彩水印编辑终端100存储的YUV图像。The third color value is the color value corresponding to the theme color in the RGB color space. The color watermark is usually displayed on the display screen of the terminal 100 such as a mobile phone, a camera, a computer, etc. The image obtained by such a terminal 100 shooting an object is usually a YUV image. Therefore, generating a color watermark in the YUV format can easily use the color watermark to edit the data stored in the
在一个实施例中,依据上述公式一至公式五,将终端设备的YUV图像依次转换为RGB色彩空间图像、XYZ色彩空间图像、LAB色彩空间图像进行相应的处理。根据该YUV图像对应的LAB色彩空间图像能够生成主题颜色,再将主题颜色对应的第三颜色值转换回YUV色彩空间以生成YUV色彩空间对应的色彩水印并进行排序。In an embodiment, according to the above formulas 1 to 5, the YUV image of the terminal device is sequentially converted into an RGB color space image, an XYZ color space image, and a LAB color space image for corresponding processing. The theme color can be generated according to the LAB color space image corresponding to the YUV image, and then the third color value corresponding to the theme color is converted back to the YUV color space to generate and sort the color watermark corresponding to the YUV color space.
请结合图17,排序后的色彩水印与YUV图像一并显示,使用户能够直观地看到符合YUV图像色彩主题的色彩水印。在一些实施例中,用户可利用色彩水印实现制作个人主页、进行图片色调筛选等功能,增强用户浏览图片时的浸入式交互体验。Please refer to Figure 17, the sorted color watermarks are displayed together with the YUV image, so that the user can intuitively see the color watermark that conforms to the color theme of the YUV image. In some embodiments, the user can use the color watermark to realize functions such as making a personal homepage and performing color screening of pictures, so as to enhance the user's immersive interactive experience when browsing pictures.
在一个实施例中,为了符合人眼的视觉效果,在生成色彩水印后根据第三颜色值的亮度值大小对色彩水印排序,使用户所见的色彩水印由明到暗或由暗到明依次排列,具有美观的视觉效果。In one embodiment, in order to conform to the visual effect of the human eye, after the color watermarks are generated, the color watermarks are sorted according to the brightness value of the third color value, so that the color watermarks seen by the user are sequentially from light to dark or from dark to light Arranged for beautiful visual effects.
请参阅图17,本申请实施方式还提供一种包含计算机程序801的非易失性计算机可读存储介质800。本申请实施方式的一个或多个包含计算机程序801的非易失性计算机可读存储介质800,当计算机程序801被一个或多个处理器80执行时,使得处理器80可执行上述任一实施方式的调节方法,例如实现步骤01、02、03中的一项或多项步骤。Referring to FIG. 17 , an embodiment of the present application further provides a non-volatile computer-
例如,当计算机程序801被一个或多个处理器80执行时,使得处理器80执行以下步骤:For example,
02:将待处理图像转换至LAB色彩空间以获取第一图像;02: Convert the image to be processed to the LAB color space to obtain the first image;
03:对第一图像做聚类处理以获取多个聚类结果;及03: perform clustering processing on the first image to obtain a plurality of clustering results; and
04:根据多个聚类结果及每个聚类结果对应的色差总和获取主题颜色。04: Obtain the theme color according to multiple clustering results and the sum of the color differences corresponding to each clustering result.
在本说明书的描述中,参考术语“一个实施方式”、“一些实施方式”、“示意性实施方式”、“示例”、“具体示例”或“一些示例”等的描述意指结合实施方式或示例描述的具体特征、结构、材料或者特点包含于本申请的至少一个实施方式或示例中。在本说明书中,对上述术语的示意性表述不一定指的是相同的实施方式或示例。而且,描述的具体特征、结构、材料或者特点可以在任何的一个或多个实施方式或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本邻域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。In the description of this specification, reference to the terms "one embodiment," "some embodiments," "exemplary embodiment," "example," "specific example," or "some examples", etc. The particular feature, structure, material or characteristic described by example is included in at least one embodiment or example of the present application. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and combine the different embodiments or examples described in this specification, as well as the features of the different embodiments or examples, without conflicting each other.
流程图中或在此以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现特定逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本申请的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本申请的实施例所属技术邻域的技术人员所理解。Any description of a process or method in the flowcharts or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing a specified logical function or step of the process , and the scope of the preferred embodiments of the present application includes alternative implementations in which the functions may be performed out of the order shown or discussed, including performing the functions substantially concurrently or in the reverse order depending upon the functions involved, which should It is understood by those skilled in the art to which the embodiments of the present application belong.
尽管上面已经示出和描述了本申请的实施方式,可以理解的是,上述实施方式是示例性的,不能理解为对本申请的限制,本邻域的普通技术人员在本申请的范围内可以对上述实施方式进行变化、修改、替换和变型。Although the embodiments of the present application have been shown and described above, it should be understood that the above-mentioned embodiments are exemplary and should not be construed as limitations on the present application. Variations, modifications, substitutions and alterations are made to the above-described embodiments.
Claims (12)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210369140.0A CN114723602B (en) | 2022-04-08 | 2022-04-08 | Image processing method, image processing device, terminal and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210369140.0A CN114723602B (en) | 2022-04-08 | 2022-04-08 | Image processing method, image processing device, terminal and readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114723602A true CN114723602A (en) | 2022-07-08 |
CN114723602B CN114723602B (en) | 2025-01-28 |
Family
ID=82241614
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210369140.0A Active CN114723602B (en) | 2022-04-08 | 2022-04-08 | Image processing method, image processing device, terminal and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114723602B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105957078A (en) * | 2016-04-27 | 2016-09-21 | 浙江万里学院 | Multi-view video segmentation method based on graph cut |
CN107886549A (en) * | 2017-10-18 | 2018-04-06 | 浙江工业大学之江学院 | A kind of dermatoglyphic pattern of the fabric color transfer method based on braiding grain details enhancing |
CN112509068A (en) * | 2020-10-29 | 2021-03-16 | 北京达佳互联信息技术有限公司 | Image dominant color recognition method and device, electronic equipment and storage medium |
CN114219733A (en) * | 2021-12-16 | 2022-03-22 | 上海幻电信息科技有限公司 | Image processing method and device |
-
2022
- 2022-04-08 CN CN202210369140.0A patent/CN114723602B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105957078A (en) * | 2016-04-27 | 2016-09-21 | 浙江万里学院 | Multi-view video segmentation method based on graph cut |
CN107886549A (en) * | 2017-10-18 | 2018-04-06 | 浙江工业大学之江学院 | A kind of dermatoglyphic pattern of the fabric color transfer method based on braiding grain details enhancing |
CN112509068A (en) * | 2020-10-29 | 2021-03-16 | 北京达佳互联信息技术有限公司 | Image dominant color recognition method and device, electronic equipment and storage medium |
CN114219733A (en) * | 2021-12-16 | 2022-03-22 | 上海幻电信息科技有限公司 | Image processing method and device |
Non-Patent Citations (1)
Title |
---|
黄诚;王国营;: "一种基于颜色聚合向量的图像检索方法", 计算机工程, 20 January 2006 (2006-01-20) * |
Also Published As
Publication number | Publication date |
---|---|
CN114723602B (en) | 2025-01-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR100658998B1 (en) | Image processing apparatus, image processing method and computer readable medium which records program thereof | |
CN100517316C (en) | Image file list display device | |
CN112069339B (en) | Background image processing and search result display method, device, equipment and medium | |
US20100080448A1 (en) | Method and graphical user interface for modifying depth maps | |
CN101360250B (en) | Immersion method and system, factor dominating method, content analysis method and parameter prediction method | |
US20060082574A1 (en) | Image processing program for 3D display, image processing apparatus, and 3D display system | |
US20090027732A1 (en) | Image processing apparatus, image processing method, and computer program | |
WO2023273111A1 (en) | Image processing method and apparatus, and computer device and storage medium | |
CN113129391B (en) | Multi-exposure fusion method based on multi-exposure image feature distribution weight | |
CN107274351A (en) | Image processing equipment, image processing system and image processing method | |
US8064716B2 (en) | Apparatus and methods for enhancing digital images | |
CN109104545A (en) | Image processing equipment, image processing method and image processing system | |
CA2674104C (en) | Method and graphical user interface for modifying depth maps | |
WO2022120799A1 (en) | Image processing method and apparatus, electronic device, and storage medium | |
CN114723602A (en) | Image processing method, image processing device, terminal and readable storage medium | |
JP2001056867A (en) | Image data processing apparatus, medium recording image data set, medium recording image data processing program, and image data processing method | |
TW201635796A (en) | Image processing apparatus and method | |
CN107454374A (en) | Image processing apparatus, image processing method and image processing system | |
CN108765502B (en) | A Color Appearance Acquisition Method in a Complex Environment | |
CN108305235A (en) | The method and device of plurality of pictures fusion | |
US7623724B2 (en) | Interface method and system for mapping image intensity | |
US9667709B2 (en) | Picture conversion SNS system and method, apparatus, and terminal | |
CN116703794B (en) | Multi-image fusion method in HSV color space | |
TW475157B (en) | Method for displaying image in cartoon-looking rendering | |
US7305126B2 (en) | Photo dazzle color temperature correction |
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 | ||
GR01 | Patent grant |