A grayscale image compression method and decompression method
By dividing and processing subpixel blocks of grayscale images and generating compressed data streams using appropriate compression mode, the problem of poor compression effect of grayscale images in the prior art is solved, and higher compression ratios and storage space savings are achieved.
Patent Information
- Application Number
- CN202210192109.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-01
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2042-03-01
AI Technical Summary
The existing grayscale image compression method has a low compression ratio, and the compressed data occupies a large storage space, and the compression effect is not good.
By obtaining the grayscale image to be compressed, dividing it into red, blue and green subpixel blocks, determining whether the span value of the green pixel is less than the threshold, using the first or second compression mode to generate a compressed data stream, and storing red and blue subpixels respectively, respectively Quantization value and green subpixel average or green subpixel quantization value and quantization value of adjacent subpixel blocks.
It improves the compression ratio of grayscale images, reduces storage space usage, and improves compression effect.
Smart Images

Figure CN114529620B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of image processing, and in particular to a compression method and a decompression method for a grayscale image. Background Art
[0002] At present, with the continuous development of electronic technology, electronic devices such as smart phones, tablet computers and televisions have gradually integrated into people's daily life and work, and the display screen is an important component of electronic devices such as smart phones, tablet computers and televisions, and undertakes important tasks such as picture display and human-computer interaction. In the display system, the host computer processes the original image data to be displayed into rendering sub-pixel data, and compresses the rendering sub-pixel data, stores it, decompresses it, and then sends it to the display panel for display after other data processing.
[0003] The original image data includes gradient images, random data images, grayscale images, general color images and other types. In the existing compression process for grayscale images, it is necessary to select a sub-pixel as a reference point in the grayscale image and calculate the difference data with other points, and then use a quantization lookup table to encode it to obtain compressed data. However, this method has a low compression ratio, the compressed data requires a large storage space, and the compression effect is poor. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a grayscale image compression method and a decompression method, which can improve the compression ratio of the grayscale image, make the compressed data occupy a smaller storage space, and improve the compression effect.
[0005] The present disclosure provides a grayscale image compression method, the method comprising:
[0006] Acquire a grayscale image to be compressed, and determine rendering sub-pixels corresponding to the grayscale image to be compressed, wherein the rendering sub-pixels include red sub-pixels, blue sub-pixels, and green sub-pixels;
[0007] Divide the rendering sub-pixel into a plurality of sub-pixel blocks, and for each of the sub-pixel blocks, determine a green pixel span value corresponding to the green sub-pixel in the sub-pixel block;
[0008] Determine whether the green pixel span value is less than a preset threshold;
[0009] If yes, a first compressed data stream corresponding to the sub-pixel block is generated in a first compression mode, wherein the first compressed data stream stores a red sub-pixel quantized value of each red sub-pixel, a blue sub-pixel quantized value of each blue sub-pixel, a green sub-pixel average value of the green sub-pixel, and a first compression mode identifier corresponding to the first compression mode;
[0010] If not, generate a second compressed data stream corresponding to the sub-pixel block in a second compression mode, wherein the second compressed data stream stores the green sub-pixel quantization value of each green sub-pixel in the sub-pixel block, the green sub-pixel quantization value of each green sub-pixel in the last column of the sub-pixel block adjacent to the left side of the sub-pixel block, and a second compression mode identifier corresponding to the second compression mode.
[0011] In an optional implementation manner, determining, for each of the sub-pixel blocks, a pixel span value corresponding to the green sub-pixel in the sub-pixel block includes:
[0012] For each of the sub-pixel blocks, determining a maximum pixel value and a minimum pixel value of the green sub-pixels in the sub-pixel block;
[0013] The difference between the maximum pixel value and the minimum pixel value of the green sub-pixel is determined as the green pixel span value.
[0014] The present disclosure also provides a grayscale image decompression method, the method comprising:
[0015] Obtaining the compressed data stream corresponding to each sub-pixel block in the grayscale image to be decompressed;
[0016] For each of the compressed data streams, identifying a compression mode identifier contained in the compressed data stream;
[0017] When the compression mode identifier is the first compression mode identifier, determining, in the compressed data stream, a red sub-pixel dequantized value corresponding to each red sub-pixel quantized value, a blue sub-pixel dequantized value corresponding to each blue sub-pixel quantized value, and a first green sub-pixel dequantized value corresponding to an average value of green sub-pixels;
[0018] Determine the red sub-pixel dequantized value, the blue sub-pixel dequantized value, and the first green sub-pixel dequantized value as decompressed data corresponding to the red sub-pixel, the blue sub-pixel, and the green sub-pixel, respectively, in the first compression mode;
[0019] When the compression mode identifier is the second compression mode identifier, determining a second green sub-pixel inverse quantization value corresponding to each green sub-pixel quantization value in the compressed data stream, and selecting a plurality of green sub-pixel quantization values as reference green sub-pixel quantization values in the compressed data stream corresponding to two sub-pixel blocks adjacent to the upper side and the upper left side of the sub-pixel block corresponding to the compressed data stream;
[0020] Determine a reference green sub-pixel inverse quantization value corresponding to the reference green sub-pixel quantization value, and construct a green sub-pixel reference matrix corresponding to the compressed data stream according to all of the second green sub-pixel inverse quantization values and the reference green sub-pixel inverse quantization values;
[0021] For each red sub-pixel or blue sub-pixel in the sub-pixel block, determine a pixel position of the red sub-pixel or blue sub-pixel in the sub-pixel block, and match four mapped green sub-pixel quantization values in the green sub-pixel reference matrix according to the pixel position;
[0022] For each of the mapped green sub-pixel quantization values, determine a first pixel mapping value corresponding to the mapped green sub-pixel quantization value in a preset first pixel quantization value matching table, and configure a corresponding weight parameter for each of the first pixel mapping values;
[0023] Determine a weighted average value corresponding to all the first pixel mapping values according to the weight parameter, and determine a second pixel mapping value corresponding to the weighted average value in a preset second pixel quantization value matching table;
[0024] The second pixel mapping value is determined as the decompressed data corresponding to the red sub-pixel or the blue sub-pixel under the second compression mode, and the second green sub-pixel inverse quantization value is determined as the decompressed data corresponding to the green sub-pixel under the second compression mode.
[0025] In an optional implementation manner, after determining the second pixel mapping value as decompressed data corresponding to the red sub-pixel or the blue sub-pixel in the second compression mode, and determining the second green sub-pixel dequantized value as decompressed data corresponding to the green sub-pixel in the second compression mode, the method further includes:
[0026] Determine color arrangement information corresponding to a preset image display panel;
[0027] The decompressed data corresponding to all red sub-pixels, blue sub-pixels and green sub-pixels are arranged according to the color arrangement information, and the decompressed grayscale image is displayed on the image display panel.
[0028] The present disclosure also provides a grayscale image compression device, the device comprising:
[0029] A first acquisition module is used to acquire a grayscale image to be compressed, and determine rendering sub-pixels corresponding to the grayscale image to be compressed, wherein the rendering sub-pixels include red sub-pixels, blue sub-pixels, and green sub-pixels;
[0030] a dividing module, configured to divide the rendering sub-pixel into a plurality of sub-pixel blocks, and for each of the sub-pixel blocks, determine a green pixel span value corresponding to the green sub-pixel in the sub-pixel block;
[0031] A judging module, used to judge whether the green pixel span value is less than a preset threshold;
[0032] A first compression module is configured to generate a first compressed data stream corresponding to the sub-pixel block in a first compression mode, wherein the first compressed data stream stores a red sub-pixel quantized value of each of the red sub-pixels, a blue sub-pixel quantized value of each of the blue sub-pixels, a green sub-pixel average value of the green sub-pixels, and a first compression mode identifier corresponding to the first compression mode;
[0033] A second compression module is used to generate a second compressed data stream corresponding to the sub-pixel block in a second compression mode if not, wherein the second compressed data stream stores the green sub-pixel quantization value of each green sub-pixel in the sub-pixel block, the green sub-pixel quantization value of each green sub-pixel in the last column of the sub-pixel block adjacent to the left side of the sub-pixel block, and a second compression mode identifier corresponding to the second compression mode.
[0034] The present disclosure also provides a grayscale image decompression device, the device comprising:
[0035] A second acquisition module is used to acquire a compressed data stream corresponding to each sub-pixel block in the grayscale image to be decompressed;
[0036] An identification module, configured to identify, for each of the compressed data streams, a compression mode identifier contained in the compressed data stream;
[0037] A first decompression module is used to determine, when the compression mode identifier is the first compression mode identifier, a red sub-pixel dequantized value corresponding to each red sub-pixel quantized value, a blue sub-pixel dequantized value corresponding to each blue sub-pixel quantized value, and a first green sub-pixel dequantized value corresponding to an average value of green sub-pixels in the compressed data stream;
[0038] A first determining module, configured to determine the red sub-pixel dequantized value, the blue sub-pixel dequantized value, and the first green sub-pixel dequantized value as decompressed data corresponding to the red sub-pixel, the blue sub-pixel, and the green sub-pixel, respectively, in a first compression mode;
[0039] A second decompression module is configured to, when the compression mode identifier is a second compression mode identifier, determine a second green sub-pixel inverse quantization value corresponding to each green sub-pixel quantization value in the compressed data stream, and select a plurality of green sub-pixel quantization values as reference green sub-pixel quantization values in the compressed data stream corresponding to two sub-pixel blocks adjacent to the upper side and the upper left side of the sub-pixel block corresponding to the compressed data stream;
[0040] a matrix construction module, configured to determine a reference green sub-pixel inverse quantization value corresponding to the reference green sub-pixel quantization value, and to construct a green sub-pixel reference matrix corresponding to the compressed data stream according to all of the second green sub-pixel inverse quantization values and the reference green sub-pixel inverse quantization values;
[0041] A first matching module is used to determine, for each red sub-pixel or blue sub-pixel in the sub-pixel block, a pixel position of the red sub-pixel or the blue sub-pixel in the sub-pixel block, and match four mapped green sub-pixel quantization values in the green sub-pixel reference matrix according to the pixel position;
[0042] A second matching module is used to determine, for each of the mapped green sub-pixel quantization values, a first pixel mapping value corresponding to the mapped green sub-pixel quantization value in a preset first pixel quantization value matching table, and configure a corresponding weight parameter for each of the first pixel mapping values;
[0043] A third matching module, configured to determine a weighted average value corresponding to all the first pixel mapping values according to the weight parameter, and determine a second pixel mapping value corresponding to the weighted average value in a preset second pixel quantization value matching table;
[0044] The second determination module is used to determine the second pixel mapping value as the decompressed data corresponding to the red sub-pixel or the blue sub-pixel under the second compression mode, and determine the second green sub-pixel inverse quantization value as the decompressed data corresponding to the green sub-pixel under the second compression mode.
[0045] The present disclosure also provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the above-mentioned grayscale image compression and decompression method, or steps in any possible implementation of the above-mentioned grayscale image compression and decompression method.
[0046] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer program executes the above-mentioned grayscale image compression and decompression method, or the steps in any possible implementation of the above-mentioned grayscale image compression and decompression method.
[0047] The present disclosure provides a grayscale image compression method and decompression method. The method comprises the following steps: obtaining a grayscale image to be compressed, determining a rendering sub-pixel corresponding to the grayscale image to be compressed, wherein the rendering sub-pixel includes a red sub-pixel, a blue sub-pixel and a green sub-pixel; dividing the rendering sub-pixel into a plurality of sub-pixel blocks, and determining, for each sub-pixel block, a green pixel span value corresponding to a green sub-pixel in the sub-pixel block; judging whether the green pixel span value is less than a preset threshold; if so, generating a first compressed data stream corresponding to the sub-pixel block in a first compression mode, wherein the first compressed data stream stores a red sub-pixel quantization value of each red sub-pixel, a blue sub-pixel quantization value of each blue sub-pixel, a green sub-pixel average value of the green sub-pixel, and a first compression mode identifier corresponding to the first compression mode; if not, generating a second compressed data stream corresponding to the sub-pixel block in a second compression mode, wherein the second compressed data stream stores a green sub-pixel quantization value of each green sub-pixel in the sub-pixel block, a green sub-pixel quantization value of each green sub-pixel in the last column of a sub-pixel block adjacent to the left side of the sub-pixel block, and a second compression mode identifier corresponding to the second compression mode. The compression ratio of grayscale images can be increased, so that the compressed data occupies less storage space and the compression effect is improved.
[0048] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0050] Figure 1 A schematic flow chart of a grayscale image compression method provided by an embodiment of the present disclosure is shown;
[0051] Figure 2A schematic diagram showing a PENTILE RGBG pixel arrangement provided by an embodiment of the present disclosure;
[0052] Figure 3 One of the schematic diagrams of the position relationship of sub-pixel blocks provided by an embodiment of the present disclosure is shown;
[0053] Figure 4 A schematic flow chart of a grayscale image decompression method provided by an embodiment of the present disclosure is shown;
[0054] Figure 5 A second schematic diagram of the position relationship of sub-pixel blocks provided in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0056] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0057] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0058] Research has found that in the existing compression process for grayscale images, it is necessary to select a sub-pixel as a reference point in the grayscale image and calculate the difference data with other points, and then use a quantization lookup table to encode it to obtain compressed data. However, this method has a low compression ratio, the compressed data requires a large storage space, and the compression effect is poor.
[0059] Based on the above research, the present disclosure provides a grayscale image compression method and a decompression method, which obtains a grayscale image to be compressed, determines the rendering sub-pixels corresponding to the grayscale image to be compressed, wherein the rendering sub-pixels include red sub-pixels, blue sub-pixels and green sub-pixels; divides the rendering sub-pixels into a plurality of sub-pixel blocks, and for each sub-pixel block, determines the green pixel span value corresponding to the green sub-pixel in the sub-pixel block; determines whether the green pixel span value is less than a preset threshold; if so, generates a first compressed data stream corresponding to the sub-pixel block in a first compression mode, wherein the first compressed data stream The red sub-pixel quantization value of each red sub-pixel, the blue sub-pixel quantization value of each blue sub-pixel, the green sub-pixel average value of the green sub-pixel, and the first compression mode identifier corresponding to the first compression mode are stored; if not, the second compressed data stream corresponding to the sub-pixel block is generated in the second compression mode, wherein the second compressed data stream stores the green sub-pixel quantization value of each green sub-pixel in the sub-pixel block, the green sub-pixel quantization value of each green sub-pixel in the last column of the sub-pixel block adjacent to the left side of the sub-pixel block, and the second compression mode identifier corresponding to the second compression mode. The compression ratio of the grayscale image can be improved, so that the compressed data occupies a smaller storage space, and the compression effect is improved.
[0060] To facilitate understanding of the present embodiment, a grayscale image compression method disclosed in the present embodiment is first introduced in detail. The grayscale image compression method provided in the present embodiment is generally executed by a computer device with certain computing capabilities, such as a terminal device or a server or other processing device. The terminal device may be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the grayscale image compression method may be implemented by a processor calling a computer-readable instruction stored in a memory.
[0061] See also Figure 1 FIG. 1 is a flow chart of a grayscale image compression method provided by an embodiment of the present disclosure, wherein the method comprises steps S101 to S105, wherein:
[0062] S101. Acquire a grayscale image to be compressed, and determine rendering sub-pixels corresponding to the grayscale image to be compressed, wherein the rendering sub-pixels include red sub-pixels, blue sub-pixels, and green sub-pixels.
[0063] In this step, an original grayscale image to be compressed is obtained as the grayscale image to be compressed, and image data processing is performed on the original grayscale image to obtain rendering sub-pixel data corresponding to the grayscale image to be compressed.
[0064] Here, the rendering sub-pixels are composed of sub-pixels of three colors: red (R), green (G), and blue (B). Unlike traditional pixels, which are composed of red, green, and blue sub-pixels arranged in sequence and different pixels emit light independently, the rendering sub-pixels have a different arrangement and can use the surrounding sub-pixels to assist in emitting light to achieve the required brightness and chromaticity.
[0065] Optionally, a sub-pixel rendering (SPR) technology may be used to process the grayscale image to be compressed, so as to obtain rendering sub-pixel data corresponding to the grayscale image to be compressed.
[0066] Here, the grayscale image refers to image data whose original image is composed of 0 to 255 grayscale data (R=G=B).
[0067] S102: Divide the rendering sub-pixel into a plurality of sub-pixel blocks, and for each of the sub-pixel blocks, determine a green pixel span value corresponding to the green sub-pixel in the sub-pixel block.
[0068] In this step, the rendered sub-pixel data corresponding to the acquired grayscale image is divided into a plurality of sub-pixel blocks, each sub-pixel block contains a plurality of red, green and blue sub-pixels, and all the green sub-pixels in each sub-pixel block are extracted according to the color arrangement of the rendered sub-pixels, and the pixel value span in the green sub-pixels is used as the green pixel span value.
[0069] The green pixel span value is determined based on the following method: for each sub-pixel block, the maximum pixel value and the minimum pixel value of the green sub-pixel in the sub-pixel block are determined; and the difference between the maximum pixel value and the minimum pixel value of the green sub-pixel is determined as the green pixel span value.
[0070] Here, the size of the sub-pixel block can be set according to actual needs in practical application, and no specific limitation is made here. Preferably, the size of the sub-pixel block can be 2×16, that is, each sub-pixel block contains 2×16 sub-pixels, and the compressed data bit width is 96 bits.
[0071] For the process of extracting all green sub-pixels in each sub-pixel block, Figure 2 As an example, see the PENTILERGBG pixel arrangement shown in Figure 2As shown, it is a schematic diagram of the PENTILE RGBG pixel arrangement provided by an embodiment of the present disclosure, and all sub-pixel data located in even columns in the sub-pixel block are taken out, that is, all green sub-pixel data in the sub-pixel block.
[0072] S103: Determine whether the green pixel span value is less than a preset threshold.
[0073] Here, in actual application, the value of the preset threshold can be set according to actual needs and is not specifically limited here.
[0074] S104. If so, generate a first compressed data stream corresponding to the sub-pixel block in a first compression mode, wherein the first compressed data stream stores a red sub-pixel quantization value of each of the red sub-pixels, a blue sub-pixel quantization value of each of the blue sub-pixels, a green sub-pixel average value of the green sub-pixels, and a first compression mode identifier corresponding to the first compression mode.
[0075] In this step, if the green pixel span value is less than a preset threshold, the sub-pixel block is compressed in the first compression mode to obtain a first compressed data stream corresponding to the sub-pixel block. The first compressed data stream stores the red sub-pixel quantization value of each red sub-pixel in the sub-pixel block, the blue sub-pixel quantization value of each blue sub-pixel, the green sub-pixel average value of the green sub-pixel, and the first compression mode identifier corresponding to the first compression mode.
[0076] Here, the processing method of the first compression mode is: first, the first compression mode identifier corresponding to the first compression mode is stored in the first compressed data stream; then, the sub-pixel quantization values corresponding to all the red sub-pixels and blue sub-pixels in the sub-pixel block are determined, and the sub-pixel quantization values corresponding to all the red sub-pixels and blue sub-pixels are stored in the first compressed data stream; finally, the pixel average value corresponding to all the green sub-pixels in the sub-pixel block is determined, and the pixel average value corresponding to the green sub-pixels is quantized and stored in the first compressed data stream.
[0077] The compression mode identifier is used to identify the compression mode of the compressed data stream, and optionally, 2-bit data can be used to represent it. The quantization bit width of the sub-pixel quantization value can be selected according to actual needs, and no specific restrictions are made here. To reduce precision loss, the quantization bit width should not be less than 4 bits.
[0078] Optionally, a preset bit width threshold may be set for the compressed data stream. If the bit width of the compressed data stream generated after compression is less than the preset bit width threshold, invalid data may be used to pad the bit width to the preset bit width threshold.
[0079] S105. If not, generate a second compressed data stream corresponding to the sub-pixel block in a second compression mode, wherein the second compressed data stream stores the green sub-pixel quantization value of each green sub-pixel in the sub-pixel block, the green sub-pixel quantization value of each green sub-pixel in the last column of the sub-pixel block adjacent to the left side of the sub-pixel block, and a second compression mode identifier corresponding to the second compression mode.
[0080] In this step, if the green pixel span value is greater than a preset threshold, the sub-pixel block is compressed in the second compression mode to obtain a second compressed data stream corresponding to the sub-pixel block. The second compressed data stream stores the green sub-pixel quantization value of each green sub-pixel in the sub-pixel block, the green sub-pixel quantization value of each green sub-pixel in the last column of the sub-pixel block adjacent to the left side of the sub-pixel block, and the second compression mode identifier corresponding to the second compression mode.
[0081] Here, the processing method of the second compression mode is: first, the second compression mode identifier corresponding to the second compression mode is stored in the second compressed data stream; then, the sub-pixel quantization values corresponding to all green sub-pixels in the sub-pixel block are determined, and stored in the second compressed data stream; finally, the sub-pixel quantization values corresponding to the last column of the green sub-pixel in the sub-pixel block adjacent to the left side of the current sub-pixel block are obtained, and stored in the second compressed data stream. For ease of understanding, see Figure 3 The figure is one of the schematic diagrams of the position relationship of sub-pixel blocks provided in an embodiment of the present disclosure.
[0082] As a possible implementation manner, the second compressed data stream may also store the pixel position of each red sub-pixel and each blue sub-pixel in the sub-pixel block.
[0083] The present disclosure provides a grayscale image compression method, which obtains a grayscale image to be compressed, determines a rendering sub-pixel corresponding to the grayscale image to be compressed, wherein the rendering sub-pixel includes a red sub-pixel, a blue sub-pixel and a green sub-pixel; divides the rendering sub-pixel into a plurality of sub-pixel blocks, and for each sub-pixel block, determines a green pixel span value corresponding to a green sub-pixel in the sub-pixel block; determines whether the green pixel span value is less than a preset threshold; if so, generates a first compressed data stream corresponding to the sub-pixel block in a first compression mode, wherein the first compressed data stream stores a red sub-pixel quantization value of each red sub-pixel, a blue sub-pixel quantization value of each blue sub-pixel, a green sub-pixel average value of the green sub-pixel, and a first compression mode identifier corresponding to the first compression mode; if not, generates a second compressed data stream corresponding to the sub-pixel block in a second compression mode, wherein the second compressed data stream stores a green sub-pixel quantization value of each green sub-pixel in the sub-pixel block, a green sub-pixel quantization value of each green sub-pixel in the last column of a sub-pixel block adjacent to the left side of the sub-pixel block, and a second compression mode identifier corresponding to the second compression mode. The compression ratio of grayscale images can be increased, so that the compressed data occupies less storage space and the compression effect is improved.
[0084] Furthermore, a grayscale image decompression method disclosed in an embodiment of the present disclosure is introduced in detail.
[0085] See also Figure 4 As shown, it is a flowchart of a grayscale image decompression method provided by an embodiment of the present disclosure, the method comprises steps S401 to S410, wherein the grayscale image decompression method provided by an embodiment of the present disclosure is a decompression method corresponding to the grayscale image compression method provided by the above embodiment:
[0086] S401: Obtain a compressed data stream corresponding to each sub-pixel block in a grayscale image to be decompressed.
[0087] In this step, according to the grayscale image compression method provided by the above embodiment, the grayscale image to be decompressed is compressed according to the multiple sub-pixel blocks divided into by the corresponding rendering sub-pixels, and each sub-pixel block corresponds to a compressed data stream. Therefore, for each sub-pixel block in the grayscale image to be decompressed, the compressed data stream corresponding to the sub-pixel block is obtained.
[0088] Here, when the compression mode adopted by the sub-pixel block is the first compression mode, the compressed data stream corresponding to the sub-pixel block is the first compressed data stream; when the compression mode adopted by the sub-pixel block is the second compression mode, the compressed data stream corresponding to the sub-pixel is the second compressed data stream.
[0089] S402: For each of the compressed data streams, identify a compression mode identifier included in the compressed data stream.
[0090] In this step, for each compressed data stream obtained, the compression mode identification data stored in the compressed data stream is extracted to determine whether the compressed data stream is compressed using the first compression mode or the second compression mode, and then match different decompression methods.
[0091] S403. When the compression mode identifier is the first compression mode identifier, determine in the compressed data stream, the red sub-pixel dequantization value corresponding to each red sub-pixel quantization value, the blue sub-pixel dequantization value corresponding to each blue sub-pixel quantization value, and the first green sub-pixel dequantization value corresponding to the green sub-pixel average value.
[0092] In this step, when the compressed data stream to be decompressed is compressed using the first compression mode, the recognized compression mode identifier is the first compression mode identifier, and each red sub-pixel quantization value, each blue sub-pixel quantization value, and the average value of the green sub-pixel after quantization processing are extracted from the compressed data stream, and inverse quantization calculations are performed on each of them to obtain the red sub-pixel inverse quantization value corresponding to each red sub-pixel quantization value, the blue sub-pixel inverse quantization value corresponding to each blue sub-pixel quantization value, and the first green sub-pixel inverse quantization value corresponding to the green sub-pixel average value.
[0093] S404: Determine the red sub-pixel dequantized value, the blue sub-pixel dequantized value, and the first green sub-pixel dequantized value as decompressed data corresponding to the red sub-pixel, the blue sub-pixel, and the green sub-pixel in a first compression mode, respectively.
[0094] In this step, the acquired red sub-pixel dequantized value, blue sub-pixel dequantized value and first green sub-pixel dequantized value are respectively determined as decompressed data corresponding to the red sub-pixel, blue sub-pixel and green sub-pixel in the first compression mode.
[0095] Here, the red sub-pixel inverse quantization value, the blue sub-pixel inverse quantization value and the first green sub-pixel inverse quantization value are the decompressed data after decompressing the compressed data stream compressed in the first compression mode. The decompressed data can be sent to the display panel to control the luminous display of the corresponding red sub-pixels, blue sub-pixels and green sub-pixels in the display panel, thereby restoring the compressed grayscale image.
[0096] S405. When the compression mode identifier is the second compression mode identifier, determine the second green sub-pixel inverse quantization value corresponding to each green sub-pixel quantization value in the compressed data stream, and select multiple green sub-pixel quantization values as reference green sub-pixel quantization values in the compressed data stream corresponding to the two sub-pixel blocks adjacent to the upper side and the upper left side of the sub-pixel block corresponding to the compressed data stream.
[0097] In this step, when the compressed data stream to be decompressed is compressed using the second compression mode, the identified compression mode identifier is the second compression mode identifier, all stored green sub-pixel quantization values are extracted from the compressed data stream, and the second green sub-pixel inverse quantization values corresponding to all green sub-pixel quantization values are calculated. These green sub-pixel quantization values include both the green sub-pixel quantization values corresponding to all green sub-pixels in the sub-pixel block currently being decompressed and the green sub-pixel quantization values corresponding to all green sub-pixels in the last column of the sub-pixel block adjacent to the left side of the sub-pixel block currently being decompressed.
[0098] Furthermore, a plurality of green sub-pixel quantization values are selected from the adjacent sub-pixel blocks located above and to the upper left of the sub-pixel block currently undergoing decompression processing as reference green sub-pixel quantization values.
[0099] Here, the green sub-pixel quantization value corresponding to the green sub-pixel in the last row of the sub-pixel block located above the sub-pixel block currently undergoing decompression processing and the green sub-pixel quantization value corresponding to the last green sub-pixel in the sub-pixel block located above the left side of the sub-pixel block currently undergoing decompression processing are selected as reference green sub-pixel quantization values. For ease of understanding, see Figure 5 , which is a second schematic diagram of the position relationship of sub-pixel blocks provided in an embodiment of the present disclosure.
[0100] S406, determine a reference green sub-pixel inverse quantization value corresponding to the reference green sub-pixel quantization value, and construct a green sub-pixel reference matrix corresponding to the compressed data stream according to all the second green sub-pixel inverse quantization values and the reference green sub-pixel inverse quantization values.
[0101] In this step, the reference green sub-pixel quantization value is dequantized to obtain a reference green sub-pixel dequantization value corresponding to the reference green sub-pixel quantization value, and all second green sub-pixel dequantization values are combined with the reference green sub-pixel dequantization value to generate a green sub-pixel reference matrix corresponding to the compressed data stream.
[0102] Here, the reference green sub-pixel inverse quantization value is used as the first row of the green sub-pixel reference matrix, the reference green sub-pixel inverse quantization value corresponding to the last green sub-pixel in the sub-pixel block adjacent to the upper left side of the sub-pixel block currently undergoing decompression is used as the first parameter of the green sub-pixel reference matrix, and the reference green sub-pixel inverse quantization value corresponding to the green sub-pixel in the last row in the sub-pixel block adjacent to the upper side of the sub-pixel block currently undergoing decompression constitutes the "zero" row of the green sub-pixel reference matrix. The second green sub-pixel inverse quantization value corresponding to the last column of green sub-pixels in the sub-pixel block adjacent to the left side of the sub-pixel block currently undergoing decompression stored in the compressed data stream and the reference green sub-pixel inverse quantization value corresponding to the last green sub-pixel in the sub-pixel block adjacent to the upper left side of the sub-pixel block currently undergoing decompression constitutes the "zero" column of the green sub-pixel reference matrix.
[0103] It should be noted that the "zero" row and the "zero" column are the first row and the first column for the green sub-pixel reference matrix itself, but in order to facilitate the subsequent matching of the mapped green sub-pixel quantization values in the green sub-pixel reference matrix, they are marked here as the "zero" row and the "zero" column, and the "zero" is only used for marking.
[0104] S407. For each red sub-pixel or blue sub-pixel in the sub-pixel block, determine the pixel position of the red sub-pixel or blue sub-pixel in the sub-pixel block, and match four mapped green sub-pixel quantization values in the green sub-pixel reference matrix according to the pixel position.
[0105] In this step, for each red sub-pixel or blue sub-pixel in the sub-pixel block currently undergoing decompression processing, the position coordinates of the red sub-pixel or blue sub-pixel in the sub-pixel block are determined, and based on the position coordinates, the green sub-pixel quantization values at four positions associated with the position coordinates are matched in the green sub-pixel reference matrix as mapped green sub-pixel quantization values.
[0106] Exemplarily, the position coordinates of a red or blue sub-pixel in the sub-pixel block currently undergoing decompression are (i, j). Based on the position coordinates, green sub-pixel quantization values at four positions with coordinates (i, j), (i-1, j), (i, j-1), and (i-1, j-1) are selected in the green sub-pixel reference matrix as mapped green sub-pixel quantization values.
[0107] S408. For each of the mapped green sub-pixel quantization values, determine a first pixel mapping value corresponding to the mapped green sub-pixel quantization value in a preset first pixel quantization value matching table, and configure a corresponding weight parameter for each of the first pixel mapping values.
[0108] In this step, for each mapped green sub-pixel quantization value, a first pixel mapping value corresponding to the mapped green sub-pixel quantization value is determined by looking up in a preset first pixel quantization value matching table, and a corresponding weight parameter is configured for each first pixel mapping value.
[0109] Here, in actual application, the weight parameter corresponding to each first pixel mapping value can be selected according to actual needs, and no specific restrictions are made here. The preset first pixel quantization value matching table can be set according to actual conditions such as the selected display panel parameters, and no specific restrictions are made here.
[0110] S409: Determine a weighted average value corresponding to all the first pixel mapping values according to the weight parameter, and determine a second pixel mapping value corresponding to the weighted average value in a preset second pixel quantization value matching table.
[0111] In this step, a weighted average value corresponding to all first pixel mapping values is determined according to the weight parameter corresponding to each first pixel mapping value, and a second pixel mapping value corresponding to the weighted average value is determined by looking up in a preset second pixel quantization value matching table.
[0112] Here, the preset second pixel quantization value matching table can be set as required according to actual conditions such as the selected display panel parameters, and no specific limitation is made here.
[0113] S410: Determine the second pixel mapping value as decompressed data corresponding to the red sub-pixel or the blue sub-pixel under the second compression mode, and determine the second green sub-pixel inverse quantization value as decompressed data corresponding to the green sub-pixel under the second compression mode.
[0114] In this step, the second pixel mapping value is determined as the decompressed data corresponding to the red sub-pixel or the blue sub-pixel after the compressed data stream compressed according to the second compression mode is decompressed, and the second green sub-pixel inverse quantization value is determined as the decompressed data corresponding to the green sub-pixel after the compressed data stream compressed according to the second compression mode is decompressed.
[0115] As a possible implementation manner, after determining the second pixel mapping value as the decompressed data corresponding to the red sub-pixel or the blue sub-pixel under the second compression mode, and determining the second green sub-pixel inverse quantization value as the decompressed data corresponding to the green sub-pixel under the second compression mode, the method further includes: determining color arrangement information corresponding to a preset image display panel; arranging the decompressed data corresponding to all red sub-pixels, blue sub-pixels and green sub-pixels according to the color arrangement information, and displaying the decompressed grayscale image on the image display panel.
[0116] A grayscale image decompression method provided by an embodiment of the present disclosure includes identifying a compression mode identifier contained in each compressed data stream; when the compression mode identifier is a first compression mode identifier, determining a red sub-pixel dequantized value corresponding to each red sub-pixel quantized value, a blue sub-pixel dequantized value corresponding to each blue sub-pixel quantized value, and a first green sub-pixel dequantized value corresponding to an average value of green sub-pixels in the compressed data stream; determining the red sub-pixel dequantized value, the blue sub-pixel dequantized value, and the first green sub-pixel dequantized value as decompressed data corresponding to the red sub-pixel, the blue sub-pixel, and the green sub-pixel under the first compression mode, respectively; when the compression mode identifier is a second compression mode identifier, determining a second green sub-pixel dequantized value corresponding to each green sub-pixel quantized value in the compressed data stream, and selecting a plurality of green sub-pixel quantized values as reference green sub-pixel quantized values in the compressed data stream corresponding to two sub-pixel blocks adjacent to the upper side and the upper left side of the sub-pixel block corresponding to the compressed data stream; determining a reference green sub-pixel dequantized value corresponding to the reference green sub-pixel quantized value, and determining the reference green sub-pixel dequantized value according to the reference green sub-pixel quantized value. The green sub-pixel reference matrix corresponding to the compressed data stream is constructed by combining all the second green sub-pixel inverse quantization values with the reference green sub-pixel inverse quantization values; for each red sub-pixel or blue sub-pixel in the sub-pixel block, the pixel position of the red sub-pixel or blue sub-pixel in the sub-pixel block is determined, and four mapped green sub-pixel quantization values are matched in the green sub-pixel reference matrix according to the pixel position; for each of the mapped green sub-pixel quantization values, the first pixel mapping value corresponding to the mapped green sub-pixel quantization value is determined in a preset first pixel quantization value matching table, and a corresponding weight parameter is configured for each first pixel mapping value; according to the weight parameter, the weighted average value corresponding to all the first pixel mapping values is determined, and the second pixel mapping value corresponding to the weighted average value is determined in a preset second pixel quantization value matching table; the second pixel mapping value is determined as the decompressed data corresponding to the red sub-pixel or blue sub-pixel in the second compression mode, and the second green sub-pixel inverse quantization value is determined as the decompressed data corresponding to the green sub-pixel in the second compression mode, which has a better decompression effect and improves the display effect of the grayscale image after decompression.
[0117] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0118] Based on the same inventive concept, the embodiment of the present disclosure also provides a grayscale image compression device corresponding to the grayscale image compression method. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned grayscale image compression method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0119] An embodiment of the present disclosure provides a grayscale image compression device, the device comprising:
[0120] A first acquisition module is used to acquire a grayscale image to be compressed, and determine rendering sub-pixels corresponding to the grayscale image to be compressed, wherein the rendering sub-pixels include red sub-pixels, blue sub-pixels, and green sub-pixels;
[0121] a dividing module, configured to divide the rendering sub-pixel into a plurality of sub-pixel blocks, and for each of the sub-pixel blocks, determine a green pixel span value corresponding to the green sub-pixel in the sub-pixel block;
[0122] A judging module, used to judge whether the green pixel span value is less than a preset threshold;
[0123] A first compression module is configured to generate a first compressed data stream corresponding to the sub-pixel block in a first compression mode, wherein the first compressed data stream stores a red sub-pixel quantized value of each of the red sub-pixels, a blue sub-pixel quantized value of each of the blue sub-pixels, a green sub-pixel average value of the green sub-pixels, and a first compression mode identifier corresponding to the first compression mode;
[0124] A second compression module is used to generate a second compressed data stream corresponding to the sub-pixel block in a second compression mode if not, wherein the second compressed data stream stores the green sub-pixel quantization value of each green sub-pixel in the sub-pixel block, the green sub-pixel quantization value of each green sub-pixel in the last column of the sub-pixel block adjacent to the left side of the sub-pixel block, and a second compression mode identifier corresponding to the second compression mode.
[0125] The present disclosure provides a grayscale image compression device, which obtains a grayscale image to be compressed, determines rendering sub-pixels corresponding to the grayscale image to be compressed, wherein the rendering sub-pixels include red sub-pixels, blue sub-pixels and green sub-pixels; divides the rendering sub-pixels into a plurality of sub-pixel blocks, and for each sub-pixel block, determines a green pixel span value corresponding to a green sub-pixel in the sub-pixel block; determines whether the green pixel span value is less than a preset threshold; if so, generates a first compressed data stream corresponding to the sub-pixel block in a first compression mode, wherein the first compressed data stream stores a red sub-pixel quantization value of each red sub-pixel, a blue sub-pixel quantization value of each blue sub-pixel, a green sub-pixel average value of the green sub-pixel, and a first compression mode identifier corresponding to the first compression mode; if not, generates a second compressed data stream corresponding to the sub-pixel block in a second compression mode, wherein the second compressed data stream stores a green sub-pixel quantization value of each green sub-pixel in the sub-pixel block, a green sub-pixel quantization value of each green sub-pixel in the last column of a sub-pixel block adjacent to the left side of the sub-pixel block, and a second compression mode identifier corresponding to the second compression mode. The compression ratio of grayscale images can be increased, so that the compressed data occupies less storage space and the compression effect is improved.
[0126] Furthermore, the embodiments of the present disclosure also provide a grayscale image decompression device corresponding to the grayscale image decompression method. Since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to the above-mentioned grayscale image decompression method in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0127] An embodiment of the present disclosure provides a grayscale image decompression device, the device comprising:
[0128] A second acquisition module is used to acquire a compressed data stream corresponding to each sub-pixel block in the grayscale image to be decompressed;
[0129] An identification module, configured to identify, for each of the compressed data streams, a compression mode identifier contained in the compressed data stream;
[0130] A first decompression module is used to determine, when the compression mode identifier is the first compression mode identifier, a red sub-pixel dequantized value corresponding to each red sub-pixel quantized value, a blue sub-pixel dequantized value corresponding to each blue sub-pixel quantized value, and a first green sub-pixel dequantized value corresponding to an average value of green sub-pixels in the compressed data stream;
[0131] A first determining module, configured to determine the red sub-pixel dequantized value, the blue sub-pixel dequantized value, and the first green sub-pixel dequantized value as decompressed data corresponding to the red sub-pixel, the blue sub-pixel, and the green sub-pixel, respectively, in a first compression mode;
[0132] A second decompression module is configured to, when the compression mode identifier is a second compression mode identifier, determine a second green sub-pixel inverse quantization value corresponding to each green sub-pixel quantization value in the compressed data stream, and select a plurality of green sub-pixel quantization values as reference green sub-pixel quantization values in the compressed data stream corresponding to two sub-pixel blocks adjacent to the upper side and the upper left side of the sub-pixel block corresponding to the compressed data stream;
[0133] a matrix construction module, configured to determine a reference green sub-pixel inverse quantization value corresponding to the reference green sub-pixel quantization value, and to construct a green sub-pixel reference matrix corresponding to the compressed data stream according to all of the second green sub-pixel inverse quantization values and the reference green sub-pixel inverse quantization values;
[0134] A first matching module is used to determine, for each red sub-pixel or blue sub-pixel in the sub-pixel block, a pixel position of the red sub-pixel or the blue sub-pixel in the sub-pixel block, and match four mapped green sub-pixel quantization values in the green sub-pixel reference matrix according to the pixel position;
[0135] A second matching module is used to determine, for each of the mapped green sub-pixel quantization values, a first pixel mapping value corresponding to the mapped green sub-pixel quantization value in a preset first pixel quantization value matching table, and configure a corresponding weight parameter for each of the first pixel mapping values;
[0136] A third matching module, configured to determine a weighted average value corresponding to all the first pixel mapping values according to the weight parameter, and determine a second pixel mapping value corresponding to the weighted average value in a preset second pixel quantization value matching table;
[0137] The second determination module is used to determine the second pixel mapping value as the decompressed data corresponding to the red sub-pixel or the blue sub-pixel under the second compression mode, and determine the second green sub-pixel inverse quantization value as the decompressed data corresponding to the green sub-pixel under the second compression mode.
[0138] A grayscale image decompression device provided by an embodiment of the present disclosure identifies a compression mode identifier contained in each compressed data stream; when the compression mode identifier is a first compression mode identifier, determines in the compressed data stream, a red sub-pixel dequantized value corresponding to each red sub-pixel quantized value, a blue sub-pixel dequantized value corresponding to each blue sub-pixel quantized value, and a first green sub-pixel dequantized value corresponding to an average value of green sub-pixels; determines the red sub-pixel dequantized value, the blue sub-pixel dequantized value, and the first green sub-pixel dequantized value as decompressed data corresponding to the red sub-pixel, the blue sub-pixel, and the green sub-pixel under the first compression mode, respectively; when the compression mode identifier is a second compression mode identifier, determines in the compressed data stream, a second green sub-pixel dequantized value corresponding to each green sub-pixel quantized value, and selects a plurality of green sub-pixel quantized values as reference green sub-pixel quantized values in the compressed data stream corresponding to two sub-pixel blocks adjacent to the upper side and the upper left side of the sub-pixel block corresponding to the compressed data stream; determines a reference green sub-pixel dequantized value corresponding to the reference green sub-pixel quantized value, and selects a plurality of green sub-pixel quantized values as reference green sub-pixel quantized values according to the reference green sub-pixel quantized value. The green sub-pixel reference matrix corresponding to the compressed data stream is constructed by combining all the second green sub-pixel inverse quantization values with the reference green sub-pixel inverse quantization values; for each red sub-pixel or blue sub-pixel in the sub-pixel block, the pixel position of the red sub-pixel or blue sub-pixel in the sub-pixel block is determined, and four mapped green sub-pixel quantization values are matched in the green sub-pixel reference matrix according to the pixel position; for each of the mapped green sub-pixel quantization values, the first pixel mapping value corresponding to the mapped green sub-pixel quantization value is determined in a preset first pixel quantization value matching table, and a corresponding weight parameter is configured for each first pixel mapping value; according to the weight parameter, the weighted average value corresponding to all the first pixel mapping values is determined, and the second pixel mapping value corresponding to the weighted average value is determined in a preset second pixel quantization value matching table; the second pixel mapping value is determined as the decompressed data corresponding to the red sub-pixel or blue sub-pixel in the second compression mode, and the second green sub-pixel inverse quantization value is determined as the decompressed data corresponding to the green sub-pixel in the second compression mode, which has a better decompression effect and improves the display effect of the grayscale image after decompression.
[0139] Corresponds to Figure 1 and Figure 4 The present disclosure also provides an electronic device, including:
[0140] Processor, memory, and bus; the memory is used to store execution instructions, including internal memory and external memory; the internal memory here is also called internal memory, which is used to temporarily store the operation data in the processor and the data exchanged with the external memory such as the hard disk. The processor exchanges data with the external memory through the internal memory. When the electronic device is running, the processor and the memory communicate through the bus so that the processor executes Figure 1 and Figure 4 The steps of the compression method and decompression method of the grayscale image in.
[0141] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the grayscale image compression method and decompression method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0142] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0143] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0144] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0145] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0146] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A grayscale image compression method, characterized in that: include: Acquire a grayscale image to be compressed, and determine rendering sub-pixels corresponding to the grayscale image to be compressed, wherein the rendering sub-pixels include red sub-pixels, blue sub-pixels, and green sub-pixels; Divide the rendering sub-pixel into a plurality of sub-pixel blocks, and for each of the sub-pixel blocks, determine a green pixel span value corresponding to the green sub-pixel in the sub-pixel block; Determine whether the green pixel span value is less than a preset threshold; If yes, a first compressed data stream corresponding to the sub-pixel block is generated in a first compression mode, wherein the first compressed data stream stores a red sub-pixel quantized value of each red sub-pixel, a blue sub-pixel quantized value of each blue sub-pixel, a green sub-pixel average value of the green sub-pixel, and a first compression mode identifier corresponding to the first compression mode; If not, generate a second compressed data stream corresponding to the sub-pixel block in a second compression mode, wherein the second compressed data stream stores the green sub-pixel quantization value of each green sub-pixel in the sub-pixel block, the green sub-pixel quantization value of each green sub-pixel in the last column of the sub-pixel block adjacent to the left side of the sub-pixel block, and a second compression mode identifier corresponding to the second compression mode.
2. The method according to claim 1, characterized in that The step of determining, for each of the sub-pixel blocks, a pixel span value corresponding to the green sub-pixel in the sub-pixel block includes: For each of the sub-pixel blocks, determining a maximum pixel value and a minimum pixel value of the green sub-pixels in the sub-pixel block; The difference between the maximum pixel value and the minimum pixel value of the green sub-pixel is determined as the green pixel span value.
3. A grayscale image decompression method, characterized in that: include: Obtaining the compressed data stream corresponding to each sub-pixel block in the grayscale image to be decompressed; For each of the compressed data streams, identifying a compression mode identifier contained in the compressed data stream; When the compression mode identifier is the first compression mode identifier, determining, in the compressed data stream, a red sub-pixel dequantized value corresponding to each red sub-pixel quantized value, a blue sub-pixel dequantized value corresponding to each blue sub-pixel quantized value, and a first green sub-pixel dequantized value corresponding to an average value of green sub-pixels; Determine the red sub-pixel dequantized value, the blue sub-pixel dequantized value, and the first green sub-pixel dequantized value as decompressed data corresponding to the red sub-pixel, the blue sub-pixel, and the green sub-pixel, respectively, in the first compression mode; When the compression mode identifier is the second compression mode identifier, determining a second green sub-pixel inverse quantization value corresponding to each green sub-pixel quantization value in the compressed data stream, and selecting a plurality of green sub-pixel quantization values as reference green sub-pixel quantization values in the compressed data stream corresponding to two sub-pixel blocks adjacent to the upper side and the upper left side of the sub-pixel block corresponding to the compressed data stream; Determine a reference green sub-pixel inverse quantization value corresponding to the reference green sub-pixel quantization value, and construct a green sub-pixel reference matrix corresponding to the compressed data stream according to all of the second green sub-pixel inverse quantization values and the reference green sub-pixel inverse quantization values; For each red sub-pixel or blue sub-pixel in the sub-pixel block, determine a pixel position of the red sub-pixel or blue sub-pixel in the sub-pixel block, and match four mapped green sub-pixel quantization values in the green sub-pixel reference matrix according to the pixel position; For each of the mapped green sub-pixel quantization values, determine a first pixel mapping value corresponding to the mapped green sub-pixel quantization value in a preset first pixel quantization value matching table, and configure a corresponding weight parameter for each of the first pixel mapping values; Determine a weighted average value corresponding to all the first pixel mapping values according to the weight parameter, and determine a second pixel mapping value corresponding to the weighted average value in a preset second pixel quantization value matching table; The second pixel mapping value is determined as the decompressed data corresponding to the red sub-pixel or the blue sub-pixel under the second compression mode, and the second green sub-pixel inverse quantization value is determined as the decompressed data corresponding to the green sub-pixel under the second compression mode.
4. The method according to claim 3, characterized in that After determining the second pixel mapping value as decompressed data corresponding to the red sub-pixel or the blue sub-pixel in the second compression mode, and determining the second green sub-pixel dequantized value as decompressed data corresponding to the green sub-pixel in the second compression mode, the method further includes: Determine color arrangement information corresponding to a preset image display panel; The decompressed data corresponding to all red sub-pixels, blue sub-pixels and green sub-pixels are arranged according to the color arrangement information, and the decompressed grayscale image is displayed on the image display panel.
5. A grayscale image compression device, characterized in that: include: A first acquisition module is used to acquire a grayscale image to be compressed, and determine rendering sub-pixels corresponding to the grayscale image to be compressed, wherein the rendering sub-pixels include red sub-pixels, blue sub-pixels, and green sub-pixels; a dividing module, configured to divide the rendering sub-pixel into a plurality of sub-pixel blocks, and for each of the sub-pixel blocks, determine a green pixel span value corresponding to the green sub-pixel in the sub-pixel block; A judging module, used to judge whether the green pixel span value is less than a preset threshold; A first compression module is configured to generate a first compressed data stream corresponding to the sub-pixel block in a first compression mode, wherein the first compressed data stream stores a red sub-pixel quantized value of each of the red sub-pixels, a blue sub-pixel quantized value of each of the blue sub-pixels, a green sub-pixel average value of the green sub-pixels, and a first compression mode identifier corresponding to the first compression mode; A second compression module is used to generate a second compressed data stream corresponding to the sub-pixel block in a second compression mode if not, wherein the second compressed data stream stores the green sub-pixel quantization value of each green sub-pixel in the sub-pixel block, the green sub-pixel quantization value of each green sub-pixel in the last column of the sub-pixel block adjacent to the left side of the sub-pixel block, and a second compression mode identifier corresponding to the second compression mode.
6. A grayscale image decompression device, characterized in that: include: A second acquisition module is used to acquire a compressed data stream corresponding to each sub-pixel block in the grayscale image to be decompressed; An identification module, configured to identify, for each of the compressed data streams, a compression mode identifier contained in the compressed data stream; A first decompression module is used to determine, when the compression mode identifier is the first compression mode identifier, a red sub-pixel dequantized value corresponding to each red sub-pixel quantized value, a blue sub-pixel dequantized value corresponding to each blue sub-pixel quantized value, and a first green sub-pixel dequantized value corresponding to an average value of green sub-pixels in the compressed data stream; A first determining module, configured to determine the red sub-pixel dequantized value, the blue sub-pixel dequantized value, and the first green sub-pixel dequantized value as decompressed data corresponding to the red sub-pixel, the blue sub-pixel, and the green sub-pixel, respectively, in a first compression mode; A second decompression module is configured to, when the compression mode identifier is a second compression mode identifier, determine a second green sub-pixel inverse quantization value corresponding to each green sub-pixel quantization value in the compressed data stream, and select a plurality of green sub-pixel quantization values as reference green sub-pixel quantization values in the compressed data stream corresponding to two sub-pixel blocks adjacent to the upper side and the upper left side of the sub-pixel block corresponding to the compressed data stream; a matrix construction module, configured to determine a reference green sub-pixel inverse quantization value corresponding to the reference green sub-pixel quantization value, and to construct a green sub-pixel reference matrix corresponding to the compressed data stream according to all of the second green sub-pixel inverse quantization values and the reference green sub-pixel inverse quantization values; A first matching module is used to determine, for each red sub-pixel or blue sub-pixel in the sub-pixel block, a pixel position of the red sub-pixel or the blue sub-pixel in the sub-pixel block, and match four mapped green sub-pixel quantization values in the green sub-pixel reference matrix according to the pixel position; A second matching module is used to determine, for each of the mapped green sub-pixel quantization values, a first pixel mapping value corresponding to the mapped green sub-pixel quantization value in a preset first pixel quantization value matching table, and configure a corresponding weight parameter for each of the first pixel mapping values; A third matching module, configured to determine a weighted average value corresponding to all the first pixel mapping values according to the weight parameter, and determine a second pixel mapping value corresponding to the weighted average value in a preset second pixel quantization value matching table; The second determination module is used to determine the second pixel mapping value as the decompressed data corresponding to the red sub-pixel or the blue sub-pixel under the second compression mode, and determine the second green sub-pixel inverse quantization value as the decompressed data corresponding to the green sub-pixel under the second compression mode.
7. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the compression method as described in any one of claims 1 to 2 are performed.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the compression method according to any one of claims 1 to 2 are executed.
9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the decompression method as described in any one of claims 3 to 4 are performed.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the decompression method as claimed in any one of claims 3 to 4 are executed.
