Map compression method and device and computer readable storage medium
By compressing the image blocks of the map, and using the pixel distribution to determine the compression evaluation indicators, selecting high-quality compression results, the problem of excessive volume after map compression is solved, and efficient map compression is achieved in mobile games.
Patent Information
- Application Number
- CN202311237780.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2025-03-25
AI Technical Summary
After compressing the maps in the prior art, the resulting maps are large in size and are difficult to be suitable for mobile games.
By acquiring the original map, compressing the image blocks using the map compression algorithm, obtaining the first compression result, and multiplexing the first compression result of the target image block to determine the second compression result. Based on the pixel distribution of the image block, the compression evaluation index is determined and the target compression result with better distortion is selected.
While ensuring the distortion, the compression volume is reduced as much as possible, solving the problem of excessive volume after map compression.
Smart Images

Figure CN119693475A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing, and in particular, to a texture compression method, device, and computer-readable storage medium. Background Art
[0002] Currently, there are many technical solutions for achieving texture compression, such as Oodle, Crunch, and basis_universal. However, these solutions are not suitable for compressing textures in mobile games because the textures obtained after compressing them are relatively large in size.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] At least some embodiments of the present disclosure provide a texture compression method, device, and computer-readable storage medium to at least solve the technical problem in the related art that the texture volume obtained after texture compression is large.
[0005] According to one embodiment of the present disclosure, a texture compression method is provided, comprising: obtaining an original texture, wherein the original texture includes multiple image blocks; compressing the image blocks using a texture compression algorithm to obtain a first compression result corresponding to the image blocks; multiplexing the first compression result corresponding to a target image block to determine a second compression result corresponding to the image block, wherein the target image block is used to characterize an image block that has an associated relationship with the image block among the multiple image blocks; determining a first compression evaluation index corresponding to the first compression result and a second compression evaluation index corresponding to the second compression result based on pixel distribution of the image blocks, wherein the compression evaluation index is used to characterize the distortion and compression volume corresponding to the compression results; and determining a target compression result corresponding to the image block from the first compression result and the second compression result based on the first compression evaluation index and the second compression evaluation index to compress the original texture.
[0006] According to one embodiment of the present disclosure, there is also provided a texture compression device, comprising: a texture acquisition module, for acquiring an original texture, wherein the original texture comprises a plurality of image blocks; a texture compression module, for compressing the image block using a texture compression algorithm to obtain a first compression result corresponding to the image block; a result multiplexing module, for multiplexing the first compression result corresponding to the target image block, and determining a second compression result corresponding to the image block, wherein the target image block is used to characterize an image block among a plurality of image blocks that has an associated relationship with the image block; an index determination module, for determining a first compression evaluation index corresponding to the first compression result, and a second compression evaluation index corresponding to the second compression result, based on pixel distribution of the image block, wherein the compression evaluation index is used to characterize the distortion and compression volume corresponding to the compression result; a result determination module, for determining a target compression result corresponding to the image block from the first compression result and the second compression result based on the first compression evaluation index and the second compression evaluation index, so as to compress the original texture.
[0007] According to one embodiment of the present disclosure, a computer-readable storage medium is further provided, wherein a computer program is stored in the computer-readable storage medium, wherein the computer program is configured to execute any of the above-mentioned texture compression methods when running.
[0008] According to one embodiment of the present disclosure, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute any of the above-mentioned texture compression methods.
[0009] In at least some embodiments of the present disclosure, an original map is first obtained, an image block is compressed using a map compression algorithm to obtain a first compression result corresponding to the image block, the first compression result corresponding to the target image block is reused, a second compression result corresponding to the image block is determined, and then a first compression evaluation index corresponding to the first compression result and a second compression evaluation index corresponding to the second compression result are determined based on pixel distribution of the image block. Finally, based on the first compression evaluation index and the second compression evaluation index, a target compression result corresponding to the image block can be determined from the first compression result and the second compression result to compress the original map. It should be noted that the compression evaluation index is used to characterize the distortion and compression volume corresponding to the compression result. Through the above method, the image block is compressed using the texture compression algorithm to obtain a first compression result. In order to improve the compression rate of the texture file by the texture compression algorithm, part of the compression results of the image block near the image block can be reused, that is, the first compression result corresponding to the target image block near the image block is reused to determine the second compression result. By comparing the compression evaluation index of the first compression result and the second compression result, the target compression result with better distortion can be finally selected. It should be noted that the compression evaluation index is an index that includes distortion and compression volume. Therefore, by screening the compressed data through the compression evaluation index to obtain the target compression result, the distortion and compression volume can be kept in a relatively balanced state, thereby achieving the purpose of selecting the target compression result according to the distortion and compression volume, thereby achieving the technical effect of reducing the compression volume as much as possible under the premise of ensuring the distortion, thereby solving the technical problem of the large texture volume obtained after compressing the texture in the related technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present application. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure. In the drawings:
[0011] Figure 1 It is a hardware structure block diagram of a mobile terminal of a method for compressing a texture in an embodiment of the present disclosure;
[0012] Figure 2 is a flowchart of a texture compression method according to one embodiment of the present disclosure;
[0013] Figure 3 is a schematic diagram of a texture compression combination according to an embodiment of the present disclosure;
[0014] Figure 4 is a schematic diagram of a Pareto equilibrium according to an embodiment of the present disclosure;
[0015] Figure 5ais a schematic diagram of using the prior art to compress a texture according to an embodiment of the present disclosure;
[0016] Figure 5b is a schematic diagram of using the embodiment of the present disclosure to perform texture compression according to an embodiment of the present disclosure;
[0017] Figure 6 is a schematic diagram of a texture compression device according to one embodiment of the present disclosure;
[0018] Figure 7 is a schematic diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0019] In order to enable those skilled in the art to better understand the scheme of the present disclosure, 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, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present disclosure.
[0020] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0021] In a possible implementation, the inventors have practiced and carefully studied the method commonly used in the field of image processing, but still found that the compressed image volume is large. Based on this, the present disclosure proposes a texture compression method, which first obtains the original texture, compresses the image block using a texture compression algorithm, obtains a first compression result corresponding to the image block, reuses the first compression result corresponding to the target image block, determines a second compression result corresponding to the image block, and then determines a first compression evaluation index corresponding to the first compression result and a second compression evaluation index corresponding to the second compression result based on the pixel distribution of the image block. Finally, based on the first compression evaluation index and the second compression evaluation index, the target compression result corresponding to the image block can be determined from the first compression result and the second compression result to compress the original texture. It should be noted that the compression evaluation index is used to characterize the distortion and compression volume corresponding to the compression result. Through the above method, the image block is compressed using the texture compression algorithm to obtain a first compression result. In order to improve the compression rate of the texture file by the texture compression algorithm, part of the compression results of the image block near the image block can be reused, that is, the first compression result corresponding to the target image block near the image block is reused to determine the second compression result. By comparing the compression evaluation index of the first compression result and the second compression result, the target compression result with better distortion can be finally selected. It should be noted that the compression evaluation index is an index that includes distortion and compression volume. Therefore, by screening the compressed data through the compression evaluation index to obtain the target compression result, the distortion and compression volume can be kept in a relatively balanced state, thereby achieving the purpose of selecting the target compression result according to the distortion and compression volume, thereby achieving the technical effect of reducing the compression volume as much as possible under the premise of ensuring the distortion, thereby solving the technical problem of the large texture volume obtained after compressing the texture in the related technology.
[0022] The above method embodiments involved in the present disclosure can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, the mobile terminal can be a smart phone, a tablet computer, a handheld computer, a mobile Internet device, a PAD, a game console and other terminal devices. Figure 1 is a hardware structure block diagram of a mobile terminal of a method for compressing a sticker in an embodiment of the present disclosure. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1The processor 102 (only one is shown) may include, but is not limited to, a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microprocessor (MCU), a field-programmable logic device (FPGA), a neural network processor (NPU), a tensor processing unit (TPU), an artificial intelligence (AI) type processor, etc.) and a memory 104 for storing data. In one embodiment of the present disclosure, it may also include: an input / output device 108 and a display device 110.
[0023] In some optional embodiments mainly based on game scenarios, the above-mentioned device can also provide a human-computer interaction interface with a touch-sensitive surface, which can sense finger contact and / or gestures to perform human-computer interaction with a graphical user interface (GUI). The human-computer interaction function may include the following interactions: creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, sending and receiving emails, call interface, playing digital videos, playing digital music and / or web browsing, etc. The executable instructions for executing the above-mentioned human-computer interaction functions are configured / stored in a computer program product or readable storage medium executable by one or more processors.
[0024] Those skilled in the art will understand that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0025] According to one embodiment of the present disclosure, an embodiment of a texture compression method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0026] Figure 2 is a flowchart of a texture compression method according to one embodiment of the present disclosure, such as Figure 2 As shown, the method comprises the following steps:
[0027] Step S202, obtaining an original map, wherein the original map includes a plurality of image blocks.
[0028] The original map may be understood as a map in an original format that contains multiple image blocks and has not been processed in any way.
[0029] In an optional embodiment, the original texture may be a texture in an original format produced by a developer without considering the texture volume, and therefore, it may be considered that the texture quality of the original texture is better.
[0030] It can be understood that, since the image blocks are obtained by dividing a complete original map, the original map can be compressed by subsequently compressing multiple image blocks in the original map.
[0031] Step S204: compress the image block using a texture compression algorithm to obtain a first compression result corresponding to the image block.
[0032] The texture compression algorithm may be understood as an algorithm for compressing the volume of a texture, and the first compression result may be understood as data obtained by compressing an image block using the texture compression algorithm, through which a compressed texture may be constructed.
[0033] In an optional embodiment, the texture compression algorithm may include but is not limited to: astc, etc. In the embodiment of the present disclosure, the astc algorithm is taken as an example.
[0034] In another optional embodiment, the first compression result may include Endpoints and Weights, wherein Endpoints can be understood as the minimum and maximum values of the image block pixels in the original map, and Weights can be understood as the importance or occurrence frequency of the image block.
[0035] Figure 3 is a schematic diagram of a texture compression combination according to an embodiment of the present disclosure, Figure 3 In the color space, there are a total of 8 points, such as Figure 3 As shown by the solid dots in the figure, these 8 dots can represent the pixel color distribution in a certain image block. Figure 3 The solid large dots in the image can represent the Endpoints selected when using the texture compression algorithm. The distance between the solid dots can reflect the Weights of the solid dots. The above solid dots can be obtained by interpolation of the solid large dots. Figure 3 As shown, at least five combinations of Endpoints and Weights can be used to achieve texture compression, but it is not limited thereto.
[0036] Step S206: multiplex the first compression result corresponding to the target image block to determine a second compression result corresponding to the image block, wherein the target image block is used to represent an image block associated with the image block among the multiple image blocks.
[0037] Among them, the target image block can be understood as an image block that is recorded in the lookback window and is of the same type as the current image block during the processing of each image block. The lookback window can be understood as a window that stores image blocks near the current image block that need to be attempted to be reused, that is, the target image block. The second compression result can be understood as the data obtained by reusing the first compression result corresponding to the target image block, and the compressed map can also be constructed through this data.
[0038] In an optional embodiment, the type of image block can be understood as different compression branches in the ASTC algorithm, which may include but is not limited to: 1-4 partition and 1 plane, or 1 partition and 2 planes.
[0039] Specifically, 1-4partition can be understood as dividing an image or video into different partitions, each partition can have a different size or resolution. For example, an image can be divided into four equal-sized regions, and each region can be compressed or processed independently. This partitioning method can use different compression methods or parameters in different regions to better preserve image details or reduce compression losses. 1plane can be understood as dividing an image or video into different planes, each plane containing different color or brightness information. For example, a color image can be divided into three planes, representing the red, green, and blue channels respectively, and each plane can be compressed or processed independently to better control the distortion of each color channel or reduce compression losses.
[0040] 1partition and 2plane can be understood as a method of combining the above two technologies, that is, dividing an image or video into multiple partitions, each partition contains multiple planes, so that the image or video data can be compressed or processed more flexibly to meet different application requirements.
[0041] It can be understood that since the astc algorithm first divides the texture into image blocks of N*M size and then compresses each image block separately, the second compression result corresponding to the image block can be obtained by reusing image blocks that are associated with the image block in multiple image blocks.
[0042] Step S208, based on the pixel distribution of the image block, determine a first compression evaluation index corresponding to the first compression result and a second compression evaluation index corresponding to the second compression result, wherein the first compression evaluation index is used to characterize the distortion and compression volume corresponding to the first compression result, and the second compression evaluation index is used to characterize the distortion and compression volume corresponding to the second compression result.
[0043] Among them, the first compression evaluation index can be understood as an index used to evaluate the distortion and compression volume corresponding to the first compression result, and the second compression evaluation index can be understood as an index used to evaluate the distortion and compression volume corresponding to the second compression result. The distortion can be understood as the degree of difference between the original texture file and the compressed texture file, and the compression volume can be understood as the volume of the texture compression file.
[0044] It can be understood that since the pixel distribution of the image block can reflect the distortion and compression volume of the texture compression file, the first compression evaluation index corresponding to the first compression result and the second compression evaluation index corresponding to the second compression result can be determined based on the pixel distribution of the image block.
[0045] Specifically, rate-distortion optimization (Rdo) can be understood as a method for improving video quality in video compression. This method can achieve the effect of satisfying the final video distortion while minimizing the compressed video volume by making a trade-off between the compression bit rate and the distortion in video compression. Corresponding to the embodiment of the present disclosure, the Rdo algorithm will strike a balance between the quality contrast (Distortion) between the compressed texture and the original texture and the bit rate (Bit Rate) of the compressed texture during the texture compression process, which can be understood as how many bits are needed to encode a pixel of the original image. The lower the Distortion, the better the distortion, but at the same time the Bit Rate must be higher, that is, more bits are needed to record the texture details, resulting in an excessively large texture volume. Similarly, the lower the Bit Rate, the higher the Distortion, that is, there is a lack of bits to record more texture details. At this time, the texture volume is small but the quality is deteriorated. Therefore, it is necessary to obtain the distortion and the compression volume, and then strike a balance between the two, so as to ensure that the compressed texture has a better quality and a smaller volume.
[0046] Step S210, based on the first compression evaluation index and the second compression evaluation index, determining a target compression result corresponding to the image block from the first compression result and the second compression result to compress the original map.
[0047] The target compression result may be understood as a compression result with better quality.
[0048] In an optional embodiment, the target compression result corresponding to the image block is determined from the first compression result and the second compression result, and the compression result with a higher compression evaluation index may be selected as the target compression result.
[0049] It can be understood that since the first compression result and the second compression result are both compression results obtained after compressing the original map, and since the processes of obtaining the two compression results are different, the first compression evaluation index and the second compression evaluation index will also be different. Therefore, the first compression evaluation index and the second compression evaluation index can be used to determine which of the first compression result and the second compression result has better quality, thereby obtaining the target compression result.
[0050] Through the above steps, the original map is first obtained, the image block is compressed using the map compression algorithm to obtain a first compression result corresponding to the image block, the first compression result corresponding to the target image block is reused, and the second compression result corresponding to the image block is determined. Then, based on the pixel distribution of the image block, a first compression evaluation index corresponding to the first compression result and a second compression evaluation index corresponding to the second compression result are determined. Finally, based on the first compression evaluation index and the second compression evaluation index, the target compression result corresponding to the image block can be determined from the first compression result and the second compression result to compress the original map. It should be noted that the first compression evaluation index is used to characterize the distortion and compression volume corresponding to the first compression result, and the second compression evaluation index is used to characterize the distortion and compression volume corresponding to the second compression result. Through the above method, the image block is compressed using the texture compression algorithm to obtain a first compression result. In order to improve the compression rate of the texture file by the texture compression algorithm, part of the compression results of the image block near the image block can be reused, that is, the first compression result corresponding to the target image block near the image block is reused to determine the second compression result. By comparing the compression evaluation index of the first compression result and the second compression result, the target compression result with better distortion can be finally selected. It should be noted that the compression evaluation index is an index that includes distortion and compression volume. Therefore, by screening the compressed data through the compression evaluation index to obtain the target compression result, the distortion and compression volume can be kept in a relatively balanced state, thereby achieving the purpose of selecting the target compression result according to the distortion and compression volume, thereby achieving the technical effect of reducing the compression volume as much as possible under the premise of ensuring the distortion, thereby solving the technical problem of the large texture volume obtained after compressing the texture in the related technology.
[0051] Optionally, based on the pixel distribution of the image block, a first compression evaluation index corresponding to the first compression result and a second compression evaluation index corresponding to the second compression result are determined, including: determining a target parameter based on the pixel distribution of the image block; determining a distortion corresponding to the first compression result based on the image block and the first compression result, and determining a distortion corresponding to the second compression result based on the image block and the second compression result; determining a compressed volume corresponding to the first compression result based on the first compression result, and determining a compressed volume corresponding to the second compression result based on the second compression result; determining the first compression evaluation index based on the target parameter, the distortion and the compressed volume corresponding to the first compression result, and determining the second compression evaluation index based on the target parameter, the distortion and the compressed volume corresponding to the second compression result.
[0052] Among them, the target parameter can be understood as a parameter used to reflect the effect of the compression algorithm, and can be used to make the distortion corresponding to the compression result and the compression volume corresponding to the compression result in a Pareto equilibrium state.
[0053] In an optional embodiment, the target parameter is not a fixed value and can be adjusted according to the pixel distribution of the image block.
[0054] It can be understood that the Pareto equilibrium state can be understood as an ideal state of resource allocation. Corresponding to the embodiment of the present disclosure, the Pareto equilibrium state can be understood as a state where it is impossible to control the compression volume without increasing while improving the distortion. In order to achieve the Pareto equilibrium state of distortion and compression volume, the trade-off between distortion and compression volume can be adjusted through target parameters, thereby achieving the optimal texture compression effect.
[0055] Optionally, a first compression evaluation index is determined based on the target parameter, the distortion and the compression volume corresponding to the first compression result, and a second compression evaluation index is determined based on the target parameter, the distortion and the compression volume corresponding to the second compression result, including: obtaining a first index value according to the target parameter and the compression volume corresponding to the first compression result; obtaining a second index value according to the target parameter and the compression volume corresponding to the second compression result; obtaining the first compression evaluation index according to the first index value and the distortion corresponding to the first compression result; obtaining the second compression evaluation index according to the second index value and the distortion corresponding to the second compression result.
[0056] Among them, the first index value can be understood as the value obtained by multiplying the target parameter by the compressed volume corresponding to the first compression result, and the second index value can be understood as the value obtained by multiplying the target parameter by the compressed volume corresponding to the second compression result.
[0057] Specifically, the above process can be expressed by the formula: J=D+lambda*R, where J represents the compression evaluation index, D represents the distortion, lambda represents the target parameter, and R represents the compression volume.
[0058] Through the above formula, we can get the first compression evaluation index and the second compression evaluation index. The larger the lambda, the more accurate the algorithm, and the smaller the lambda, the more distorted it is. If lambda is 0, it degenerates into the original astc compression algorithm. After substituting the values of D and R into the formula, the smaller the J value obtained, the better the final quality. In order to make the final texture compression effect better, it is necessary to find a Pareto equilibrium between R and D, as follows Figure 4 shown.
[0059] Figure 4 is a schematic diagram of a Pareto equilibrium according to an embodiment of the present disclosure, such as Figure 4 As shown, the vertical axis represents D, the horizontal axis represents R, and the straight lines of different solid and virtual colors represent areas of different brightness. The solid line area represents the brightest area, and the dotted line area composed of points represents the darkest area. The crosses of different solid and virtual colors represent compression results of different qualities. The solid cross represents a compression result with better quality, and the dotted cross represents a compression result with worse quality. Figure 4 It can be seen that when the distortion value is large, or the compression volume value is large, two compression results with better quality will appear. At this time, it can be considered that the solid cross framed between the two compression results achieves Pareto equilibrium, that is, it is a better map compression result.
[0060] Optionally, determining the degree of distortion corresponding to the first compression result based on the image block and the first compression result, and determining the degree of distortion corresponding to the second compression result based on the image block and the second compression result, includes: generating a first compressed block corresponding to the image block based on the first compression result, and generating a second compressed block corresponding to the image block based on the second compression result; reconstructing the first compressed block to obtain a first reconstructed block, and reconstructing the second compressed block to obtain a second reconstructed block; obtaining the degree of distortion corresponding to the first compression result according to the first reconstructed block and the first compressed block, and obtaining the degree of distortion corresponding to the second compression result according to the second reconstructed block and the second compressed block.
[0061] Among them, the first compressed block can be understood as a compressed block obtained by compressing the image block of the original map using a compression algorithm, the second compressed block can be understood as a compressed block obtained by multiplexing the image blocks in the first compression result, the first reconstructed block can be understood as an image block obtained by reconstructing the first compressed block, and the second reconstructed block can be understood as an image block obtained by reconstructing the second compressed block.
[0062] It can be understood that the distortion corresponding to the compression result can be obtained by contrasting the qualities of the reconstructed block and the compressed block, so that the difference between the image block and the compressed block can be quantitatively evaluated, that is, the quality of the compression result can be reflected, and then the distortion can be obtained, wherein the contrast amount can be understood as a measurement method to measure the contrast difference between two image blocks, and the contrast can refer to the degree of difference in color or brightness between different areas in the image.
[0063] Specifically, the smaller the difference between the image block and the compressed block, the better the compression result can be considered, and conversely, the larger the difference between the image block and the compressed block, the worse the compression result can be considered.
[0064] In an optional embodiment, the quality of the image block and the compressed block may be compared by using mean squared error (MSE), structural similarity index (SSIM), etc.
[0065] Optionally, based on the first compression result, a compressed volume corresponding to the first compression result is determined, and based on the second compression result, a compressed volume corresponding to the second compression result is determined, including: based on the first compression result, generating a first compressed block corresponding to the image block, and based on the second compression result, generating a second compressed block corresponding to the image block; obtaining the bit rate of the first compressed block to obtain the compressed volume corresponding to the first compression result, and obtaining the bit rate of the second compressed block to obtain the compressed volume corresponding to the second compression result.
[0066] The bit rate may be understood as the amount of data output per unit. In the embodiment of the present disclosure, it may be understood as the amount of bits required to encode a pixel unit of the original image.
[0067] In an optional embodiment, the bit number required to encode one pixel unit of the original image can be calculated by the bit rate, and then multiplied by the number of pixel units in the compressed block to obtain the total number of bits of the image. Then, by converting the total number of bits into bytes or storage units, the volume size of the image can be calculated.
[0068] It is understandable that the lower the contrast, the better the distortion, but at the same time the bit rate must be higher, that is, more bits are needed to record the texture details, resulting in a large texture size. Similarly, the lower the bit rate, the higher the contrast, that is, there are fewer bits to record more texture details. At this time, the texture size is small but the quality is indeed deteriorated. Therefore, a balance needs to be achieved between the two, that is, the above-mentioned Pareto equilibrium.
[0069] The Human Visual System (HVS) is a method to improve the effect of image compression algorithms by studying the sensitivity of the human visual system to distortion in different areas of the image. It also proposes the Just-noticeable difference (JND), which is the threshold at which the image changes before and after for the human eye to perceive it. Based on this concept, the following conclusions can be drawn: the human eye is more sensitive to changes in relative brightness values and insensitive to changes in absolute values. Therefore, in darker or brighter areas in the map, the bit rate can be considered more, otherwise the contrast amount needs to be considered more; the human eye is not sensitive to the spatial non-uniformity of background brightness, so the bit rate can be considered more in areas with higher information entropy of the map, otherwise the contrast amount needs to be considered more.
[0070] In the disclosed embodiment, by introducing the above-mentioned optimization idea into the compression algorithm of ASTC, the following effect can be finally achieved: within the distortion range imperceptible to the human eye, the volume of the texture compressed by the ASTC algorithm is reduced as much as possible, thereby greatly reducing the size of the texture in the final package of the game.
[0071] Optionally, the method further includes: determining a first image block for which a target compression result has been determined among multiple image blocks; determining an interval between the first image block and the image block, wherein the interval is used to characterize the number of image blocks spaced apart from the first image block and the image block; and in response to the interval being less than a preset interval, determining that the first image block is a target image block.
[0072] Among them, the first image block can be understood as an image block for which a compression result with better quality has been determined, and the preset interval can be understood as a smaller interval value preset in advance. When the interval is smaller than the preset interval, it can be considered that the first image block is near the image block, that is, the first image block is the target image block.
[0073] It is understandable that for the original map of M*N, it can be processed row by row starting from the first image block in the upper left corner, so the interval here is not a simple straight-line distance.
[0074] Optionally, determining a first image block among multiple image blocks for which a target compression result has been determined includes: determining a second image block among multiple image blocks for which a target compression result has been determined; and in response to a compression type of the second image block being the same as a compression type of the image block, determining the second image block to be the first image block, wherein the compression type is used to characterize the type of compression method for compressing the image block.
[0075] The second image block may be understood as an image block for which a compression result with better quality has been determined.
[0076] It is understandable that if the compression type of the second image block is the same as the compression type of the image block, that is, both are 1-4 partition and 1 plane, or 1 partition and 2 plane, but not limited thereto, the second image block can be considered as the first image block.
[0077] Through the above method, firstly, the second image block with the same compression type as the image block is determined as the first image block, and then the target image block is determined by the interval between the first image block and the image block, so that the image block with the same compression type as the image block and with a close interval and an associated relationship among multiple image blocks can be accurately obtained, that is, the target image block.
[0078] Optionally, the first compression result includes: a first endpoint set and a first weight set, the first endpoint set being used to characterize the endpoints of a value range of pixel values obtained after compressing the target image block, and the first weight set being used to characterize the value of the pixel value obtained after compressing the target image block, and the first compression result corresponding to the target image block is multiplexed to determine a second compression result corresponding to the image block, including: based on the first endpoint set corresponding to the target image block, compressing the image block using a texture compression algorithm to obtain a second weight set corresponding to the image block; based on the first weight set corresponding to the target image block, compressing the image block using a texture compression algorithm to obtain a second endpoint set corresponding to the image block; combining the first endpoint set and the second weight set, and combining the second endpoint set and the first weight set to obtain a second compression result.
[0079] Among them, the first endpoint set can be understood as the endpoint set of each image block in the first compression result, the first weight set can be understood as the weight set of each image block in the first compression result, the second endpoint set can be understood as the endpoint set of each image block obtained after multiplexing the first compression result, and the second weight set can be understood as the weight set of each image block obtained after multiplexing the first compression result.
[0080] It is understandable that in the existing related technologies, the following process is used for texture compression: first, the .astc texture file is compressed using the astc algorithm, and then the .astc texture file is compressed again using a common lossless compression algorithm, such as winzip, 7z, etc. Finally, when the player runs the game, the .astc texture file is first decompressed and passed to the graphics processor (Graphics Processing Unit, referred to as GPU), and the GPU decompresses the .astc texture in real time. On this basis, the embodiment of the present disclosure applies the idea of the Rdo algorithm to the aforementioned steps. In order to improve the compression rate of the compression algorithm for the astc texture file, it is possible to consider reusing some compression results of image blocks near the image block, for example, the endpoints or weights results of the nearby image blocks can be tried to be reused respectively, that is, the first compression result in the above step S204, and then the weights or endpoints results of the image block are recalculated according to the reused endpoints or weights, that is, the second compression result in the above step S206.
[0081] Specifically, the above process can be understood as two methods of determining the second compression result, that is, obtaining the second compression result based on the reused endpoints and the newly calculated weights, or obtaining the second compression result based on the newly calculated endpoints and the reused weights.
[0082] Optionally, based on the first compression evaluation index and the second compression evaluation index, a target compression result corresponding to the image block is determined from the first compression result and the second compression result, including: obtaining the minimum compression evaluation index between the first compression evaluation index and the second compression evaluation index; and determining that the compression result corresponding to the minimum compression evaluation index in the first compression result and the second compression result is the target compression result.
[0083] The minimum compression evaluation index may be understood as a compression evaluation index with a smaller value between the first compression evaluation index and the second compression evaluation index.
[0084] It can be understood that the smaller the compression evaluation index is, the better the quality of the compression result is. Therefore, the compression result corresponding to the minimum compression evaluation index can be determined as the target compression result.
[0085] Specifically, the main framework algorithm of the embodiment of the present disclosure has the following brief flow: first, the lambda value is adjusted according to hvs. For each image block in the lookback window, if it is a 1-4 partition and 1 plane type, try to reuse the endpoint set result, record if the quality is better, and try to reuse the weighted set result, record if the quality is better; if it is a 1 partition and 2 plane type, try to reuse the endpoint set result, record if the quality is better, and try to reuse the weighted set result, record if the quality is better. If there is an image block combination with better quality after reuse, replace the original image block result.
[0086] Figure 5a is a schematic diagram of using the prior art to compress a texture according to an embodiment of the present disclosure, such as Figure 5a As shown, using existing solutions on the market to compress textures will result in many abnormal color blocks, namely the black square parts in the figure.
[0087] Figure 5b is a schematic diagram of using the embodiment of the present disclosure to perform texture compression according to an embodiment of the present disclosure, such as Figure 5b As shown, when the scheme of the embodiment of the present disclosure is used to compress the texture, no abnormal color blocks will appear.
[0088] From the above comparison chart, it can be seen that the technical solution of the embodiment of the present disclosure can achieve the following effects: within the range of distortion that is imperceptible to the human eye, the volume of the texture compressed by the ASTC algorithm is reduced as much as possible, which greatly reduces the size of the texture in the final game package. Through testing, based on the existing game package resources, the entire game package can be reduced by 2.4G without causing any loss in game quality.
[0089] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present disclosure, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present disclosure.
[0090] In this embodiment, a device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the terms "subunit", "unit", and "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0091] Figure 6 is a schematic diagram of a texture compression device according to one embodiment of the present disclosure, such as Figure 6 As shown, the device includes: a texture acquisition module 602, which is used to acquire an original texture, wherein the original texture includes multiple image blocks; a texture compression module 604, which is used to compress the image block using a texture compression algorithm to obtain a first compression result corresponding to the image block; a result reuse module 606, which is used to reuse the first compression result corresponding to the target image block, and determine a second compression result corresponding to the image block, wherein the target image block is used to characterize an image block in multiple image blocks that has an associated relationship with the image block; an index determination module 608, which is used to determine a first compression evaluation index corresponding to the first compression result and a second compression evaluation index corresponding to the second compression result based on pixel distribution of the image block, wherein the compression evaluation index is used to characterize the distortion and compression volume corresponding to the compression result; a result determination module 610, which is used to determine a target compression result corresponding to the image block from the first compression result and the second compression result based on the first compression evaluation index and the second compression evaluation index, so as to compress the original texture.
[0092] The index determination module 608 includes: a parameter determination unit, which is used to determine the target parameter based on the pixel distribution of the image block, wherein the target parameter is used to make the distortion corresponding to the compression result and the compressed volume corresponding to the compression result in a Pareto equilibrium state; a quality determination unit, which is used to determine the distortion corresponding to the first compression result based on the image block and the first compression result, and to determine the distortion corresponding to the second compression result based on the image block and the second compression result; a volume determination unit, which is used to determine the compressed volume corresponding to the first compression result based on the first compression result, and to determine the compressed volume corresponding to the second compression result based on the second compression result; an index determination unit, which is used to determine the first compression evaluation index based on the target parameter, the distortion and the compressed volume corresponding to the first compression result, and to determine the second compression evaluation index based on the target parameter, the distortion and the compressed volume corresponding to the second compression result.
[0093] The indicator determination unit includes: a first acquisition subunit, used to obtain a first indicator value according to the target parameter and the compression volume corresponding to the first compression result; a second acquisition subunit, used to obtain a second indicator value according to the target parameter and the compression volume corresponding to the second compression result; a third acquisition subunit, used to obtain a first compression evaluation indicator according to the first indicator value and the distortion corresponding to the first compression result; and a fourth acquisition subunit, used to obtain a second compression evaluation indicator according to the second indicator value and the distortion corresponding to the second compression result.
[0094] The quality determination unit includes: a first generation subunit, used to generate a first compressed block corresponding to the image block based on the first compression result, and to generate a second compressed block corresponding to the image block based on the second compression result; a reconstruction subunit, used to reconstruct the first compressed block to obtain a first reconstructed block, and to reconstruct the second compressed block to obtain a second reconstructed block; a distortion degree acquisition subunit, used to obtain the distortion degree corresponding to the first compression result according to the first reconstructed block and the first compressed block, and to obtain the distortion degree corresponding to the second compression result according to the second reconstructed block and the second compressed block.
[0095] The volume determination unit includes: a second generation subunit, used to generate a first compressed block corresponding to the image block based on the first compression result, and to generate a second compressed block corresponding to the image block based on the second compression result; a bit rate acquisition subunit, used to acquire the bit rate of the first compressed block to obtain the compressed volume corresponding to the first compression result, and to acquire the bit rate of the second compressed block to obtain the compressed volume corresponding to the second compression result.
[0096] The above-mentioned device also includes: a first image block determination module, which is used to determine a first image block for which a target compression result has been determined among multiple image blocks; an interval determination module, which is used to determine the interval between the first image block and the image block, wherein the interval is used to characterize the number of image blocks spaced between the first image block and the image block; and a second image block determination module, which is used to determine that the first image block is a target image block in response to the interval being less than a preset interval.
[0097] The first image block determination module includes: a first image block determination unit, used to determine a second image block for which a target compression result has been determined among multiple image blocks; and a second image block determination unit, used to determine that the second image block is the first image block in response to the compression type of the second image block being the same as the compression type of the image block, wherein the compression type is used to characterize the type of compression method for compressing the image block.
[0098] The result multiplexing module 606 includes: a first compression unit, used to compress the image block based on the first endpoint set corresponding to the target image block to obtain a second weight set corresponding to the image block; a second compression unit, used to compress the image block based on the first weight set corresponding to the target image block to obtain a second endpoint set corresponding to the image block; a combining unit, used to combine the first endpoint set and the second weight set, and combine the second endpoint set and the first weight set to obtain a second compression result.
[0099] The result determination module 610 includes: an indicator acquisition unit, used to obtain the minimum compression evaluation indicator between the first compression evaluation indicator and the second compression evaluation indicator; a result determination unit, used to determine that the compression result corresponding to the minimum compression evaluation indicator in the first compression result and the second compression result is the target compression result.
[0100] It should be noted that the above-mentioned sub-units, units, and modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to this: the above-mentioned sub-units, units, and modules are all located in the same processor; or, the above-mentioned sub-units, units, and modules are located in different processors in any combination.
[0101] An embodiment of the present disclosure further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0102] Optionally, in this embodiment, the above-mentioned computer-readable storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0103] Optionally, in this embodiment, the computer-readable storage medium may be located in any one of the computer terminals in a computer terminal group in a computer network, or in any one of the mobile terminals in a mobile terminal group.
[0104] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0105] Obtain an original map, wherein the original map includes multiple image blocks;
[0106] Compressing the image block to obtain a first compression result corresponding to the image block;
[0107] multiplexing a first compression result corresponding to a target image block to determine a second compression result corresponding to the image block, wherein the target image block is used to represent an image block associated with the image block among the multiple image blocks;
[0108] Based on the pixel distribution of the image block, determine a first compression evaluation index corresponding to the first compression result and a second compression evaluation index corresponding to the second compression result, wherein the compression evaluation index is used to characterize the distortion and compression volume corresponding to the compression result;
[0109] Based on the first compression evaluation index and the second compression evaluation index, a target compression result corresponding to the image block is determined from the first compression result and the second compression result to compress the original map.
[0110] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: determining a target parameter based on the pixel distribution of the image block, wherein the target parameter is used to make the distortion corresponding to the compression result and the compression volume corresponding to the compression result in a Pareto equilibrium state; determining the distortion corresponding to the first compression result based on the image block and the first compression result, and determining the distortion corresponding to the second compression result based on the image block and the second compression result; determining the compression volume corresponding to the first compression result based on the first compression result, and determining the compression volume corresponding to the second compression result based on the second compression result; determining a first compression evaluation index based on the target parameter, the distortion and the compression volume corresponding to the first compression result, and determining a second compression evaluation index based on the target parameter, the distortion and the compression volume corresponding to the second compression result.
[0111] Optionally, the above-mentioned computer-readable storage medium is also configured to store program codes for executing the following steps: obtaining a first index value based on the compression volume corresponding to the target parameter and the first compression result; obtaining a second index value based on the compression volume corresponding to the target parameter and the second compression result; obtaining a first compression evaluation index based on the first index value and the distortion corresponding to the first compression result; obtaining a second compression evaluation index by obtaining the second index value and the distortion corresponding to the second compression result.
[0112] Optionally, the computer-readable storage medium is further configured to store a program code for executing the following steps: generating a first compressed block corresponding to the image block based on the first compression result, and generating a second compressed block corresponding to the image block based on the second compression result; reconstructing the first compressed block to obtain a first reconstructed block, and reconstructing the second compressed block to obtain a second reconstructed block; obtaining a distortion degree corresponding to the first compression result based on the first reconstructed block and the first compressed block, and obtaining a distortion degree corresponding to the second compression result based on the second reconstructed block and the second compressed block.
[0113] Optionally, the above-mentioned computer-readable storage medium is also configured to store program codes for executing the following steps: based on the first compression result, generating a first compressed block corresponding to the image block, and based on the second compression result, generating a second compressed block corresponding to the image block; obtaining the bit rate of the first compressed block to obtain the compressed volume corresponding to the first compression result, and obtaining the bit rate of the second compressed block to obtain the compressed volume corresponding to the second compression result.
[0114] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: determining a first image block for which a target compression result has been determined among multiple image blocks; determining an interval between the first image block and the image block, wherein the interval is used to characterize the number of image blocks spaced apart from the first image block and the image block; and in response to the interval being less than a preset interval, determining that the first image block is a target image block.
[0115] Optionally, the computer-readable storage medium is further configured to store program code for executing the following steps: determining a second image block among multiple image blocks for which a target compression result has been determined; in response to a compression type of the second image block being the same as a compression type of the image block, determining that the second image block is the first image block, wherein the compression type is used to characterize the type of compression method for compressing the image block.
[0116] Optionally, the computer-readable storage medium is also configured to store program codes for executing the following steps: compressing the image block based on a first endpoint set corresponding to the target image block to obtain a second weight set corresponding to the image block; compressing the image block based on a first weight set corresponding to the target image block to obtain a second endpoint set corresponding to the image block; combining the first endpoint set and the second weight set, and combining the second endpoint set and the first weight set to obtain a second compression result.
[0117] Optionally, the above-mentioned computer-readable storage medium is also configured to store program code for executing the following steps: obtaining the minimum compression evaluation index between the first compression evaluation index and the second compression evaluation index; determining that the compression result corresponding to the minimum compression evaluation index in the first compression result and the second compression result is the target compression result.
[0118] In the computer-readable storage medium of this embodiment, a technical solution is provided. An image block is compressed using a texture compression algorithm to obtain a first compression result. In order to improve the compression rate of the texture file by the texture compression algorithm, part of the compression results of the image block near the image block can be reused, that is, the first compression result corresponding to the target image block near the image block is reused to determine the second compression result. By comparing the compression evaluation index of the first compression result and the second compression result, a target compression result with better distortion can be finally selected. It should be noted that the compression evaluation index is an index that includes distortion and compression volume. Therefore, by filtering the compressed data using the compression evaluation index to obtain the target compression result, the distortion and compression volume can be kept in a relatively balanced state, achieving the purpose of selecting the target compression result according to the distortion and compression volume, thereby achieving the technical effect of reducing the compression volume as much as possible under the premise of ensuring the distortion, thereby solving the technical problem of the large texture volume obtained after compressing the texture in the related technology.
[0119] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0120] In an exemplary embodiment of the present application, a program product capable of implementing the above method of the present embodiment is stored on a computer-readable storage medium. In some possible implementations, various aspects of the embodiments of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps described in the above "Exemplary Method" section of the present embodiment according to various exemplary implementations of the present disclosure.
[0121] According to the program product for implementing the above method in the embodiment of the present disclosure, it can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the embodiment of the present disclosure is not limited to this. In the embodiment of the present disclosure, the computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0122] The program product may be in any combination of one or more computer-readable media. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive) of computer-readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0123] It should be noted that the program code contained in the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0124] An embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0125] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0126] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0127] Obtain an original map, wherein the original map includes multiple image blocks;
[0128] Compressing the image block to obtain a first compression result corresponding to the image block;
[0129] multiplexing a first compression result corresponding to a target image block to determine a second compression result corresponding to the image block, wherein the target image block is used to represent an image block associated with the image block among the multiple image blocks;
[0130] Based on the pixel distribution of the image block, determine a first compression evaluation index corresponding to the first compression result and a second compression evaluation index corresponding to the second compression result, wherein the compression evaluation index is used to characterize the distortion and compression volume corresponding to the compression result;
[0131] Based on the first compression evaluation index and the second compression evaluation index, a target compression result corresponding to the image block is determined from the first compression result and the second compression result to compress the original map.
[0132] Optionally, the processor may also be configured to perform the following steps through a computer program: determining a target parameter based on the pixel distribution of the image block, wherein the target parameter is used to make the distortion corresponding to the compression result and the compression volume corresponding to the compression result in a Pareto equilibrium state; determining the distortion corresponding to the first compression result based on the image block and the first compression result, and determining the distortion corresponding to the second compression result based on the image block and the second compression result; determining the compression volume corresponding to the first compression result based on the first compression result, and determining the compression volume corresponding to the second compression result based on the second compression result; determining a first compression evaluation index based on the target parameter, the distortion and the compression volume corresponding to the first compression result, and determining a second compression evaluation index based on the target parameter, the distortion and the compression volume corresponding to the second compression result.
[0133] Optionally, the above-mentioned processor can also be configured to perform the following steps through a computer program: obtain a first index value based on the compression volume corresponding to the target parameter and the first compression result; obtain a second index value based on the compression volume corresponding to the target parameter and the second compression result; obtain a first compression evaluation index based on the first index value and the distortion corresponding to the first compression result; obtain a second compression evaluation index based on the second index value and the distortion corresponding to the second compression result.
[0134] Optionally, the processor may also be configured to perform the following steps through a computer program: based on the first compression result, generate a first compressed block corresponding to the image block, and based on the second compression result, generate a second compressed block corresponding to the image block; reconstruct the first compressed block to obtain a first reconstructed block, and reconstruct the second compressed block to obtain a second reconstructed block; obtain a distortion degree corresponding to the first compression result based on the first reconstructed block and the first compressed block, and obtain a distortion degree corresponding to the second compression result based on the second reconstructed block and the second compressed block.
[0135] Optionally, the above-mentioned processor can also be configured to perform the following steps through a computer program: based on the first compression result, generate a first compressed block corresponding to the image block, and based on the second compression result, generate a second compressed block corresponding to the image block; obtain the bit rate of the first compressed block to obtain the compressed volume corresponding to the first compression result, and obtain the bit rate of the second compressed block to obtain the compressed volume corresponding to the second compression result.
[0136] Optionally, the processor may also be configured to perform the following steps through a computer program: determining a first image block for which a target compression result has been determined among a plurality of image blocks; determining an interval between the first image block and the image block, wherein the interval is used to characterize the number of image blocks spaced apart from the first image block and the image block; and in response to the interval being less than a preset interval, determining that the first image block is a target image block.
[0137] Optionally, the processor may also be configured to perform the following steps through a computer program: determining a second image block among multiple image blocks for which a target compression result has been determined; and in response to the compression type of the second image block being the same as the compression type of the image block, determining that the second image block is the first image block, wherein the compression type is used to characterize the type of compression method for compressing the image block.
[0138] Optionally, the processor may also be configured to perform the following steps through a computer program: compressing the image block based on a first endpoint set corresponding to the target image block to obtain a second weight set corresponding to the image block; compressing the image block based on a first weight set corresponding to the target image block to obtain a second endpoint set corresponding to the image block; combining the first endpoint set and the second weight set, and combining the second endpoint set and the first weight set to obtain a second compression result.
[0139] Optionally, the processor may also be configured to perform the following steps through a computer program: obtaining the minimum compression evaluation index between the first compression evaluation index and the second compression evaluation index; and determining that the compression result corresponding to the minimum compression evaluation index in the first compression result and the second compression result is the target compression result.
[0140] In the electronic device of this embodiment, a technical solution is provided. An image block is compressed using a texture compression algorithm to obtain a first compression result. In order to improve the compression rate of the texture file by the texture compression algorithm, part of the compression results of the image block near the image block can be reused, that is, the first compression result corresponding to the target image block near the image block is reused to determine the second compression result. By comparing the compression evaluation index of the first compression result and the second compression result, a target compression result with better distortion can be finally selected. It should be noted that the compression evaluation index is an index that includes distortion and compression volume. Therefore, by screening the compressed data using the compression evaluation index to obtain the target compression result, the distortion and compression volume can be kept in a relatively balanced state, achieving the purpose of selecting the target compression result according to the distortion and compression volume, thereby achieving the technical effect of reducing the compression volume as much as possible under the premise of ensuring the distortion, thereby solving the technical problem of the large texture volume obtained after compressing the texture in the related technology.
[0141] Figure 7 is a schematic diagram of an electronic device according to an embodiment of the present disclosure. Figure 7 As shown, the electronic device 700 is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0142] like Figure 7As shown, the electronic device 700 is in the form of a general computing device. The components of the electronic device 700 may include but are not limited to: at least one processor 710, at least one memory 720, a bus 730 connecting different system components (including the memory 720 and the processor 710), and a display 740.
[0143] The memory 720 stores program codes, which can be executed by the processor 710, so that the processor 710 executes the steps described in the method part of the embodiment of the present application according to various exemplary embodiments of the present disclosure.
[0144] The memory 720 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 7201 and / or a cache memory unit 7202, and may further include a read-only memory unit (ROM) 7203, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
[0145] In some examples, the memory 720 may also include a program / utility 7204 having a set (at least one) of program modules 7205, such program modules 7205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may include the implementation of a network environment. The memory 720 may further include a memory remotely disposed relative to the processor 710, and these remote memories may be connected to the electronic device 700 via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0146] Bus 730 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a local bus of processor 710, or any of a variety of bus architectures.
[0147] The display 740 may be, for example, a touch screen type liquid crystal display (LCD) that enables a user to interact with a user interface of the electronic device 700 .
[0148] Optionally, the electronic device 700 may also communicate with one or more external devices 800 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device 700, and / or any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 750. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 760. Figure 7 As shown, the network adapter 760 communicates with other modules of the electronic device 700 via the bus 730. It should be understood that although Figure 7 Not shown, other hardware and / or software modules may be used in conjunction with electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0149] The electronic device 700 may further include: a keyboard, a cursor control device (such as a mouse), an input / output interface (I / O interface), a network interface, a power supply and / or a camera.
[0150] It can be understood by those skilled in the art that Figure 7 The structure shown is for illustration only and does not limit the structure of the above electronic device. Figure 7 More or fewer components as shown, or with Figure 1 The memory 720 may be used to store computer programs and corresponding data, such as the computer programs and corresponding data corresponding to the texture compression method in the embodiment of the present disclosure. The processor 710 executes various functional applications and data processing by running the computer programs stored in the memory 720, that is, implementing the above-mentioned texture compression method.
[0151] The serial numbers of the above-mentioned embodiments of the present disclosure are only for description and do not represent the advantages or disadvantages of the embodiments.
[0152] In the above embodiments of the present disclosure, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0153] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be 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 interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0154] 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 units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0155] 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. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0156] 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 technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable 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: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0157] The above is only a preferred embodiment of the present disclosure. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present disclosure. These improvements and modifications should also be regarded as the scope of protection of the present disclosure.
Claims
1. A texture compression method, characterized in that: include: Obtain an original map, wherein the original map includes multiple image blocks; compressing the image block to obtain a first compression result corresponding to the image block; multiplexing the first compression result corresponding to a target image block to determine a second compression result corresponding to the image block, wherein the target image block is used to represent an image block associated with the image block among the plurality of image blocks; Determine, based on the pixel distribution of the image block, a first compression evaluation index corresponding to the first compression result and a second compression evaluation index corresponding to the second compression result, wherein the compression evaluation index is used to characterize the distortion and compression volume corresponding to the compression result; Based on the first compression evaluation index and the second compression evaluation index, a target compression result corresponding to the image block is determined from the first compression result and the second compression result to compress the original map.
2. The method according to claim 1, characterized in that Determining the first compression evaluation index corresponding to the first compression result and the second compression evaluation index corresponding to the second compression result based on the pixel distribution of the image block includes: Determining a target parameter based on pixel distribution of the image block, wherein the target parameter is used to make the distortion corresponding to the compression result and the compression volume corresponding to the compression result in a Pareto equilibrium state; Determining a degree of distortion corresponding to the first compression result based on the image block and the first compression result, and determining a degree of distortion corresponding to the second compression result based on the image block and the second compression result; Based on the first compression result, determining a compression volume corresponding to the first compression result, and based on the second compression result, determining a compression volume corresponding to the second compression result; The first compression evaluation index is determined based on the target parameter, the distortion and the compression volume corresponding to the first compression result, and the second compression evaluation index is determined based on the target parameter, the distortion and the compression volume corresponding to the second compression result.
3. The method according to claim 2, characterized in that Determining the first compression evaluation index based on the target parameter, the distortion and the compression volume corresponding to the first compression result, and determining the second compression evaluation index based on the target parameter, the distortion and the compression volume corresponding to the second compression result, includes: Obtaining a first index value according to the target parameter and a compression volume corresponding to the first compression result; Obtaining a second index value according to the target parameter and a compression volume corresponding to the second compression result; Obtaining the first compression evaluation index according to the first index value and the distortion corresponding to the first compression result; The second compression evaluation index is obtained according to the second index value and the distortion corresponding to the second compression result.
4. The method according to claim 2, characterized in that: Determining a degree of distortion corresponding to the first compression result based on the image block and the first compression result, and determining a degree of distortion corresponding to the second compression result based on the image block and the second compression result, includes: Based on the first compression result, generating a first compressed block corresponding to the image block, and based on the second compression result, generating a second compressed block corresponding to the image block; Reconstructing the first compressed block to obtain a first reconstructed block, and reconstructing the second compressed block to obtain a second reconstructed block; The distortion degree corresponding to the first compression result is obtained according to the first reconstructed block and the first compressed block, and the distortion degree corresponding to the second compression result is obtained according to the second reconstructed block and the second compressed block.
5. The method according to claim 2, characterized in that: Determining a compression volume corresponding to the first compression result based on the first compression result, and determining a compression volume corresponding to the second compression result based on the second compression result, includes: Based on the first compression result, generating a first compressed block corresponding to the image block, and based on the second compression result, generating a second compressed block corresponding to the image block; The bit rate of the first compression block is obtained to obtain a compression volume corresponding to the first compression result, and the bit rate of the second compression block is obtained to obtain a compression volume corresponding to the second compression result.
6. The method according to claim 1, characterized in that The method further comprises: Determine a first image block for which the target compression result has been determined among the plurality of image blocks; Determine an interval between the first image block and the image block, wherein the interval is used to represent the number of image blocks between the first image block and the image block; In response to the interval being smaller than a preset interval, the first image block is determined to be the target image block.
7. The method according to claim 6, characterized in that Determining the first image block for which the target compression result has been determined among the plurality of image blocks comprises: Determine a second image block for which the target compression result has been determined among the plurality of image blocks; In response to the compression type of the second image block being the same as the compression type of the image block, determining that the second image block is the first image block, wherein the compression type is used to characterize the type of compression method for compressing the image block.
8. The method according to claim 1, characterized in that The first compression result includes: a first endpoint set and a first weight set, the first endpoint set is used to represent the endpoints of the value range of the pixel value obtained after compressing the target image block, and the first weight set is used to represent the value of the pixel value obtained after compressing the target image block. Multiplexing the first compression result corresponding to the target image block to determine the second compression result corresponding to the image block includes: Based on the first endpoint set corresponding to the target image block, compress the image block to obtain a second weight set corresponding to the image block; Based on the first weight set corresponding to the target image block, compress the image block to obtain a second endpoint set corresponding to the image block; The first endpoint set and the second weight set are combined, and the second endpoint set and the first weight set are combined to obtain the second compression result.
9. The method according to claim 1, characterized in that: Determining a target compression result corresponding to the image block from the first compression result and the second compression result based on the first compression evaluation index and the second compression evaluation index includes: Obtaining a minimum compression evaluation index between the first compression evaluation index and the second compression evaluation index; Determine that, among the first compression result and the second compression result, the compression result corresponding to the minimum compression evaluation index is the target compression result.
10. A texture compression device, characterized in that: include: A texture acquisition module, used to acquire an original texture, wherein the original texture includes a plurality of image blocks; A texture compression module, used to compress the image block using a texture compression algorithm to obtain a first compression result corresponding to the image block; a result multiplexing module, configured to multiplex the first compression result corresponding to a target image block to determine a second compression result corresponding to the image block, wherein the target image block is used to represent an image block associated with the image block among the plurality of image blocks; an index determination module, configured to determine a first compression evaluation index corresponding to the first compression result and a second compression evaluation index corresponding to the second compression result based on pixel distribution of the image block, wherein the first compression evaluation index is used to characterize the distortion and compression volume corresponding to the first compression result, and the second compression evaluation index is used to characterize the distortion and compression volume corresponding to the second compression result; A result determination module is used to determine a target compression result corresponding to the image block from the first compression result and the second compression result based on the first compression evaluation index and the second compression evaluation index.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 9 when executed by a processor.
12. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 9.