Image processing method, device, electronic equipment and medium

By performing singular value decomposition and zeroing operations on the index matrix of the target image, the problem of low image compression efficiency in the prior art is solved, and more efficient storage space utilization and image quality assurance are achieved.

CN117671044BActive Publication Date: 2025-05-13SHENZHEN UASCENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311365170.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-19
Publication Date
2025-05-13
Estimated Expiration
2043-10-19

AI Technical Summary

Technical Problem

The prior art is inefficient when compressing the custom image format used in the lightweight embedded graphics library, and cannot effectively reduce the storage space usage, limiting the number and type of images of RTOS smart screens.

Method used

By obtaining the attribute information of the target image and the index matrix, the index matrix is ​​decomposed singularly, and the left singular, right singular and diagonal matrices are obtained. The threshold of the number of singular values ​​is determined based on the attribute information, and the zeroing operation of some elements is performed on these matrices to obtain an approximate matrix for representing the data compressed by the target image.

Benefits of technology

Improve image compression efficiency, reduce storage space usage, and accurately determine the number threshold of singular values ​​based on image attributes, ensuring image quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117671044B_ABST
    Figure CN117671044B_ABST
Patent Text Reader

Abstract

The present application is applicable to the field of image processing technology, and provides an image processing method, device, electronic device and medium, the method comprising: obtaining attribute information and index matrix of a target image; performing singular value decomposition on the index matrix to obtain a left singular matrix, a right singular matrix and a 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; determining a singular value quantity threshold according to the attribute information; performing a zeroing 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 an approximate matrix for representing compressed data of the target image. Compared with the prior art, the method improves the compression efficiency by performing singular value decomposition on the index matrix of the target image. At the same time, the singular value quantity threshold matching the image can be accurately determined according to the attribute information of the image, so as to ensure the image quality when compressing the target object.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of image processing technology, and in particular relates to an image processing method, device, electronic equipment and medium. Background Art

[0002] The Light and Versatile Graphics Library (LVGL) is an open source graphics library that can run on a real-time operating system (RTOS), supports a variety of displays and controllers, and provides a rich graphical user interface (GUI) components and animation effects. The Lightweight Embedded Graphics Library usually uses a custom image format to store and display images. However, images in its custom image format take up more storage space, limiting the number and types of images that the RTOS smart screen can store and display. Therefore, it is necessary to compress the images in the above format.

[0003] The prior art generally 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. Summary of the invention

[0004] The embodiments of the present application provide an image processing method, device, electronic device and medium, which improve the image compression efficiency.

[0005] In a first aspect, an embodiment of the present application provides an image processing method, comprising:

[0006] Get the attribute information and index matrix of the target image;

[0007] Performing singular value decomposition on the index matrix to obtain a left singular matrix, a right singular matrix and a 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;

[0008] Determine a singular value quantity threshold value according to the attribute information;

[0009] A partial element zeroing operation is performed on the diagonal matrix, the left singular matrix and the right singular matrix according to the singular value quantity threshold, so as to obtain an approximate matrix for representing the compressed data of the target image.

[0010] Optionally, performing a zeroing 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 an approximate matrix for representing compressed data of the target image includes:

[0011] Sorting each singular value in the diagonal matrix according to size to obtain a singular value sequence table;

[0012] Acquire, from the singular value sequence table in descending order, a number of target singular values ​​equal to the singular value quantity threshold;

[0013] According to the multiple target singular values, a zeroing operation is performed on some elements of the diagonal matrix, the left singular matrix, and the right singular matrix to obtain the approximate matrix.

[0014] Optionally, performing a zeroing operation on some elements of the diagonal matrix, the left singular matrix, and the right singular matrix according to the multiple target singular values ​​to obtain the approximate matrix includes:

[0015] Setting the remaining singular values ​​in the diagonal matrix except the plurality of target singular values ​​to zero to obtain a first matrix;

[0016] Setting the singular vectors associated with the remaining singular values ​​in the left singular matrix to zero to obtain a second matrix;

[0017] Setting the singular vectors associated with the remaining singular values ​​in the right singular matrix to zero to obtain a third matrix;

[0018] The first matrix, the second matrix, and the third matrix are determined as the approximate matrices.

[0019] Optionally, the attribute information includes image resolution, and the image resolution is positively correlated with the singular value quantity threshold.

[0020] Optionally, the attribute information includes image resolution; and determining a singular value quantity threshold according to the attribute information includes:

[0021] Obtaining an expected image compression ratio of the target image;

[0022] Searching 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 the corresponding relationship between different image resolutions and different singular value quantity thresholds under any image compression ratio;

[0023] From the target threshold determination table, a singular value quantity threshold corresponding to the image resolution of the target image is searched.

[0024] Optionally, the target image includes a color palette; after performing a zeroing 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 for representing compressed data of the target image, the method further includes:

[0025] 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.

[0026] Optionally, after determining the color palette, the singular value number threshold, and the approximate matrix as compressed image data corresponding to the target image and storing the image data, the method further includes:

[0027] Acquiring the image data;

[0028] Reconstructing a matrix according to the singular value number threshold and the approximate matrix to obtain an index matrix of the target image;

[0029] The target image is generated according to the index matrix and the color palette, and the target image is displayed.

[0030] In a second aspect, an embodiment of the present application provides an image processing device, including:

[0031] A first acquisition unit, used for acquiring attribute information and an index matrix of a target image;

[0032] A decomposition unit, used for performing singular value decomposition on the index matrix to obtain a left singular matrix, a right singular matrix and a 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;

[0033] A first determining unit, configured to determine a singular value quantity threshold according to the attribute information;

[0034] The first zeroing unit is used to perform a zeroing 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 an approximate matrix for representing the compressed data of the target image.

[0035] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, an image processing method as described in any one of the first aspects above is implemented.

[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image processing method as described in any one of the first aspects above is implemented.

[0037] In a fifth aspect, an embodiment of the present application provides 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 first aspects above.

[0038] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0039] 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 values ​​of each element on the diagonal of the diagonal matrix are all singular values ​​of the index matrix; determines the singular value number threshold according to the attribute information; performs a zeroing 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 for representing the compressed data of the target image. Compared with the prior art, the present method improves the compression efficiency by performing singular value decomposition on the index matrix of the target image. At the same time, the singular value number threshold 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. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0041] Figure 1 is a flowchart of an implementation of an image processing method provided by an embodiment of the present application;

[0042] Figure 2 is a flowchart of an implementation of an image processing method provided by another embodiment of the present application;

[0043] Figure 3 is a flowchart of an implementation of an image processing method provided in yet another embodiment of the present application;

[0044] Figure 4 is a flowchart of an implementation of an image processing method provided by another embodiment of the present application;

[0045] Figure 5 is a structural schematic diagram of an image processing device provided by an embodiment of the present application;

[0046] Figure 6 It is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0047] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0048] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0049] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0050] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0051] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0052] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0053] In practical applications, the Light and Versatile Graphics Library (LVGL) is an open source graphics library that can run on a real-time operating system (RTOS), supports a variety of displays and controllers, and provides a wealth of graphical user interface (GUI) components and animation effects. The Lightweight Embedded Graphics Library usually uses a custom image format to store and display images. However, its custom image format, such as images in the LV_IMG_CF_INDEXED_8BIT format, takes up more storage space, limiting the number and types of images that the RTOS smart screen can store and display. Therefore, it is necessary to compress the images in the above format.

[0054] However, existing image compression methods based on singular value decomposition (SVD) are usually for grayscale images or color images (RGB), but are not suitable for images in LV_IMG_CF_INDEXED_8BIT format, because images in LV_IMG_CF_INDEXED_8BIT format contain a palette and cannot be directly subjected to singular value decomposition.

[0055] 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 1. The image in this format includes a palette and an index matrix. The palette refers to the palette matrix, which is the image color table.

[0056] Based on this, an embodiment of the present application provides an image compression method for image formats that cannot be directly subjected to 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 elaborated here.

[0057] See also Figure 1 , Figure 1 1 is a flowchart of an implementation of an image processing method provided in 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. The electronic device may be an RTOS smart screen.

[0058] like Figure 1 As shown, the image processing method provided in an embodiment of the present application may include S101 to S104, which are described in detail as follows:

[0059] In S101, the attribute information and index matrix of the target image are obtained.

[0060] In practical applications, in order to reduce the storage space occupied by images, users can trigger image processing requests for electronic devices.

[0061] In an embodiment of the present application, the electronic device detects the above-mentioned image processing request may be: detecting that the user triggers the first preset operation for the electronic device. Among them, the first preset operation can be determined according to actual needs and is not limited here. Exemplarily, 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 may also be a time-triggered operation, and the electronic device may be configured with a corresponding workflow during operation, and the workflow includes trigger nodes for multiple key events, and the above-mentioned key events include an event of image compression of the target image. In this case, if the electronic device detects that the trigger node associated with the event of image compression of the target image is reached, the operations of S101 to S104 are executed to perform the compression operation on the target image. Among them, the target image refers to the image that needs to be compressed.

[0062] In some possible embodiments, the target image may be an image whose image format is LV_IMG_CF_INDEXED_8BIT format.

[0063] In the embodiment of the present application, after detecting the above-mentioned image processing request, the electronic device can obtain the target image and determine the attribute information and index matrix of the target image, wherein the attribute information of the target image includes but is not limited to the resolution of the target image.

[0064] In S102, singular value decomposition is performed on the index matrix to obtain a left singular matrix, a right singular matrix and a 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.

[0065] In an embodiment of the present application, after obtaining the index matrix of the target image, the electronic device may perform singular value decomposition on the index matrix to obtain a left singular matrix, a right singular matrix, and a diagonal matrix corresponding to the index matrix of the target image.

[0066] It should be noted that the values ​​of the elements on the diagonal of the diagonal matrix are all singular values ​​of the index matrix. Therefore, the diagonal matrix is ​​also called a singular value matrix.

[0067] For example, taking the matrix A with m rows and n columns as an example, the matrix A is subjected to singular value decomposition to obtain the matrix U (i.e., the left singular matrix), the matrix S (i.e., the diagonal matrix), and the matrix V (i.e., the right singular matrix), so that A=USV H .

[0068] Please refer to Table 1, which is a detailed description of the left singular matrix, the right singular matrix and the diagonal matrix after the matrix A is decomposed.

[0069] Table 1

[0070]

[0071] In S103, a singular value quantity threshold is determined according to the attribute information.

[0072] 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.

[0073] The attribute information includes image resolution.

[0074] In one embodiment of the present application, the electronic device pre-stores the correspondence between different image resolutions and singular value number thresholds. Therefore, after obtaining the image resolution of the target image, the electronic device can determine the singular value number threshold corresponding to the image resolution of the target image based on the image resolution of the target image and the above correspondence.

[0075] In this embodiment, the singular value quantity thresholds corresponding to different image resolutions are not completely the same.

[0076] In some possible embodiments, the image resolution is positively correlated with the threshold of the number of singular values, that is, the larger the image resolution, the larger the threshold of the number of singular values, and the smaller the image resolution, the smaller the threshold of the number of singular values.

[0077] In another embodiment of the present application, after obtaining the image resolution of the target image, the electronic device may determine the image level according to the image resolution, wherein the image level includes but is not limited to the first level, the second level and the third level.

[0078] The value range of the first level image resolution is (0, first resolution threshold), the value range of the second level image resolution is [first resolution threshold, second resolution threshold), and the value range of the third level image resolution is [second resolution threshold, +∞).

[0079] In this embodiment, when the electronic device detects that the image resolution of the target image is less than a 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 greater than or equal to the first resolution threshold and less than the second resolution threshold, it can determine that the image level of the target image is the second level; when the electronic device detects that the image resolution of the target image is greater than or equal to the second resolution threshold, it can determine that the image level of the target image is the third level.

[0080] In this embodiment, the singular value quantity threshold includes but is 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.

[0081] In one implementation of this embodiment, the electronic device can set the singular value number threshold corresponding to the first level as the first number threshold, the electronic device can set the singular value number threshold corresponding to the second level as the second number threshold, and the electronic device can set the singular value number threshold corresponding to the third level as the third number threshold, thereby obtaining a corresponding relationship between different image levels and the singular value number thresholds.

[0082] Based on this, in this embodiment, after determining the image level of the target image, the electronic device can determine the singular value number threshold corresponding to the target image according to the image level of the target image and the correspondence between different image levels and the singular value number thresholds.

[0083] In yet another embodiment of the present application, in order to further improve the accuracy of determining the threshold value of the number of singular values, the electronic device may specifically perform the following steps: Figure 2 Steps S201 to S203 shown determine the singular value number threshold, as detailed below:

[0084] In S201, the expected image compression ratio of the target image is obtained.

[0085] In this embodiment, the image compression ratio refers to the compression ratio of the image data size after being compressed by the encoder to the original image data size, wherein the original image refers to an image that has not been processed in any way.

[0086] In one implementation of this embodiment, the electronic device can obtain the desired image compression ratio required by the user in real time through a terminal device wirelessly connected to the electronic device, wherein the terminal device can be a smart phone, notebook, or computer used by the user.

[0087] In another implementation of this embodiment, the user may input a desired image compression ratio of the target image on a display interface of the electronic device, so that the electronic device acquires the desired image compression ratio.

[0088] In S202, a target threshold determination table corresponding to the desired image compression ratio is searched from a plurality of pre-constructed threshold determination tables; wherein the threshold determination table is used to describe the correspondence between different image resolutions and different singular value quantity thresholds at any image compression ratio.

[0089] In this embodiment, after obtaining the expected image compression ratio of the target image, the electronic device may search for a target threshold determination table corresponding to the expected image compression ratio from a plurality of pre-constructed threshold determination tables.

[0090] In some possible embodiments, different threshold determination tables correspond to different image compression ratio ranges. Therefore, the electronic device can determine the image compression ratio range in which the desired image compression ratio lies, and determine the threshold determination table corresponding to the image compression ratio range as the target threshold determination table.

[0091] Exemplarily, assuming 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], the image compression ratio range corresponding to the second determination table 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.

[0092] In S203, a singular value quantity threshold corresponding to the image resolution of the target image is searched from the target threshold determination table.

[0093] In this embodiment, after obtaining the target threshold determination table, the electronic device may search the target threshold determination table for a singular value quantity threshold corresponding to the image resolution of the target image according to the image resolution of the target image.

[0094] In S104, a partial element zeroing operation is performed on the diagonal matrix, the left singular matrix, and the right singular matrix according to the singular value quantity threshold, so as to obtain an approximate matrix for representing the compressed data of the target image.

[0095] In an embodiment of the present application, after obtaining the singular value number threshold, the electronic device can screen all elements in the diagonal matrix, the left singular matrix and the right singular matrix according to the singular value number threshold, retain the target elements equal to the singular value number threshold, and set all elements except the target elements to zero, thereby achieving dimensionality reduction and compression of the target image, and obtaining an approximate matrix for representing the compressed data of the target image.

[0096] In one embodiment of the present application, the electronic device may number all elements in the diagonal matrix, the left singular matrix, and the right singular matrix, such as number 1, number 2, ... number n, etc., and then the electronic device may determine the target numbers to be retained from the above multiple numbers based on a random function until the number of target numbers is equal to the singular value number threshold. The random function may be a rand() function.

[0097] In another embodiment of the present application, in order to ensure the image compression rate of the target image while ensuring the image compression quality, the electronic device can specifically Figure 3 Steps S301 to S303 shown in the figure compress the target image to obtain an approximate matrix, which is described in detail as follows:

[0098] In S301, each singular value in the diagonal matrix is ​​sorted according to size to obtain a singular value sequence table.

[0099] In S302, a plurality of target singular values ​​whose number is equal to the singular value quantity threshold are obtained from the singular value sequence table in order from large to small.

[0100] In S303, according to the multiple target singular values, a zeroing operation is performed on some elements of the diagonal matrix, the left singular matrix, and the right singular matrix to obtain the approximate matrix.

[0101] 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 number threshold. In other words, the multiple target singular values ​​obtained by the electronic device are the singular values ​​that are ranked before the singular value number threshold in order from large to small in the singular value sequence table.

[0102] In one embodiment of the present application, the electronic device can obtain an approximate matrix by the following steps, which are described in detail as follows:

[0103] Setting the remaining singular values ​​in the diagonal matrix except the plurality of target singular values ​​to zero to obtain a first matrix;

[0104] Setting the singular vectors associated with the remaining singular values ​​in the left singular matrix to zero to obtain a second matrix;

[0105] Setting the singular vectors associated with the remaining singular values ​​in the right singular matrix to zero to obtain a third matrix;

[0106] The first matrix, the second matrix, and the third matrix are determined as the approximate matrices.

[0107] In this embodiment, the electronic device may retain multiple target singular values ​​in the diagonal matrix, and set all other singular values ​​except the multiple target singular values ​​to zero, so as to obtain a first matrix corresponding to the diagonal matrix.

[0108] 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, set all singular vectors associated with the remaining singular values ​​to zero, so as to obtain a second matrix corresponding to the left singular matrix.

[0109] 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, set all singular vectors associated with the remaining singular values ​​to zero, so as to obtain a third matrix corresponding to the right singular matrix.

[0110] For example, taking the matrix A with m rows and n columns as an example, it is assumed that the expansion form of the singular value decomposition of the matrix A is:

[0111]

[0112] Where 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.

[0113] Assuming that the threshold of the number of singular values ​​is K, the approximate matrix is:

[0114]

[0115] Where A represents the index matrix, u i represents the j-th m-dimensional singular vector in the left singular matrix, σ i represents the jth singular value in the diagonal matrix, v i H represents the j-th n-dimensional singular vector in the right singular matrix, K <r。

[0116] Based on this, the electronic device may determine the first matrix, the second matrix, and the third matrix as approximate matrices.

[0117] From the above, it can be seen that 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 values ​​of each element on the diagonal of the diagonal matrix are all singular values ​​of the index matrix; determines the singular value number threshold according to the attribute information; performs a zeroing 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 for representing the compressed data of the target image. Compared with the prior art, the present method improves the compression efficiency by performing singular value decomposition on the index matrix of the target image. At the same time, the singular value number threshold that matches 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.

[0118] In one embodiment of the present application, after obtaining the approximate matrix, the electronic device can determine the color palette of the target image, the threshold value of the number of singular values, and the approximate matrix as compressed image data corresponding to the target image, and store the image data for subsequent other operations on the target image.

[0119] In this embodiment, the electronic device can store the above image data in its own memory.

[0120] Based on this, see Figure 4 , Figure 4 This is an image processing method provided by another embodiment of the present application. After storing the image data, in order to display the target image, this embodiment may also include S401 to S403, which are described in detail as follows:

[0121] In S401, the image data is acquired.

[0122] In S402, matrix reconstruction is performed according to the singular value quantity threshold and the approximate matrix to obtain an index matrix of the target image.

[0123] In S403, the target image is generated according to the index matrix and the color palette, and the target image is displayed.

[0124] In actual applications, when a user requires an electronic device to display a target image, the user may trigger an image display request for the electronic device.

[0125] In this embodiment, the electronic device detects the above-mentioned image display request may be: detecting that the user triggers the second preset operation for the electronic device. The second preset operation can be determined according to actual needs and is not limited here. Exemplarily, the second preset operation may be clicking on a 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 that the second preset operation for the electronic device is detected, that is, the image display request is detected.

[0126] 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.

[0127] The electronic device can perform matrix reconstruction according to a threshold value of the number of singular values ​​in the image data and an approximate matrix to obtain an approximate representation of the index matrix of the target image.

[0128] Afterwards, the electronic device can 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.

[0129] As can be seen from the above, the image processing method provided in this embodiment acquires image data; performs matrix reconstruction according to the singular value number threshold and the approximate matrix to obtain the index matrix of the target image; generates the target image according to the index matrix and the color palette, and outputs the target image. After compressing the target image, the method provided in this embodiment can restore the target image before compression based on the color palette, singular value number threshold and approximate matrix of the target image, and display the target image to avoid distortion of the displayed target image.

[0130] It should be understood that the size of the serial numbers of the steps in the above embodiments 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 embodiments of the present application.

[0131] Corresponding to an image processing method described in the above embodiment, Figure 5 The structure diagram of an image processing device provided by an embodiment of the present application is shown. For the convenience of explanation, only the part related to the embodiment of the present application is shown. Figure 5 The image processing device 500 includes: a first acquisition unit 51, a decomposition unit 52, a first determination unit 53 and a first zeroing unit 54. Wherein:

[0132] The first acquisition unit 51 is used to acquire the attribute information and index matrix of the target image.

[0133] The decomposition unit 52 is used to perform singular value decomposition on the index matrix to obtain a left singular matrix, a right singular matrix and a 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.

[0134] The first determining unit 53 is used to determine a singular value quantity threshold according to the attribute information.

[0135] The first zeroing unit 54 is used to perform a zeroing operation on some elements of the diagonal matrix, the left singular matrix and the right singular matrix according to the singular value quantity threshold, so as to obtain an approximate matrix for representing the compressed data of the target image.

[0136] In one embodiment of the present application, the first zeroing unit 54 specifically includes: a sorting unit, a second acquiring unit and a second zeroing unit.

[0137] The sorting unit is used to sort the singular values ​​in the diagonal matrix according to their sizes to obtain a singular value sequence table.

[0138] The second acquisition unit is used to acquire, from the singular value sequence table in descending order, a number of target singular values ​​equal to the singular value quantity threshold.

[0139] The second zeroing unit is used to perform a zeroing operation on some elements of the diagonal matrix, the left singular matrix and the right singular matrix according to the multiple target singular values ​​to obtain the approximate matrix.

[0140] 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 determining unit. Wherein:

[0141] The third zeroing unit is used to set the remaining singular values ​​in the diagonal matrix except the multiple target singular values ​​to zero to obtain a first matrix.

[0142] The fourth zeroing unit is used to set the singular vectors associated with the remaining singular values ​​in the left singular matrix to zero to obtain a second matrix.

[0143] The fifth zeroing 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.

[0144] The second determining unit is configured to determine the first matrix, the second matrix, and the third matrix as the approximate matrix

[0145] In one embodiment of the present application, the attribute information includes image resolution, and the image resolution is positively correlated with the singular value quantity threshold.

[0146] 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. Among them:

[0147] The third acquisition unit is used to acquire the expected image compression ratio of the target image.

[0148] 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 the correspondence between different image resolutions and different singular value quantity thresholds under any image compression ratio.

[0149] The second search unit is used to search the target threshold determination table for a singular value quantity threshold corresponding to the image resolution of the target image.

[0150] In one embodiment of the present application, the target image includes a color palette; the image processing device 500 further includes: a storage unit.

[0151] The storage unit is used to determine the color palette, the singular value number threshold and the approximate matrix as compressed image data corresponding to the target image, and store the image data.

[0152] 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.

[0153] The fourth acquiring unit is used to acquire the image data.

[0154] The reconstruction unit is used to perform matrix reconstruction according to the singular value quantity threshold and the approximate matrix to obtain the index matrix of the target image.

[0155] The display unit is used to generate the target image according to the index matrix and the color palette, and display the target image.

[0156] 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 embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0157] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0158] Figure 6 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Figure 6 As shown, the electronic device 6 of this embodiment includes: at least one processor 60 ( Figure 6 Only one is shown in the figure) a processor, a memory 61, and a computer program 62 stored in the memory 61 and executable on the at least one processor 60, wherein the processor 60 implements the steps in any of the above-mentioned image processing method embodiments when executing the computer program 62.

[0159] The electronic device may include, but is not limited to, a processor 60 and a memory 61. Those skilled in the art will appreciate that Figure 6 It 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 a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.

[0160] The processor 60 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (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 any conventional processor, etc.

[0161] In some embodiments, the memory 61 may be an internal storage unit of the electronic device 6, 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), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 6. Further, the memory 61 may also include both the internal storage unit of the electronic device 6 and the external storage device. The memory 61 is used to store an operating system, an application program, a boot loader (BootLoader), data and other programs, such as the program code of the computer program, etc. The memory 61 may also be used to temporarily store data that has been output or is to be output.

[0162] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0163] An embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0164] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying the 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), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0165] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0166] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. An image processing method, characterized in that: include: Get the attribute information and index matrix of the target image; Performing singular value decomposition on the index matrix to obtain a left singular matrix, a right singular matrix and a 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; Determine a singular value quantity threshold value according to the attribute information; Performing a zeroing 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 for representing compressed data of the target image; The attribute information includes image resolution; and determining the singular value quantity threshold according to the attribute information includes: Obtaining an expected image compression ratio of the target image; Searching 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 the corresponding relationship between different image resolutions and different singular value quantity thresholds under any image compression ratio; From the target threshold determination table, a singular value quantity threshold corresponding to the image resolution of the target image is searched.

2. The image processing method according to claim 1, characterized in that: The step of performing a zeroing 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 an approximate matrix for representing compressed data of the target image includes: Sorting each singular value in the diagonal matrix according to size to obtain a singular value sequence table; Acquire, from the singular value sequence table in descending order, a number of target singular values ​​equal to the singular value quantity threshold; According to the multiple target singular values, a zeroing operation is performed on some elements of the diagonal matrix, the left singular matrix, and the right singular matrix to obtain the approximate matrix.

3. The image processing method according to claim 2, characterized in that: The step of performing a zeroing operation on some elements of the diagonal matrix, the left singular matrix, and the right singular matrix according to the multiple target singular values ​​to obtain the approximate matrix comprises: Setting the remaining singular values ​​in the diagonal matrix except the plurality of target singular values ​​to zero to obtain a first matrix; Setting the singular vectors associated with the remaining singular values ​​in the left singular matrix to zero to obtain a second matrix; Setting 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 approximate matrices.

4. The image processing method according to claim 1, wherein: The attribute information includes image resolution, and the image resolution is positively correlated with the singular value quantity threshold.

5. The image processing method according to any one of claims 1 to 4, characterized in that: The target image includes a color palette; after performing a zeroing 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 for representing compressed data of the target image, the method further 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.

6. The image processing method according to claim 5, characterized in that: After determining the color palette, the singular value number threshold, and the approximate matrix as compressed image data corresponding to the target image and storing the image data, the method further includes: Acquiring the image data; Reconstructing a matrix according to the singular value number threshold and the approximate matrix to obtain an 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.

7. An image processing device, characterized in that: include: A first acquisition unit, used for acquiring attribute information and an index matrix of a target image; A decomposition unit, used for performing singular value decomposition on the index matrix to obtain a left singular matrix, a right singular matrix and a 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; A first determining unit, configured to determine a singular value quantity threshold according to the attribute information; A first zeroing unit is used to perform a zeroing operation on some elements of the diagonal matrix, the left singular matrix and the right singular matrix according to the singular value quantity threshold, so as to obtain an approximate matrix for representing the compressed data of the target image; The attribute information includes image resolution; the first determining unit specifically includes: A third acquisition unit, used to acquire the expected image compression ratio of the target image; A first search unit is used to search 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 the corresponding relationship between different image resolutions and different singular value quantity thresholds under any image compression ratio; The second search unit is used to search the singular value quantity threshold corresponding to the image resolution of the target image from the target threshold determination table.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the image processing method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the image processing method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Super-resolution network model compression method, system and device and medium

    CN112184557A

  • Image compression method based on singular vector sparse reconstruction

    CN112218085A