CN117671044A - Image processing method, device, electronic equipment and medium - Google Patents
Image processing method, device, electronic equipment and medium Download PDFInfo
- Publication number
- CN117671044A CN117671044A CN202311365170.5A CN202311365170A CN117671044A CN 117671044 A CN117671044 A CN 117671044A CN 202311365170 A CN202311365170 A CN 202311365170A CN 117671044 A CN117671044 A CN 117671044A
- Authority
- CN
- China
- Prior art keywords
- matrix
- singular
- image
- target
- target 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; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T9/00—Image coding
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Processing (AREA)
Abstract
Description
技术领域Technical field
本申请属于图像处理技术领域,尤其涉及一种图像处理方法、装置、电子设备及介质。The present application belongs to the field of image processing technology, and in particular, relates to an image processing method, device, electronic equipment and media.
背景技术Background technique
轻量级嵌入式图形库(Light and Versatile Graphics Library,LVGL)是一种开源的图形库,可以在实时操作系统(Real-Time Operating System,RTOS)上运行,支持多种显示器和控制器,提供了丰富的图形用户界面(GUI)组件和动画效果。轻量级嵌入式图形库通常使用自定义的图像格式来存储和显示图像。然而,其自定义的图像格式的图像占用较多的存储空间,限制了RTOS智能屏能够存储和显示的图像数量和种类,因此,需要对上述格式图像进行图像压缩。Lightweight embedded graphics library (Light and Versatile Graphics Library, LVGL) is an open source graphics library that can run on a real-time operating system (Real-Time Operating System, RTOS), supports a variety of displays and controllers, and provides Rich graphical user interface (GUI) components and animation effects. Lightweight embedded graphics libraries often use custom image formats to store and display images. However, the images in its custom image format take up a lot of storage space, which limits the number and types of images that the RTOS smart screen can store and display. Therefore, image compression is required for the images in the above formats.
现有技术通常是将图像中相同的多个索引值转化为一个数量值和索引值,以减少该图像的存储空间,图像压缩效率低下。The existing technology usually converts multiple identical index values in an image into a quantity value and an index value to reduce the storage space of the image, resulting in low image compression efficiency.
发明内容Contents of the invention
本申请实施例提供了一种图像处理方法、装置、电子设备及介质,提高了图像压缩效率。Embodiments of the present application provide an image processing method, device, electronic equipment and media, which improve image compression efficiency.
第一方面,本申请实施例提供了一种图像处理方法,包括:In a first aspect, embodiments of the present application provide an image processing method, including:
获取目标图像的属性信息和索引矩阵;Obtain the attribute information and index matrix of the target image;
对所述索引矩阵进行奇异值分解,得到所述目标图像对应的左奇异矩阵、右奇异矩阵以及对角矩阵;其中,所述对角矩阵的对角线上的各个元素的值均为所述索引矩阵的奇异值;Perform singular value decomposition on the index matrix to obtain the left singular matrix, the right singular matrix and the diagonal matrix corresponding to the target image; wherein the value of each element on the diagonal of the diagonal matrix is the Singular values of the index matrix;
根据所述属性信息确定奇异值数量阈值;Determine a singular value number threshold based on the attribute information;
根据所述奇异值数量阈值对所述对角矩阵、所述左奇异矩阵以及所述右奇异矩阵进行部分元素的置零操作,得到用于表示所述目标图像压缩后的数据的近似矩阵。Perform a zero-setting operation on some elements of the diagonal matrix, the left singular matrix, and the right singular matrix according to the singular value number threshold to obtain an approximate matrix used to represent the compressed data of the target image.
可选的,所述根据所述奇异值数量阈值对所述对角矩阵、所述左奇异矩阵以及所述右奇异矩阵进行部分元素的置零操作,得到用于表示所述目标图像压缩后的数据的近似矩阵,包括:Optionally, the diagonal matrix, the left singular matrix and the right singular matrix are zeroed on some elements according to the singular value number threshold to obtain a compressed representation of the target image. An approximate matrix of data, including:
对所述对角矩阵中的各个奇异值按照大小进行排序,得到奇异值顺序表;Sort each singular value in the diagonal matrix according to size to obtain a singular value sequence table;
按照从大到小的顺序从所述奇异值顺序表中,获取与所述奇异值数量阈值相等数量的多个目标奇异值;Obtain a number of target singular values equal to the singular value quantity threshold from the singular value sequence table in order from large to small;
根据所述多个目标奇异值,对所述对角矩阵、所述左奇异矩阵以及所述右奇异矩阵进行部分元素的置零操作,得到所述近似矩阵。According to the plurality of target singular values, a zero-setting operation is performed on some elements of the diagonal matrix, the left singular matrix and the right singular matrix to obtain the approximate matrix.
可选的,所述根据所述多个目标奇异值,对所述对角矩阵、所述左奇异矩阵以及所述右奇异矩阵进行部分元素的置零操作,得到所述近似矩阵,包括:Optionally, based on the plurality of target singular values, performing zero-setting operations on some elements of the diagonal matrix, the left singular matrix and the right singular matrix to obtain the approximate matrix, including:
将所述对角矩阵中除所述多个目标奇异值之外的其余奇异值置零,得到第一矩阵;Set the remaining singular values in the diagonal matrix except the plurality of target singular values to zero to obtain a first matrix;
将所述左奇异矩阵中与所述其余奇异值关联的奇异向量置零,得到第二矩阵;Set the singular vectors associated with the remaining singular values in the left singular matrix to zero to obtain a second matrix;
将所述右奇异矩阵中与所述其余奇异值关联的奇异向量置零,得到第三矩阵;Set the singular vectors associated with the remaining singular values in the right singular matrix to zero to obtain a third matrix;
将所述第一矩阵、所述第二矩阵以及所述第三矩阵确定为所述近似矩阵。The first matrix, the second matrix and the third matrix are determined as the approximation matrices.
可选的,所述属性信息包括图像分辨率,所述图像分辨率与所述奇异值数量阈值呈正相关。Optionally, the attribute information includes image resolution, and the image resolution is positively correlated with the singular value number threshold.
可选的,所述属性信息包括图像分辨率;所述根据所述属性信息确定奇异值数量阈值,包括:Optionally, the attribute information includes image resolution; and determining the singular value number threshold based on the attribute information includes:
获取所述目标图像的期望图像压缩比;Obtain the desired image compression ratio of the target image;
从预先构建的多个阈值确定表中,查找与所述期望图像压缩比对应的目标阈值确定表;其中,所述阈值确定表用于描述在任意一个图像压缩比下,不同图像分辨率与不同奇异值数量阈值之间的对应关系;From multiple pre-constructed threshold determination tables, search for a target threshold determination table corresponding to the desired image compression ratio; wherein, the threshold determination table is used to describe the difference between different image resolutions and different values under any image compression ratio. Correspondence between singular value number thresholds;
从所述目标阈值确定表中,查找与所述目标图像的图像分辨率对应的奇异值数量阈值。From the target threshold determination table, a singular value number threshold corresponding to the image resolution of the target image is found.
可选的,所述目标图像包括调色板;在所述根据所述奇异值数量阈值对所述对角矩阵、所述左奇异矩阵以及所述右奇异矩阵进行部分元素的置零操作,得到用于表示所述目标图像压缩后的数据的近似矩阵之后,还包括:Optionally, the target image includes a color palette; performing a zero-setting operation on some elements of the diagonal matrix, the left singular matrix and the right singular matrix according to the singular value number threshold, we obtain After the approximate matrix used to represent the compressed data of the target image, it also includes:
将所述调色板、所述奇异值数量阈值以及所述近似矩阵确定为与所述目标图像对应的压缩后的图像数据,并存储所述图像数据。The color palette, the singular value number threshold, and the approximation matrix are determined as compressed image data corresponding to the target image, and the image data is stored.
可选的,在所述将所述调色板、所述奇异值数量阈值以及所述近似矩阵确定为与所述目标图像对应的压缩后的图像数据,并存储所述图像数据之后,还包括:Optionally, after determining the color palette, the singular value number threshold and the approximation matrix as compressed image data corresponding to the target image and storing the image data, it further includes: :
获取所述图像数据;Obtain the image data;
根据所述奇异值数量阈值和所述近似矩阵进行矩阵重构,得到所述目标图像的索引矩阵;Perform matrix reconstruction according to the singular value number threshold and the approximation matrix to obtain the index matrix of the target image;
根据所述索引矩阵和所述调色板生成所述目标图像,并显示所述目标图像。The target image is generated according to the index matrix and the color palette, and the target image is displayed.
第二方面,本申请实施例提供了一种图像处理装置,包括:In a second aspect, embodiments of the present application provide an image processing device, including:
第一获取单元,用于获取目标图像的属性信息和索引矩阵;The first acquisition unit is used to acquire the attribute information and index matrix of the target image;
分解单元,用于对所述索引矩阵进行奇异值分解,得到所述目标图像对应的左奇异矩阵、右奇异矩阵以及对角矩阵;其中,所述对角矩阵的对角线上的各个元素的值均为所述索引矩阵的奇异值;A decomposition unit configured to perform singular value decomposition on the index matrix to obtain the left singular matrix, the right singular matrix and the diagonal matrix corresponding to the target image; wherein, the values of each element on the diagonal line of the diagonal matrix The values are all singular values of the index matrix;
第一确定单元,用于根据所述属性信息确定奇异值数量阈值;A first determination unit configured to determine a singular value quantity threshold based on the attribute information;
第一置零单元,用于根据所述奇异值数量阈值对所述对角矩阵、所述左奇异矩阵以及所述右奇异矩阵进行部分元素的置零操作,得到用于表示所述目标图像压缩后的数据的近似矩阵。The first zero-setting unit is configured to perform a zero-setting operation on some elements of the diagonal matrix, the left singular matrix and the right singular matrix according to the singular value quantity threshold to obtain a compression representation of the target image. Approximate matrix of the subsequent data.
第三方面,本申请实施例提供了一种电子设备,包括:存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,上述处理器执行所述计算机程序时实现如上述第一方面中任一项所述的图像处理方法。In a third aspect, embodiments of the present application provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program Implement the image processing method as described in any one of the above first aspects.
第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现如上述第一方面中任一项所述的图像处理方法。In a fourth aspect, embodiments of the present application provide a computer-readable storage medium that stores a computer program. When the computer program is executed by a processor, the computer program implements any of the above-described first aspects. The image processing method described above.
第五方面,本申请实施例提供了一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备可执行上述第一方面中任一项所述的图像处理方法。In a fifth aspect, embodiments of the present application provide a computer program product. When the computer program product is run on an electronic device, the electronic device can execute the image processing method described in any one of the above first aspects.
本申请实施例与现有技术相比存在的有益效果是:Compared with the prior art, the beneficial effects of the embodiments of the present application are:
本申请实施例提供的一种图像处理方法,通过获取目标图像的属性信息和索引矩阵;对索引矩阵进行奇异值分解,得到目标图像对应的左奇异矩阵、右奇异矩阵以及对角矩阵;其中,对角矩阵的对角线上的各个元素的值均为索引矩阵的奇异值;根据属性信息确定奇异值数量阈值;根据奇异值数量阈值对对角矩阵、左奇异矩阵以及右奇异矩阵进行部分元素的置零操作,得到用于表示目标图像压缩后的数据的近似矩阵。与现有技术相比,本方法通过对目标图像的索引矩阵的奇异值分解,提高了压缩效率。同时,根据图像的属性信息可以准确确定与该图像相匹配的奇异值数量阈值,以使在对目标对象进行压缩时可以保证图像质量。An image processing method provided by an embodiment of the present application obtains the attribute information and index matrix of the target image; performs singular value decomposition on the index matrix to obtain the left singular matrix, right singular matrix and diagonal matrix corresponding to the target image; wherein, The value of each element on the diagonal of the diagonal matrix is the singular value of the index matrix; determine the singular value number threshold based on the attribute information; select some elements of the diagonal matrix, left singular matrix, and right singular matrix based on the singular value threshold. The zero-setting operation obtains an approximate matrix used to represent the compressed data of the target image. Compared with the existing technology, this method improves compression efficiency through singular value decomposition of the index matrix of the target image. At the same time, the threshold of the number of singular values matching the image can be accurately determined according to the attribute information of the image, so that the image quality can be guaranteed when compressing the target object.
附图说明Description of drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only for the purpose of the present application. For some embodiments, for those of ordinary skill in the art, other drawings can be obtained based on these drawings without exerting creative efforts.
图1是本申请一实施例提供的图像处理方法的实现流程图;Figure 1 is an implementation flow chart of an image processing method provided by an embodiment of the present application;
图2是本申请另一实施例提供的图像处理方法的实现流程图;Figure 2 is an implementation flow chart of an image processing method provided by another embodiment of the present application;
图3是本申请再一实施例提供的图像处理方法的实现流程图;Figure 3 is an implementation flow chart of an image processing method provided by yet another embodiment of the present application;
图4是本申请又一实施例提供的图像处理方法的实现流程图;Figure 4 is an implementation flow chart of an image processing method provided by yet another embodiment of the present application;
图5是本申请一实施例提供的图像处理装置的结构示意图;Figure 5 is a schematic structural diagram of an image processing device provided by an embodiment of the present application;
图6是本申请一实施例提供的电子设备的结构示意图。FIG. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本申请实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本申请。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本申请的描述。In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures and technologies are provided to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be practiced in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
应当理解,当在本申请说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It will be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements and/or components but does not exclude one or more other The presence or addition of features, integers, steps, operations, elements, components and/or collections thereof.
还应当理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。It will also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
如在本申请说明书和所附权利要求书中所使用的那样,术语“如果”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。类似地,短语“如果确定”或“如果检测到[所描述条件或事件]”可以依据上下文被解释为意指“一旦确定”或“响应于确定”或“一旦检测到[所描述条件或事件]”或“响应于检测到[所描述条件或事件]”。As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "once" or "in response to determining" or "in response to detecting" depending on the context. ". Similarly, the phrase "if determined" or "if [the described condition or event] is detected" may be interpreted, depending on the context, to mean "once determined" or "in response to a determination" or "once the [described condition or event] is detected ]" or "in response to detection of [the described condition or event]".
另外,在本申请说明书和所附权利要求书的描述中,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。In addition, in the description of this application and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.
在本申请说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。Reference in this specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Therefore, the phrases "in one embodiment", "in some embodiments", "in other embodiments", "in other embodiments", etc. appearing in different places in this specification are not necessarily References are made to the same embodiment, but rather to "one or more but not all embodiments" unless specifically stated otherwise. The terms “including,” “includes,” “having,” and variations thereof all mean “including but not limited to,” unless otherwise specifically emphasized.
在实际应用中,轻量级嵌入式图形库(Light and Versatile Graphics Library,LVGL)是一种开源的图形库,可以在实时操作系统(Real-Time Operating System,RTOS)上运行,支持多种显示器和控制器,提供了丰富的图形用户界面(GUI)组件和动画效果。轻量级嵌入式图形库通常使用自定义的图像格式来存储和显示图像。然而,其自定义的图像格式,如LV_IMG_CF_INDEXED_8BIT格式的图像占用较多的存储空间,限制了RTOS智能屏能够存储和显示的图像数量和种类,因此,需要对上述格式图像进行图像压缩。In practical applications, the Lightweight Embedded Graphics Library (LVGL) is an open source graphics library that can run on a Real-Time Operating System (RTOS) and supports a variety of displays. and controller, providing rich graphical user interface (GUI) components and animation effects. Lightweight embedded graphics libraries often use custom image formats to store and display images. However, its custom image formats, such as LV_IMG_CF_INDEXED_8BIT format images, occupy more storage space and limit the number and types of images that the RTOS smart screen can store and display. Therefore, image compression of the above format images is required.
然而,现有的基于奇异值分解(Singular Value Decomposition,SVD)的图像压缩方法通常是针对灰度图像或彩色图像(RGB),而不适用于LV_IMG_CF_INDEXED_8BIT格式的图像,因为LV_IMG_CF_INDEXED_8BIT格式的图像包含了调色板,无法直接进行奇异值分解。However, existing image compression methods based on singular value decomposition (SVD) are usually aimed at grayscale images or color images (RGB), and are not suitable for images in the LV_IMG_CF_INDEXED_8BIT format, because the images in the LV_IMG_CF_INDEXED_8BIT format contain modulation Color palette, singular value decomposition cannot be performed directly.
需要说明的是,LV_IMG_CF_INDEXED_8BIT格式为LVGL图形库支持的一种索引色彩格式,每个像素占用8位,即一个字节1,该格式的图像包括调色板和索引矩阵。其中,调色板指调色板矩阵,为图像颜色表。It should be noted that the LV_IMG_CF_INDEXED_8BIT format is an indexed color format supported by the LVGL graphics library. Each pixel occupies 8 bits, that is, one byte. The image in this format includes a palette and an index matrix. Among them, the palette refers to the palette matrix, which is the image color table.
基于此,本申请实施例提供了一种应用于无法直接进行奇异值分解的图像格式,如LV_IMG_CF_INDEXED_8BIT格式的图像压缩方法,详细说明请参阅下图所示的实施例,在此不加以赘述。Based on this, the embodiment of the present application provides an image compression method that is applied to image formats that cannot directly perform singular value decomposition, such as the LV_IMG_CF_INDEXED_8BIT format. For detailed description, please refer to the embodiment shown in the figure below, which will not be described again here.
请参阅图1,图1是本申请一实施例提供的图像处理方法的实现流程图。本申请实施例中,该图像处理方法的执行主体为电子设备。其中,电子设备可以是RTOS智能屏。Please refer to FIG. 1 , which is an implementation flow chart of an image processing method provided by an embodiment of the present application. In the embodiment of the present application, the execution subject of the image processing method is an electronic device. Among them, the electronic device may be an RTOS smart screen.
如图1所示,本申请一实施例提供的图像处理方法可以包括S101~S104,详述如下:As shown in Figure 1, the image processing method provided by an embodiment of the present application may include S101 to S104, which are detailed as follows:
在S101中,获取目标图像的属性信息和索引矩阵。In S101, obtain the attribute information and index matrix of the target image.
在实际应用中,为了减少图像占用的存储空间,用户可以触发针对电子设备的图像处理请求。In practical applications, in order to reduce the storage space occupied by images, users can trigger image processing requests for electronic devices.
本申请实施例中,电子设备检测到上述图像处理请求可以是:检测到用户触发针对电子设备的第一预设操作。其中,第一预设操作可以根据实际需要确定,此处不作限制。示例性的,第一预设操作可以是点击第一预设控件,即电子设备若检测到用户点击电子设备上的第一预设控件,则认为检测到了针对电子设备的第一预设操作;当然,该第一预设操作也可以是一个时间触发操作,电子设备在运行时可以配置有相应的工作流程,该工作流程包含有多个关键事件的触发节点,上述关键事件包括对目标图像进行图像压缩的事件,在该情况下,若电子设备检测到达对目标图像进行图像压缩的事件关联的触发节点,则执行S101~S104的操作,以执行对目标图像的压缩操作。其中,目标图像指需要进行图像压缩的图像。In this embodiment of the present application, when the electronic device detects the above image processing request, it may be: detecting that the user triggers the first preset operation for the electronic device. The first preset operation can be determined according to actual needs and is not limited here. For example, the first preset operation may be clicking on the first preset control. That is, if the electronic device detects that the user clicks on the first preset control on the electronic device, it is considered that the first preset operation for the electronic device is detected; Of course, the first preset operation can also be a time-triggered operation. The electronic device can be configured with a corresponding workflow when running. The workflow includes trigger nodes for multiple key events. The key events include performing operations on the target image. Image compression event. In this case, if the electronic device detects that the trigger node associated with the event of image compression of the target image has been reached, the operations of S101 to S104 are performed to perform the compression operation of the target image. Among them, the target image refers to the image that needs to be compressed.
在一些可能的实施例中,目标图像可以是图像格式为LV_IMG_CF_INDEXED_8BIT格式的图像。In some possible embodiments, the target image may be an image in the LV_IMG_CF_INDEXED_8BIT format.
本申请实施例中,电子设备在检测到上述图像处理请求后,可以获取目标图像,并确定目标图像的属性信息和索引矩阵。其中,目标图像的属性信息包括但不限于目标图像的分辨率。In the embodiment of the present application, after detecting the above image processing request, the electronic device can obtain the target image and determine the attribute information and index matrix of the target image. The attribute information of the target image includes but is not limited to the resolution of the target image.
在S102中,对所述索引矩阵进行奇异值分解,得到所述目标图像对应的左奇异矩阵、右奇异矩阵以及对角矩阵;其中,所述对角矩阵的对角线上的各个元素的值均为所述索引矩阵的奇异值。In S102, perform singular value decomposition on the index matrix to obtain the left singular matrix, the right singular matrix and the diagonal matrix corresponding to the target image; wherein, the values of each element on the diagonal of the diagonal matrix are all singular values of the index matrix.
本申请实施例中,电子设备在得到目标图像的索引矩阵后,可以对该索引矩阵进行奇异值分解,得到目标图像的索引矩阵对应的左奇异矩阵、右奇异矩阵以及对角矩阵。In the embodiment of the present application, after obtaining the index matrix of the target image, the electronic device can perform singular value decomposition on the index matrix to obtain the left singular matrix, the right singular matrix and the diagonal matrix corresponding to the index matrix of the target image.
需要说明的是,对角矩阵的对角线上的各个元素的值均为索引矩阵的奇异值。因此,对角矩阵也被称为奇异值矩阵。It should be noted that the values of each element on the diagonal of the diagonal matrix are singular values of the index matrix. Therefore, the diagonal matrix is also called a singular value matrix.
示例性的,以索引矩阵为m行n列的矩阵A为例,对该矩阵A进行奇异值分解,得到矩阵U(即左奇异矩阵)、矩阵S(即对角矩阵)以及矩阵V(即右奇异矩阵),以使A=USVH。For example, taking the matrix A whose index matrix is m rows and n columns as an example, perform singular value decomposition on the matrix A to obtain the matrix U (i.e., left singular matrix), matrix S (i.e., diagonal matrix), and matrix V (i.e., Right singular matrix), so that A = USV H .
请参阅表1,表1是对矩阵A分解后的左奇异矩阵、右奇异矩阵以及对角矩阵的详细说明。Please refer to Table 1, which is a detailed description of the left singular matrix, right singular matrix and diagonal matrix after decomposition of matrix A.
表1Table 1
在S103中,根据所述属性信息确定奇异值数量阈值。In S103, a singular value number threshold is determined based on the attribute information.
需要说明的是,奇异值数量阈值用于表征对角矩阵中保留的奇异值的最大数量,可以根据实际需要设置,此处不作限制。It should be noted that the singular value number threshold is used to characterize the maximum number of singular values retained in the diagonal matrix, and can be set according to actual needs, and is not limited here.
属性信息包括图像分辨率。Attribute information includes image resolution.
在本申请的一个实施例中,电子设备预先存储有不同图像分辨率与奇异值数量阈值之间的对应关系,因此,电子设备在获取到目标图像的图像分辨率后,可以根据目标图像的图像分辨率以及上述对应关系,确定目标图像的图像分辨率对应的奇异值数量阈值。In one embodiment of the present application, the electronic device pre-stores the corresponding relationship between different image resolutions and singular value number thresholds. Therefore, after acquiring the image resolution of the target image, the electronic device can The resolution and the above correspondence relationship determine the singular value number threshold corresponding to the image resolution of the target image.
本实施例中,不同图像分辨率对应的奇异值数量阈值不完全相同。In this embodiment, the singular value number thresholds corresponding to different image resolutions are not exactly the same.
在一些可能的实施例中,图像分辨率与奇异值数量阈值呈正相关,即图像分辨率越大,奇异值数量阈值越大,图像分辨率越小,奇异值数量阈值越小。In some possible embodiments, the image resolution is positively correlated with the singular value number threshold, that is, the larger the image resolution, the larger the singular value number threshold, and the smaller the image resolution, the smaller the singular value number threshold.
在本申请的另一个实施例中,电子设备在得到目标图像的图像分辨率后,可以根据该图像分辨率的大小确定图像等级。其中,图像等级包括但不限于第一等级、第二等级以及第三等级。In another embodiment of the present application, after obtaining the image resolution of the target image, the electronic device can determine the image level according to the size of the image resolution. The image levels include but are not limited to first level, second level and third level.
第一等级的图像分辨率的取值范围为(0,第一分辨率阈值),第二等级的图像分辨率的取值范围为[第一分辨率阈值,第二分辨率阈值),第三等级的图像分辨率的取值范围为[第二分辨率阈值,+∞)。The value range of the first level of image resolution is (0, first resolution threshold), the value range of the second level of image resolution is [first resolution threshold, second resolution threshold), and the value range of the third level of image resolution is [first resolution threshold, second resolution threshold] The value range of the image resolution of the level is [second resolution threshold, +∞).
本实施例中,电子设备在检测到目标图像的图像分辨率的大小小于第一分辨率阈值时,可以确定目标图像的图像等级为第一等级;电子设备在检测到目标图像的图像分辨率的大小大于或等于第一分辨率阈值,且小于第二分辨率阈值时,可以确定目标图像的图像等级为第二等级;电子设备在检测到目标图像的图像分辨率的大小大于或等于第二分辨率阈值时,可以确定目标图像的图像等级为第三等级。In this embodiment, when the electronic device detects that the image resolution of the target image is smaller than the first resolution threshold, it can determine that the image level of the target image is the first level; when the electronic device detects that the image resolution of the target image is smaller than the first resolution threshold, When the size is greater than or equal to the first resolution threshold and less than the second resolution threshold, the image level of the target image can be determined to be the second level; when the electronic device detects that the size of the image resolution of the target image is greater than or equal to the second resolution When the rate threshold is set, it can be determined that the image level of the target image is the third level.
本实施例中,奇异值数量阈值包括但不限于:第一数量阈值、第二数量阈值以及第三数量阈值。其中,第一数量阈值小于第二数量阈值,第二数量阈值小于第三数量阈值。In this embodiment, the singular value quantity thresholds include but are not limited to: a first quantity threshold, a second quantity threshold, and a third quantity threshold. Wherein, the first quantity threshold is smaller than the second quantity threshold, and the second quantity threshold is smaller than the third quantity threshold.
在本实施例的一种实现方式中,电子设备可以设置第一等级对应的奇异值数量阈值为第一数量阈值,电子设备可以设置第二等级对应的奇异值数量阈值为第二数量阈值,电子设备可以设置第三等级对应的奇异值数量阈值为第三数量阈值,从而得到不同图像等级与奇异值数量阈值之间的对应关系。In an implementation manner of this embodiment, the electronic device can set the number threshold of singular values corresponding to the first level as the first number threshold, and the electronic device can set the number threshold of singular values corresponding to the second level as the second number threshold. The device can set the singular value quantity threshold corresponding to the third level to the third quantity threshold, thereby obtaining the corresponding relationship between different image levels and the singular value quantity threshold.
基于此,本实施例中,电子设备在确定目标图像的图像等级后,可以根据上述目标图像的图像等级,以及不同图像等级与奇异值数量阈值之间的对应关系,确定目标图像对应的奇异值数量阈值。Based on this, in this embodiment, after determining the image level of the target image, the electronic device can determine the singular values corresponding to the target image based on the image level of the target image and the correspondence between different image levels and the singular value number threshold. Quantity threshold.
在本申请的再一个实施例中,为了进一步提高对奇异值数量阈值的确定准确率,电子设备具体可以通过如图2所示的步骤S201~S203确定奇异值数量阈值,详述如下:In yet another embodiment of the present application, in order to further improve the accuracy of determining the singular value threshold, the electronic device can specifically determine the singular value threshold through steps S201 to S203 as shown in Figure 2, as detailed below:
在S201中,获取所述目标图像的期望图像压缩比。In S201, obtain the desired image compression ratio of the target image.
本实施例中,图像压缩比指通过编码器压缩后的图像数据大小和原始图像数据大小的压缩比。其中,原始图像指未经过任何处理的图像。In this embodiment, the image compression ratio refers to the compression ratio between the size of the image data compressed by the encoder and the size of the original image data. Among them, the original image refers to the image without any processing.
在本实施例的一种实现方式中,电子设备可以通过与其无线通信连接的终端设备实时获取到用户所需的期望图像压缩比。其中,终端设备可以是用户使用的智能手机、笔记本或者计算机等设备。In an implementation manner of this embodiment, the electronic device can obtain the desired image compression ratio required by the user in real time through the terminal device connected to the electronic device through wireless communication. Among them, the terminal device may be a smartphone, notebook, computer or other device used by the user.
在本实施例的另一种实现方式中,用户可以在电子设备的显示界面上输入目标图像的期望图像压缩比,以使电子设备获取到该期望图像压缩比。In another implementation of this embodiment, the user can input the desired image compression ratio of the target image on the display interface of the electronic device, so that the electronic device obtains the desired image compression ratio.
在S202中,从预先构建的多个阈值确定表中,查找与所述期望图像压缩比对应的目标阈值确定表;其中,所述阈值确定表用于描述在任意一个图像压缩比下,不同图像分辨率与不同奇异值数量阈值之间的对应关系。In S202, search for a target threshold determination table corresponding to the desired image compression ratio from a plurality of pre-constructed threshold determination tables; wherein the threshold determination table is used to describe different images under any image compression ratio. Correspondence between resolution and different singular value number thresholds.
本实施例中,电子设备在获取到目标图像的期望图像压缩比,可以从预先构建的多个阈值确定表中查找与该期望图像压缩比对应的目标阈值确定表。In this embodiment, after obtaining the desired image compression ratio of the target image, the electronic device can search for a target threshold determination table corresponding to the desired image compression ratio from a plurality of pre-constructed threshold determination tables.
在一些可能的实施例中,不同阈值确定表其对应的图像压缩比范围不同,因此,电子设备可以确定期望图像压缩比所处的图像压缩比范围,并将与该图像压缩比范围对应的阈值确定表确定为目标阈值确定表。In some possible embodiments, different threshold determination tables have different corresponding image compression ratio ranges. Therefore, the electronic device can determine the image compression ratio range in which the desired image compression ratio is located, and set the threshold value corresponding to the image compression ratio range. The determination table is determined as a target threshold determination table.
示例性的,假设阈值确定表包括第一确定表、第二确定表以及第三确定表,第一确定表对应的图像压缩比范围为(0,2],第二确定表对应的图像压缩比范围为(2,4],第一确定表对应的图像压缩比范围为(4,6],期望图像压缩比为3.5,则电子设备可以确定期望图像压缩比对应的图像压缩比范围为(2,4],因此,电子设备可以将第二确定表确定为目标阈值确定表。For example, assume that the threshold determination table includes a first determination table, a second determination table, and a third determination table. The image compression ratio range corresponding to the first determination table is (0, 2], and the image compression ratio corresponding to the second determination table is The range is (2, 4], the image compression ratio range corresponding to the first determination table is (4, 6], and the expected image compression ratio is 3.5, then the electronic device can determine that the image compression ratio range corresponding to the expected image compression ratio is (2 , 4], therefore, the electronic device can determine the second determination table as the target threshold determination table.
在S203中,从所述目标阈值确定表中,查找与所述目标图像的图像分辨率对应的奇异值数量阈值。In S203, search for the singular value number threshold corresponding to the image resolution of the target image from the target threshold determination table.
本实施例中,电子设备在得到目标阈值确定表后,可以根据目标图像的图像分辨率,从该目标阈值确定表中查找与该目标图像的图像分辨率对应的奇异值数量阈值。In this embodiment, after obtaining the target threshold determination table, the electronic device can search the singular value number threshold corresponding to the image resolution of the target image from the target threshold determination table according to the image resolution of the target image.
在S104中,根据所述奇异值数量阈值对所述对角矩阵、所述左奇异矩阵以及所述右奇异矩阵进行部分元素的置零操作,得到用于表示所述目标图像压缩后的数据的近似矩阵。In S104, a zero-setting operation is performed on some elements of the diagonal matrix, the left singular matrix, and the right singular matrix according to the singular value number threshold to obtain a value representing the compressed data of the target image. Approximate matrix.
本申请实施例中,电子设备在得到奇异值数量阈值后,可以根据该奇异值数量阈值对对角矩阵、左奇异矩阵以及右奇异矩阵中的所有元素进行筛选,保留与奇异值数量阈值相等数量的目标元素,并将除目标元素之外的其它元素均置零,从而实现对目标图像的降维和压缩,并得到用于表示目标图像压缩后的数据的近似矩阵。In the embodiment of the present application, after obtaining the singular value quantity threshold, the electronic device can filter all elements in the diagonal matrix, the left singular matrix, and the right singular matrix according to the singular value quantity threshold, and retain a number equal to the singular value quantity threshold. The target element, and all other elements except the target element are set to zero, thereby achieving dimensionality reduction and compression of the target image, and obtaining an approximate matrix used to represent the compressed data of the target image.
在本申请的一个实施例中,电子设备可以分别对对角矩阵、左奇异矩阵以及右奇异矩阵中的所有元素进行编号,如编号1、编号2、···编号n等,之后,电子设备可以基于随机函数从上述多个编号中确定需要保留的目标编号,直至目标编号的数量等于奇异值数量阈值。其中,随机函数可以是rand()函数。In one embodiment of the present application, the electronic device can number all elements in the diagonal matrix, the left singular matrix, and the right singular matrix respectively, such as number 1, number 2,... number n, etc., and then the electronic device The target number that needs to be retained can be determined from the above multiple numbers based on a random function until the number of target numbers equals the singular value number threshold. Among them, the random function can be the rand() function.
在本申请的另一个实施例中,为了在保证目标图像的图像压缩率的同时,保证图像压缩质量,电子设备具体可以通过如图3所示的步骤S301~S303对目标图像进行压缩,得到近似矩阵,详述如下:In another embodiment of the present application, in order to ensure the image compression quality while ensuring the image compression rate of the target image, the electronic device can specifically compress the target image through steps S301 to S303 as shown in Figure 3 to obtain an approximate matrix, detailed below:
在S301中,对所述对角矩阵中的各个奇异值按照大小进行排序,得到奇异值顺序表。In S301, each singular value in the diagonal matrix is sorted according to size to obtain a singular value sequence table.
在S302中,按照从大到小的顺序从所述奇异值顺序表中,获取与所述奇异值数量阈值相等数量的多个目标奇异值。In S302, obtain a plurality of target singular values equal to the singular value quantity threshold from the singular value sequence table in order from large to small.
在S303中,根据所述多个目标奇异值,对所述对角矩阵、所述左奇异矩阵以及所述右奇异矩阵进行部分元素的置零操作,得到所述近似矩阵。In S303, based on the plurality of target singular values, a zero-setting operation is performed on some elements of the diagonal matrix, the left singular matrix, and the right singular matrix to obtain the approximate matrix.
本实施例中,电子设备在得到奇异值顺序表后,可以按照从大到小的顺序从该奇异值顺序表中依次获取多个目标奇异值,直至目标奇异值的数量等于奇异值数量阈值,也就是说,电子设备获取到的多个目标奇异值,为奇异值顺序表中按照从大到小的顺序排在前奇异值数量阈值的奇异值。In this embodiment, after obtaining the singular value sequence table, the electronic device can sequentially obtain multiple target singular values from the singular value sequence table in order from large to small, until the number of target singular values is equal to the singular value quantity threshold, That is to say, the multiple target singular values acquired by the electronic device are the singular values ranked in order from large to small in the singular value sequence table with the singular value number threshold in front.
在本申请的一个实施例中,电子设备具体可以通过以下步骤得到近似矩阵,详述如下:In one embodiment of the present application, the electronic device can obtain the approximate matrix through the following steps, as detailed below:
将所述对角矩阵中除所述多个目标奇异值之外的其余奇异值置零,得到第一矩阵;Set the remaining singular values in the diagonal matrix except the plurality of target singular values to zero to obtain a first matrix;
将所述左奇异矩阵中与所述其余奇异值关联的奇异向量置零,得到第二矩阵;Set the singular vectors associated with the remaining singular values in the left singular matrix to zero to obtain a second matrix;
将所述右奇异矩阵中与所述其余奇异值关联的奇异向量置零,得到第三矩阵;Set the singular vectors associated with the remaining singular values in the right singular matrix to zero to obtain a third matrix;
将所述第一矩阵、所述第二矩阵以及所述第三矩阵确定为所述近似矩阵。The first matrix, the second matrix and the third matrix are determined as the approximation matrices.
本实施例中,电子设备可以将对角矩阵中的多个目标奇异值保留,并将除该多个目标奇异值之外的其它奇异值均置零,以得到对角矩阵对应的第一矩阵。In this embodiment, the electronic device can retain multiple target singular values in the diagonal matrix, and set other singular values except the multiple target singular values to zero to obtain the first matrix corresponding to the diagonal matrix. .
电子设备可以将左奇异矩阵中的分别与各个目标奇异值关联的奇异向量保留,并将除该多个目标奇异向量之外的其它奇异向量均置零,即将其余奇异值各自关联的奇异向量均置零,以得到左奇异矩阵对应的第二矩阵。The electronic device can retain the singular vectors in the left singular matrix that are respectively associated with each target singular value, and set all other singular vectors except the multiple target singular vectors to zero, that is, the singular vectors associated with the remaining singular values are all zeroed. Set to zero to obtain the second matrix corresponding to the left singular matrix.
电子设备可以将右奇异矩阵中的分别与各个目标奇异值关联的奇异向量保留,并将除该多个目标奇异向量之外的其它奇异向量均置零,即将其余奇异值各自关联的奇异向量均置零,以得到右奇异矩阵对应的第三矩阵。The electronic device can retain the singular vectors in the right singular matrix that are respectively associated with each target singular value, and set all other singular vectors except the multiple target singular vectors to zero, that is, the singular vectors associated with the remaining singular values are all equal to zero. Set to zero to obtain the third matrix corresponding to the right singular matrix.
示例性的,以索引矩阵为m行n列的矩阵A为例,假设矩阵A进行奇异值分解的展开形式为:For example, taking the matrix A whose index matrix is m rows and n columns, assume that the expansion form of matrix A through singular value decomposition is:
其中,A表示索引矩阵,ui表示左奇异矩阵中的第i个m维奇异向量,σi表示对角矩阵中的第i个奇异值,表示右奇异矩阵中的第i个n维奇异向量。Among them, A represents the index matrix, u i represents the i-th m-dimensional singular vector in the left singular matrix, σ i represents the i-th singular value in the diagonal matrix, Represents the i-th n-dimensional singular vector in the right singular matrix.
假设奇异值数量阈值为K,则近似矩阵为:Assuming that the threshold of the number of singular values is K, the approximate matrix is:
其中,A表示索引矩阵,ui表示左奇异矩阵中的第j个m维奇异向量,σi表示对角矩阵中的第j个奇异值,vi H表示右奇异矩阵中的第j个n维奇异向量,K<r。Among them, A represents the index matrix, u i represents the j-th m-dimensional singular vector in the left singular matrix, σ i represents the j-th singular value in the diagonal matrix, and v i H represents the j-th n in the right singular matrix. Dimensional singular vector, K<r.
基于此,电子设备可以将第一矩阵、第二矩阵以及第三矩阵确定为近似矩阵。Based on this, the electronic device may determine the first matrix, the second matrix, and the third matrix as approximate matrices.
以上可以看出,本申请实施例提供的一种图像处理方法,通过获取目标图像的属性信息和索引矩阵;对索引矩阵进行奇异值分解,得到目标图像对应的左奇异矩阵、右奇异矩阵以及对角矩阵;其中,对角矩阵的对角线上的各个元素的值均为索引矩阵的奇异值;根据属性信息确定奇异值数量阈值;根据奇异值数量阈值对对角矩阵、左奇异矩阵以及右奇异矩阵进行部分元素的置零操作,得到用于表示目标图像压缩后的数据的近似矩阵。与现有技术相比,本方法通过对目标图像的索引矩阵的奇异值分解,提高了压缩效率。同时,根据图像的属性信息可以准确确定与该图像相匹配的奇异值数量阈值,以使在对目标对象进行压缩时可以保证图像质量。As can be seen from the above, the image processing method provided by the embodiment of the present application obtains the attribute information and index matrix of the target image; performs singular value decomposition on the index matrix to obtain the left singular matrix, right singular matrix and pair corresponding to the target image. Angular matrix; where the value of each element on the diagonal of the diagonal matrix is the singular value of the index matrix; determine the singular value number threshold based on the attribute information; calculate the diagonal matrix, left singular matrix, and right singular matrix based on the singular value threshold. The singular matrix performs a zero-setting operation on some elements to obtain an approximate matrix used to represent the compressed data of the target image. Compared with the existing technology, this method improves compression efficiency through singular value decomposition of the index matrix of the target image. At the same time, the threshold of the number of singular values matching the image can be accurately determined according to the attribute information of the image, so that the image quality can be guaranteed when compressing the target object.
在本申请的一个实施例中,电子设备在得到近似矩阵后,电子设备可以将目标图像的调色板、奇异值数量阈值以及该近似矩阵确定为与目标图像对应的压缩后的图像数据,并存储图像数据,以便后续对目标图像的其它操作。In one embodiment of the present application, after the electronic device obtains the approximation matrix, the electronic device can determine the palette of the target image, the singular value number threshold, and the approximation matrix as compressed image data corresponding to the target image, and Store image data for subsequent operations on the target image.
本实施例中,电子设备可以将上述图像数据存储至自身存储器中。In this embodiment, the electronic device can store the above image data in its own memory.
基于此,请参阅图4,图4是本申请另一实施例提供的图像处理方法。本实施例在存储图像数据之后,为了显示该目标图像,本实施例还可以包括S401~S403,详述如下:Based on this, please refer to Figure 4, which is an image processing method provided by another embodiment of the present application. In this embodiment, after storing the image data, in order to display the target image, this embodiment may also include S401 to S403, which are detailed as follows:
在S401中,获取所述图像数据。In S401, the image data is obtained.
在S402中,根据所述奇异值数量阈值和所述近似矩阵进行矩阵重构,得到所述目标图像的索引矩阵。In S402, matrix reconstruction is performed according to the singular value number threshold and the approximation matrix to obtain an index matrix of the target image.
在S403中,根据所述索引矩阵和所述调色板生成所述目标图像,并显示所述目标图像。In S403, the target image is generated according to the index matrix and the palette, and the target image is displayed.
在实际应用中,当用户需要电子设备显示目标图像时,用户可以触发针对电子设备的图像显示请求。In practical applications, when the user needs the electronic device to display a target image, the user can trigger an image display request for the electronic device.
本实施例中,电子设备检测到上述图像显示请求可以是:检测到用户触发针对电子设备的第二预设操作。其中,第二预设操作可以根据实际需要确定,此处不作限制。示例性的,第二预设操作可以是点击第二预设控件,即电子设备若检测到用户点击电子设备上的第二预设控件,则认为检测到了针对电子设备的第二预设操作,即检测到图像显示请求。In this embodiment, the electronic device detecting the above image display request may be: detecting that the user triggers a second preset operation for the electronic device. The second preset operation can be determined according to actual needs and is not limited here. For example, the second preset operation may be clicking on the second preset control. That is, if the electronic device detects that the user clicks on the second preset control on the electronic device, it is considered to have detected the second preset operation for the electronic device. That is, an image display request is detected.
电子设备在检测到图像显示请求后,由于目标图像已被压缩,因此,为了保证电子设备可以完整显示目标图像,电子设备可以从自身的存储器中获取到目标图像对应的压缩后的图像数据。After the electronic device detects the image display request, since the target image has been compressed, in order to ensure that the electronic device can completely display the target image, the electronic device can obtain the compressed image data corresponding to the target image from its own memory.
电子设备可以根据图像数据中的奇异值数量阈值和近似矩阵进行矩阵重构,以得到目标图像的索引矩阵的近似表示。The electronic device can perform matrix reconstruction based on the singular value number threshold and the approximate matrix in the image data to obtain an approximate representation of the index matrix of the target image.
之后,电子设备可以根据图像数据中的调色板以及目标图像的索引矩阵的近似表示生成目标图像,并显示该目标图像。Afterwards, the electronic device may generate a target image based on the color palette in the image data and an approximate representation of the index matrix of the target image, and display the target image.
以上可以看出,本实施例提供的图像处理方法,获取图像数据;根据奇异值数量阈值和近似矩阵进行矩阵重构,得到目标图像的索引矩阵;根据索引矩阵和调色板生成目标图像,并输出目标图像。本实施例提供的方法在对目标图像进行压缩后,可以基于目标图像的调色板、奇异值数量阈值以及近似矩阵恢复压缩前的目标图像,并显示该目标图像,避免显示的目标图像失真。As can be seen from the above, the image processing method provided by this embodiment obtains image data; performs matrix reconstruction according to the singular value number threshold and the approximation matrix to obtain the index matrix of the target image; generates the target image according to the index matrix and palette, and Output the target image. After compressing the target image, the method provided in this embodiment can restore the target image before compression based on the target image's palette, singular value threshold, and approximation matrix, and display the target image to avoid distortion of the displayed target image.
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the sequence number of each step in the above embodiment does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.
对应于上文实施例所述的一种图像处理方法,图5示出了本申请实施例提供的一种图像处理装置的结构示意图,为了便于说明,仅示出了与本申请实施例相关的部分。参照图5,该图像处理装置500包括:第一获取单元51、分解单元52、第一确定单元53及第一置零单元54。其中:Corresponding to an image processing method described in the above embodiment, FIG. 5 shows a schematic structural diagram of an image processing device provided by an embodiment of the present application. For convenience of explanation, only the components related to the embodiment of the present application are shown. part. Referring to FIG. 5 , the image processing device 500 includes: a first acquisition unit 51 , a decomposition unit 52 , a first determination unit 53 and a first zero-setting unit 54 . in:
第一获取单元51用于获取目标图像的属性信息和索引矩阵。The first acquisition unit 51 is used to acquire the attribute information and index matrix of the target image.
分解单元52用于对所述索引矩阵进行奇异值分解,得到所述目标图像对应的左奇异矩阵、右奇异矩阵以及对角矩阵;其中,所述对角矩阵的对角线上的各个元素的值均为所述索引矩阵的奇异值。The decomposition unit 52 is used to perform singular value decomposition on the index matrix to obtain the left singular matrix, the right singular matrix and the diagonal matrix corresponding to the target image; wherein, the The values are all singular values of the index matrix.
第一确定单元53用于根据所述属性信息确定奇异值数量阈值。The first determining unit 53 is configured to determine a singular value number threshold according to the attribute information.
第一置零单元54用于根据所述奇异值数量阈值对所述对角矩阵、所述左奇异矩阵以及所述右奇异矩阵进行部分元素的置零操作,得到用于表示所述目标图像压缩后的数据的近似矩阵。The first zero-setting unit 54 is configured to perform a zero-setting operation on some elements of the diagonal matrix, the left singular matrix, and the right singular matrix according to the singular value quantity threshold to obtain a compression method for representing the target image. Approximate matrix of the subsequent data.
在本申请的一个实施例中,第一置零单元54具体包括:排序单元、第二获取单元及第二置零单元。其中:In one embodiment of the present application, the first zero-setting unit 54 specifically includes: a sorting unit, a second acquisition unit, and a second zero-setting unit. in:
排序单元用于对所述对角矩阵中的各个奇异值按照大小进行排序,得到奇异值顺序表。The sorting unit is used to sort each singular value in the diagonal matrix according to size to obtain a singular value sequence table.
第二获取单元用于按照从大到小的顺序从所述奇异值顺序表中,获取与所述奇异值数量阈值相等数量的多个目标奇异值。The second acquisition unit is configured to acquire a plurality of target singular values equal to the singular value quantity threshold from the singular value sequence table in order from large to small.
第二置零单元用于根据所述多个目标奇异值,对所述对角矩阵、所述左奇异矩阵以及所述右奇异矩阵进行部分元素的置零操作,得到所述近似矩阵。The second zero-setting unit is configured to perform a zero-setting operation on some elements of the diagonal matrix, the left singular matrix, and the right singular matrix according to the plurality of target singular values to obtain the approximate matrix.
在本申请的一个实施例中,第二置零单元具体包括:第三置零单元、第四置零单元、第五置零单元及第二确定单元。其中:In one embodiment of the present application, the second zero-setting unit specifically includes: a third zero-setting unit, a fourth zero-setting unit, a fifth zero-setting unit, and a second determination unit. in:
第三置零单元用于将所述对角矩阵中除所述多个目标奇异值之外的其余奇异值置零,得到第一矩阵。The third zero-setting unit is used to set the remaining singular values in the diagonal matrix to zero except for the plurality of target singular values to obtain the first matrix.
第四置零单元用于将所述左奇异矩阵中与所述其余奇异值关联的奇异向量置零,得到第二矩阵。The fourth zero-setting unit is used to set the singular vectors associated with the remaining singular values in the left singular matrix to zero to obtain the second matrix.
第五置零单元用于将所述右奇异矩阵中与所述其余奇异值关联的奇异向量置零,得到第三矩阵。The fifth zero-setting unit is used to set the singular vectors associated with the remaining singular values in the right singular matrix to zero to obtain a third matrix.
第二确定单元用于将所述第一矩阵、所述第二矩阵以及所述第三矩阵确定为所述近似矩阵The second determination unit is used to determine the first matrix, the second matrix and the third matrix as the approximate matrix
在本申请的一个实施例中,所述属性信息包括图像分辨率,所述图像分辨率与所述奇异值数量阈值呈正相关。In one embodiment of the present application, the attribute information includes image resolution, and the image resolution is positively correlated with the singular value number threshold.
在本申请的一个实施例中,所述属性信息包括图像分辨率;第一确定单元53具体包括:第三获取单元、第一查找单元及第二查找单元。其中:In one embodiment of the present application, the attribute information includes image resolution; the first determination unit 53 specifically includes: a third acquisition unit, a first search unit and a second search unit. in:
第三获取单元用于获取所述目标图像的期望图像压缩比。The third obtaining unit is used to obtain the desired image compression ratio of the target image.
第一查找单元用于从预先构建的多个阈值确定表中,查找与所述期望图像压缩比对应的目标阈值确定表;其中,所述阈值确定表用于描述在任意一个图像压缩比下,不同图像分辨率与不同奇异值数量阈值之间的对应关系。The first search unit is used to search for a target threshold determination table corresponding to the desired image compression ratio from a plurality of pre-constructed threshold determination tables; wherein the threshold determination table is used to describe under any image compression ratio, Correspondence between different image resolutions and different singular value number thresholds.
第二查找单元用于从所述目标阈值确定表中,查找与所述目标图像的图像分辨率对应的奇异值数量阈值。The second search unit is configured to search the singular value number threshold corresponding to the image resolution of the target image from the target threshold determination table.
在本申请的一个实施例中,所述目标图像包括调色板;图像处理装置500还包括:存储单元。In one embodiment of the present application, the target image includes a color palette; the image processing device 500 further includes: a storage unit.
存储单元用于将所述调色板、所述奇异值数量阈值以及所述近似矩阵确定为与所述目标图像对应的压缩后的图像数据,并存储所述图像数据。The storage unit is configured to determine the color palette, the singular value number threshold and the approximation matrix as compressed image data corresponding to the target image, and store the image data.
在本申请的一个实施例中,图像处理装置500还包括:第四获取单元、重构单元及显示单元。其中:In one embodiment of the present application, the image processing device 500 further includes: a fourth acquisition unit, a reconstruction unit and a display unit. in:
第四获取单元用于获取所述图像数据。The fourth acquisition unit is used to acquire the image data.
重构单元用于根据所述奇异值数量阈值和所述近似矩阵进行矩阵重构,得到所述目标图像的索引矩阵。The reconstruction unit is configured to perform matrix reconstruction according to the singular value number threshold and the approximation matrix to obtain an index matrix of the target image.
显示单元用于根据所述索引矩阵和所述调色板生成所述目标图像,并显示所述目标图像。The display unit is configured to generate the target image according to the index matrix and the palette, and display the target image.
需要说明的是,上述装置/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。It should be noted that the information interaction, execution process, etc. between the above-mentioned devices/units are based on the same concept as the method embodiments of the present application. For details of their specific functions and technical effects, please refer to the method embodiments section. No further details will be given.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above functional units and modules is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs. Module completion means dividing the internal structure of the device into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be hardware-based. It can also be implemented in the form of software functional units. In addition, the specific names of each functional unit and module are only for the convenience of distinguishing each other and are not used to limit the scope of protection of the present application. For the specific working processes of the units and modules in the above system, please refer to the corresponding processes in the foregoing method embodiments, and will not be described again here.
图6为本申请一实施例提供的电子设备的结构示意图。如图6所示,该实施例的电子设备6包括:至少一个处理器60(图6中仅示出一个)处理器、存储器61以及存储在所述存储器61中并可在所述至少一个处理器60上运行的计算机程序62,所述处理器60执行所述计算机程序62时实现上述任意各个图像处理方法实施例中的步骤。FIG. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As shown in Figure 6, the electronic device 6 of this embodiment includes: at least one processor 60 (only one is shown in Figure 6), a memory 61, and a processor stored in the memory 61 and capable of processing in the at least one processor 60. The computer program 62 runs on the processor 60. When the processor 60 executes the computer program 62, the steps in any of the above image processing method embodiments are implemented.
该电子设备可包括,但不仅限于,处理器60、存储器61。本领域技术人员可以理解,图6仅仅是电子设备6的举例,并不构成对电子设备6的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如还可以包括输入输出设备、网络接入设备等。The electronic device may include, but is not limited to, a processor 60 and a memory 61 . Those skilled in the art can understand that FIG. 6 is only an example of the electronic device 6 and does not constitute a limitation on the electronic device 6. It may include more or fewer components than shown in the figure, or some components may be combined, or different components may be used. , for example, it may also include input and output devices, network access devices, etc.
所称处理器60可以是中央处理单元(Central Processing Unit,CPU),该处理器60还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The processor 60 may be a central processing unit (Central Processing Unit, CPU). The processor 60 may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), or application specific integrated circuits (Application Specific Integrated Circuit). , ASIC), off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
所述存储器61在一些实施例中可以是所述电子设备6的内部存储单元,例如电子设备6的内存。所述存储器61在另一些实施例中也可以是所述电子设备6的外部存储设备,例如所述电子设备6上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器61还可以既包括所述电子设备6的内部存储单元也包括外部存储设备。所述存储器61用于存储操作系统、应用程序、引导装载程序(BootLoader)、数据以及其他程序等,例如所述计算机程序的程序代码等。所述存储器61还可以用于暂时地存储已经输出或者将要输出的数据。The memory 61 may be an internal storage unit of the electronic device 6 in some embodiments, such as the memory of the electronic device 6 . In other embodiments, the memory 61 may also be an external storage device of the electronic device 6 , such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), or a secure digital device equipped on the electronic device 6 . (Secure Digital, SD) card, Flash Card, etc. Further, the memory 61 may also include both an internal storage unit of the electronic device 6 and an external storage device. The memory 61 is used to store operating systems, application programs, boot loaders, data and other programs, such as program codes of the computer programs. The memory 61 can also be used to temporarily store data that has been output or is to be output.
本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现可实现上述各个方法实施例中的步骤。Embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps in each of the above method embodiments can be implemented.
本申请实施例提供了一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行时实现可实现上述各个方法实施例中的步骤。Embodiments of the present application provide a computer program product. When the computer program product is run on an electronic device, the steps in each of the above method embodiments can be implemented when the electronic device is executed.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质至少可以包括:能够将计算机程序代码携带到电子设备的任何实体或装置、记录介质、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质。例如U盘、移动硬盘、磁碟或者光盘等。在某些司法管辖区,根据立法和专利实践,计算机可读介质不可以是电载波信号和电信信号。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, this application can implement all or part of the processes in the methods of the above embodiments by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. The computer program can be stored in a computer-readable storage medium. When executed by the processor, the steps of each of the above method embodiments can be implemented. Wherein, the computer program includes computer program code, which may be in the form of source code, object code, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying computer program code to an electronic device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), electrical carrier signals, telecommunications signals, and software distribution media. For example, U disk, mobile hard disk, magnetic disk or CD, etc. In some jurisdictions, subject to legislation and patent practice, computer-readable media may not be electrical carrier signals and telecommunications signals.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above embodiments, each embodiment is described with its own emphasis. For parts that are not detailed or documented in a certain embodiment, please refer to the relevant descriptions of other embodiments.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-described embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still implement the above-mentioned implementations. The technical solutions described in the examples are modified, or some of the technical features are equivalently replaced; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions in the embodiments of this application, and should be included in within the protection scope of this application.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311365170.5A CN117671044A (en) | 2023-10-19 | 2023-10-19 | Image processing method, device, electronic equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311365170.5A CN117671044A (en) | 2023-10-19 | 2023-10-19 | Image processing method, device, electronic equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117671044A true CN117671044A (en) | 2024-03-08 |
Family
ID=90075986
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311365170.5A Pending CN117671044A (en) | 2023-10-19 | 2023-10-19 | Image processing method, device, electronic equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117671044A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118657799A (en) * | 2024-08-16 | 2024-09-17 | 武汉泰铭恒创信息技术股份有限公司 | A traffic police intelligent management method and system based on big data |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090123048A1 (en) * | 2007-05-09 | 2009-05-14 | Jean-Daniel Leroux | Image Reconstruction Methods Based on Block Circulant System Matrices |
CN106646595A (en) * | 2016-10-09 | 2017-05-10 | 电子科技大学 | Earthquake data compression method based on tensor adaptive rank truncation |
CN112184557A (en) * | 2020-11-04 | 2021-01-05 | 上海携旅信息技术有限公司 | Super-resolution network model compression method, system, device and medium |
CN112218085A (en) * | 2020-09-24 | 2021-01-12 | 江苏海洋大学 | An Image Compression Method Based on Sparse Reconstruction of Singular Vectors |
CN112365552A (en) * | 2021-01-11 | 2021-02-12 | 成都职业技术学院 | Image compression method combining singular value decomposition and wavelet packet transformation |
-
2023
- 2023-10-19 CN CN202311365170.5A patent/CN117671044A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090123048A1 (en) * | 2007-05-09 | 2009-05-14 | Jean-Daniel Leroux | Image Reconstruction Methods Based on Block Circulant System Matrices |
CN106646595A (en) * | 2016-10-09 | 2017-05-10 | 电子科技大学 | Earthquake data compression method based on tensor adaptive rank truncation |
CN112218085A (en) * | 2020-09-24 | 2021-01-12 | 江苏海洋大学 | An Image Compression Method Based on Sparse Reconstruction of Singular Vectors |
CN112184557A (en) * | 2020-11-04 | 2021-01-05 | 上海携旅信息技术有限公司 | Super-resolution network model compression method, system, device and medium |
CN112365552A (en) * | 2021-01-11 | 2021-02-12 | 成都职业技术学院 | Image compression method combining singular value decomposition and wavelet packet transformation |
Non-Patent Citations (1)
Title |
---|
张帅;董亚芬;: "基于奇异值分解的数字图像压缩及重构研究", 信息技术与信息化, no. 1, 25 February 2017 (2017-02-25), pages 112 - 115 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118657799A (en) * | 2024-08-16 | 2024-09-17 | 武汉泰铭恒创信息技术股份有限公司 | A traffic police intelligent management method and system based on big data |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107832062B (en) | Program updating method and terminal equipment | |
US11915058B2 (en) | Video processing method and device, electronic equipment and storage medium | |
WO2022166258A1 (en) | Behavior recognition method and apparatus, terminal device, and computer-readable storage medium | |
CN112102164A (en) | Image processing method, device, terminal and storage medium | |
WO2021175040A1 (en) | Video processing method and related device | |
CN111491169B (en) | Digital image compression method, device, equipment and medium | |
CN111290684A (en) | Image display method, image display device and terminal equipment | |
CN117671044A (en) | Image processing method, device, electronic equipment and medium | |
CN110198473B (en) | Video processing method and device, electronic equipment and computer readable storage medium | |
CN114860699A (en) | Data quality detection method, device, equipment and storage medium | |
CN114117063A (en) | Entity alignment method, device, electronic equipment and computer readable storage medium | |
WO2022110405A1 (en) | Blockchain-based on-chain storage method and apparatus, terminal device, and medium | |
CN112584057B (en) | Illumination detection method and device | |
CN111382831B (en) | Accelerating convolutional nerves network model Forward reasoning method and device | |
CN109271543B (en) | Thumbnail display method and device, terminal and computer-readable storage medium | |
CN114579970B (en) | A method and system for Android malware detection based on convolutional neural network | |
WO2023005421A1 (en) | Work cover display method, device, medium and electronic apparatus | |
CN112330768B (en) | Image rapid synthesis method based on data characteristics | |
TWI777319B (en) | Method and device for determining stem cell density, computer device and storage medium | |
CN111611417B (en) | Image de-duplication method, device, terminal equipment and storage medium | |
CN109408028B (en) | Floating point number operation method and device and storage medium | |
CN110134813B (en) | Image retrieval method, image retrieval device and terminal equipment | |
CN112989924A (en) | Target detection method, target detection device and terminal equipment | |
WO2021203741A1 (en) | Benchmark test method and system, and terminal device | |
CN111784607A (en) | Image tone mapping method, device, terminal equipment and storage medium |
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 |