Image compression processing method and device based on dichotomy, equipment and storage medium
Through the dichotomy-based image compression method, the initial parameter range is determined using the screen resolution and image display requirements of the user equipment, and the target compression parameters are found through dichotomy search, which solves the problem of low compression efficiency in traditional technology and achieves efficient Image compression processing.
Patent Information
- Application Number
- CN202411181888.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-13
AI Technical Summary
Traditional image compression technology is difficult to accurately control when determining the compression level, resulting in low compression efficiency and requires multiple attempts to meet expectations.
Using a dichotomy-based image compression method, the initial compression parameter range is determined by obtaining the screen resolution and picture display requirements of the user equipment, and a dichotomy search is carried out within this range until the target compression parameters that meet the preset conditions are found, and then Perform image compression.
The scope of determination of compression parameters is effectively narrowed, the efficiency of determination of target compression parameters is improved, the efficiency of image compression processing is significantly improved, and redundant compression attempts are avoided.
Smart Images

Figure CN119135927A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing and digital medical technology, and in particular to a method, device, computer equipment and storage medium for image compression processing based on binary division. Background Art
[0002] With the development of computer vision technology, the application of computer vision technology in the medical field is gradually expanding. It assists medical diagnosis through image processing, pattern recognition and other methods to improve the accuracy and efficiency of diagnosis. For example, computer vision is combined with artificial intelligence technology and applied to the analysis and diagnosis of various medical images such as chest X-rays, head CT, and abdominal ultrasound. However, due to the large number of patients, a large number of medical images are generated. In order to store as many medical images as possible, the images can be compressed to reduce the storage space occupied by each image. When determining the degree of compression, traditional image compression technology often relies on a fixed compression rate or a simple trial and error method. It is difficult to accurately control the compression results. Multiple attempts are required until the compressed image meets expectations, resulting in low efficiency of image compression. Therefore, how to improve the efficiency of image compression has become an urgent problem to be solved. Summary of the invention
[0003] The present application provides a method, apparatus, computer device and storage medium for image compression processing based on binary search to improve the efficiency of image compression.
[0004] In a first aspect, the present application provides a method for image compression processing based on dichotomy, the method comprising:
[0005] Get the screen resolution and image display requirements of the user's device;
[0006] Determining an initial parameter range of a compression parameter of the image to be compressed based on the screen resolution and the image display requirement;
[0007] Performing a binary search in the initial parameter range and updating the initial parameter range until the latest parameter range meets the preset conditions, thereby obtaining the target compression parameter;
[0008] Based on a preset compression strategy and the target compression parameters, the image to be compressed is compressed to obtain a compressed image.
[0009] In a second aspect, the present application further provides a picture compression processing device based on dichotomy, the device comprising:
[0010] Related information acquisition module, used to obtain the screen resolution and image display requirements of the user's device;
[0011] A parameter range determination module, used to determine an initial parameter range of a compression parameter of the image to be compressed based on the screen resolution and the image display requirement;
[0012] A compression parameter determination module, used for performing a binary search in the initial parameter range and updating the initial parameter range until the latest parameter range meets the preset conditions, thereby obtaining a target compression parameter;
[0013] The compressed image obtaining module is used to compress the image to be compressed based on a preset compression strategy and the target compression parameters to obtain a compressed image.
[0014] In a third aspect, the present application also provides a computer device, comprising a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program and implement the above-mentioned binary-based image compression processing method when executing the computer program.
[0015] In a fourth aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the above-mentioned binary-based image compression processing method.
[0016] The present application discloses a method, device, computer equipment and storage medium for image compression processing based on binary search, which obtains the screen resolution and image display requirements of a user device; determines the initial parameter range of the compression parameters of the image to be compressed based on the screen resolution and the image display requirements; performs a binary search in the initial parameter range, and updates the initial parameter range until the latest parameter range meets the preset conditions, and obtains the target compression parameter; compresses the image to be compressed based on the preset compression strategy and the target compression parameter to obtain a compressed image. The present application can determine the initial parameter range of the compression parameter based on the screen resolution and image display requirements of the user device, effectively narrow the parameter range, and searches for the target compression parameter by binary search, thereby improving the efficiency of determining the target compression parameter, thereby improving the efficiency of image compression processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1is a schematic flow chart of a first embodiment of a method for image compression processing based on binary division provided in an embodiment of the present application;
[0019] Figure 2 is a schematic flow chart of a second embodiment of a method for image compression processing based on binary division provided in an embodiment of the present application;
[0020] Figure 3 A schematic block diagram of a picture compression processing device based on binary division provided in an embodiment of the present application;
[0021] Figure 4 A schematic block diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0023] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0024] It should be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0025] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0026] The embodiments of the present application provide a method, device, computer equipment and storage medium for image compression processing based on binary search. The method for image compression processing based on binary search can be applied to a server, and the initial parameter range of the compression parameter is determined according to the screen resolution and image display requirements of the user device, effectively narrowing the parameter range, and the target compression parameter is searched by binary search, thereby improving the efficiency of determining the target compression parameter, thereby improving the efficiency of image compression processing. The server can be an independent server or a server cluster.
[0027] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0028] See also Figure 1 , Figure 1 This is a schematic flow chart of a binary-based image compression processing method provided by an embodiment of the present application. The binary-based image compression processing method can be applied to a server to determine the initial parameter range of the compression parameter according to the screen resolution and image display requirements of the user device, effectively narrow the parameter range, and search for the target compression parameter by binary search, thereby improving the efficiency of determining the target compression parameter, thereby improving the efficiency of image compression processing.
[0029] like Figure 1 As shown, the image compression processing method based on binary division specifically includes steps S101 to S104.
[0030] S101, obtaining the screen resolution and image display requirements of the user's device;
[0031] In one embodiment, the screen resolution of the user's device can be obtained by asking the user, and a setting interface can be provided to allow the user to manually input or select the device screen resolution and image display requirements.
[0032] In another embodiment, the screen resolution can also be obtained by accessing the system information of the user device. For example, in the Android system, the screen resolution can be obtained by using the `getDefaultDisplay()` method of `Wi ndowManager`; in the iOS system, the screen resolution can be obtained by using the `mainScreen` property of `UI Screen`.
[0033] In one embodiment, the image display requirements can also be obtained by analyzing user behavior, such as the zoom level and sliding speed of the user when viewing the image, and the user's image display requirements can be inferred, including the required image quality, image size limit, etc.
[0034] S102, determining an initial parameter range of a compression parameter of the image to be compressed based on the screen resolution and the image display requirement;
[0035] Furthermore, determining an initial parameter range of compression parameters of the image to be compressed based on the screen resolution and the image display requirements includes: searching for a compression parameter set corresponding to the screen resolution and the image display requirements in historical image compression records; and obtaining the initial parameter range based on a maximum compression parameter and a minimum compression parameter in the compression parameter set.
[0036] In one embodiment, the screen resolution determines the number of available pixels and has a significant impact on the display quality of the image.
[0037] In one embodiment, the compression parameter may be picture resolution, image size, etc.
[0038] In one embodiment, the historical image compression record includes the screen resolution, image display requirements, and corresponding compression parameters when the image was compressed.
[0039] In one embodiment, according to the current screen resolution and image display requirements, historical screen resolutions and historical image display requirements similar to the current screen resolution and image display requirements are screened out from the historical image compression records. Compression parameters corresponding to the screened historical screen resolutions and historical image display requirements are obtained, and a compression parameter set is generated. In one embodiment, at least one compression parameter in the compression parameter set is sorted according to size, and a maximum compression parameter and a minimum compression parameter are determined. The maximum compression parameter is used as the upper limit of the initial parameter range, and the minimum compression parameter is used as the lower limit of the initial parameter range.
[0040] In a specific embodiment, the similarity between the current screen resolution and the historical screen resolution and the historical screen resolution can be determined by comparing the difference between the current screen resolution and the historical screen resolution and the difference between the various data in the current picture display requirement and the various data in the historical picture display requirement. Corresponding weights can be set for the screen resolution and the picture display requirement, respectively, and the final similarity is calculated by weight. The historical screen resolution and picture display requirement whose similarity exceeds a preset similarity threshold can be considered to be similar to the current screen resolution and picture display requirement.
[0041] It is understandable that the compression parameters obtained from the historical image compression records are the best compression parameters for the historical images to be compressed. Therefore, the obtained initial parameter range effectively narrows the parameter range, can speed up the efficiency of determining the compression parameters, and thus improve the image compression efficiency.
[0042] S103, performing a binary search in the initial parameter range, and updating the initial parameter range until the latest parameter range meets the preset conditions, thereby obtaining a target compression parameter;
[0043] In one embodiment, first, the median value of the initial parameter range is selected as the first compression parameter, and the image to be compressed is compressed according to the first compression parameter to obtain a compressed image. Then, the quality of the compressed image is evaluated by a preset quality evaluation model (such as PSNR, SSIM and other indicators). Then, the parameter range is adjusted according to the evaluation result to obtain the latest parameter range: if the compression quality meets the requirements and the file size is better than expected, continue searching on the right side of the current parameter value; otherwise, search on the left side until the latest parameter range meets the preset conditions, stop the binary search, and use the median value of the latest parameter range as the target compression parameter.
[0044] In one embodiment, the preset condition can be set by the user to determine when to stop searching.
[0045] S104: compress the image to be compressed based on a preset compression strategy and the target compression parameter to obtain a compressed image.
[0046] In one embodiment, the compression strategy may include a compression algorithm or a compression resource allocation condition of the image to be compressed.
[0047] In one embodiment, the image to be compressed is compressed according to the compression strategy and the target compression parameters, the compressed image is saved to a specified location, and relevant information of the compressed image is recorded in the historical compressed image record, such as device screen resolution, image display requirements, compression parameters, compression time, etc.
[0048] Furthermore, before compressing the image to be compressed based on a preset compression strategy and the target compression parameters to obtain the compressed image, it also includes: obtaining resource usage of the user device, adjusting the compression strategy of the image to be compressed based on the resource usage, so as to compress the image to be compressed based on the compression strategy and according to the target compression parameters to obtain a compressed image.
[0049] In one embodiment, resource usage of the user equipment is obtained, including CPU, memory, storage space, etc. Specifically, a monitoring tool may be used to monitor the resource usage of the user equipment.
[0050] In one embodiment, based on the acquired resource usage, the performance and available resources of the user equipment are analyzed to determine whether a high-load compression task can be performed, or whether the compression algorithm and parameters need to be optimized to reduce resource consumption.
[0051] In one embodiment, the compression strategy of the images to be compressed is adjusted according to the analysis results. For example, if the user device has high performance and sufficient resources, a higher quality compression algorithm can be selected and all images to be compressed can be compressed; if the user device has low performance or limited resources, a lighter compression algorithm may need to be selected, or the images to be compressed may need to be compressed in batches. The compression strategy is intelligently adjusted according to the device resource usage, and the CPU and memory usage are effectively managed to avoid unnecessary burden on the system.
[0052] In one embodiment, the adjusted compression strategy is applied to the image to be compressed so as to perform compression based on the target compression parameters.
[0053] The above-mentioned embodiment provides a method, device, computer equipment and storage medium for image compression processing based on binary search, which obtains the screen resolution and image display requirements of the user device; determines the initial parameter range of the compression parameters of the image to be compressed based on the screen resolution and the image display requirements; performs a binary search in the initial parameter range, and updates the initial parameter range until the latest parameter range meets the preset conditions, and obtains the target compression parameter; compresses the image to be compressed based on the preset compression strategy and the target compression parameter to obtain a compressed image. The present application can determine the initial parameter range of the compression parameter based on the screen resolution and image display requirements of the user device, effectively narrow the parameter range, and searches for the target compression parameter by binary search, thereby improving the efficiency of determining the target compression parameter, thereby improving the efficiency of image compression processing.
[0054] See also Figure 2 , Figure 2 This is a schematic flow chart of a binary-based image compression processing method provided by an embodiment of the present application. The binary-based image compression processing method can be applied to a server to find target compression parameters through binary search, thereby improving the efficiency of determining the target compression parameters, avoiding redundant compression attempts, and thus improving the efficiency of image compression processing.
[0055] like Figure 2 As shown, the image compression processing method based on binary division specifically includes steps S201 to S206.
[0056] S201. Based on the maximum compression parameter and the minimum compression parameter, obtain a median value of the initial parameter range as a first compression parameter;
[0057] S202: compress the image to be compressed based on the first compression parameter to obtain a first compressed image;
[0058] S203: Based on a preset compressed picture quality assessment rule, assess the quality of the first compressed picture to obtain a first quality score;
[0059] S204: Compare a preset quality score threshold with the first quality score to obtain a comparison result;
[0060] S205: Based on the comparison result, update the maximum compression parameter or the minimum compression parameter to obtain the latest parameter range;
[0061] S206: When the difference between the maximum compression parameter and the minimum compression parameter in the latest parameter range is less than or equal to a preset difference threshold, use the first compression parameter as the target compression parameter.
[0062] In one embodiment, the maximum compression parameter is used as the parameter upper limit Q_max of the initial parameter range, and the minimum compression parameter is used as the parameter lower limit Q_min of the initial parameter range.
[0063] In one embodiment, a median value Q_mid=(Q_min+Q_max) / 2 of the maximum compression parameter and the minimum compression parameter is calculated.
[0064] In one embodiment, a preset compressed image quality assessment rule (such as PSNR, SSIM and other indicators) is used to perform quality assessment on the first compressed image to obtain a first quality score.
[0065] In one embodiment, a preset quality score threshold is compared with the first quality score. If the first quality score is higher than or equal to the quality score threshold, it indicates that the current compression parameter may be too large; if the first quality score is lower than the quality score threshold, it indicates that the current compression parameter may be too small.
[0066] Further, comparing a preset quality score threshold with the first quality score to obtain a comparison result includes: acquiring user preference information and performance information of the user device; and analyzing the user preference information and the performance information to obtain the quality score threshold.
[0067] In one embodiment, user preference information may be obtained in a variety of ways, such as through user-set preferences, user historical behavior data, user feedback, etc. Such information may include user requirements for image quality, tolerance for compression speed, preference for file size, etc.
[0068] In one embodiment, the device performance information can be obtained through the system information of the device, such as processor model, memory size, storage space, etc. In addition, the current status information of the device can also be obtained, such as CPU occupancy, memory usage, etc.
[0069] In one embodiment, the user's requirements for image quality and the device's image processing capabilities can be analyzed based on the user preference information and the device's performance information. For example, if the user has high requirements for image quality and the device has good performance, a higher quality score threshold can be set; conversely, if the user has low requirements for image quality or the device has poor performance, a lower quality score threshold can be set.
[0070] In one embodiment, the method of analyzing user preferences and device performance may adopt various methods such as machine learning, data analysis, rule formulation, etc. For example, algorithms such as decision trees and logistic regression may be used to predict the user's acceptance of quality scores; or a quality score threshold related to performance may be set based on device performance indicators.
[0071] In one embodiment, determining the quality score threshold according to user preference and device performance can make the compression process more in line with the actual needs of the user and the processing capabilities of the device, thereby improving the user experience.
[0072] Furthermore, based on the comparison result, the maximum compression parameter or the minimum compression parameter is updated to obtain the latest parameter range, including: when the comparison result is that the first quality score is greater than or equal to a preset quality score threshold, the maximum compression parameter is updated to the first compression parameter to obtain the latest parameter range; when the comparison result is that the first quality score is less than the quality score threshold, the minimum compression parameter is updated to the sum of the first compression parameter and a preset quality step value to obtain the latest parameter range.
[0073] In one embodiment, if the comparison result is that the first quality score is higher than or equal to the quality score threshold, the maximum compression parameter is updated to the first compression parameter, otherwise the minimum compression parameter is updated to the sum of the first compression parameter and the preset quality step value, and a new parameter range, i.e., the latest parameter range, is obtained. The quality step value may be equal to the preset difference threshold.
[0074] In one embodiment, if the difference between the maximum compression parameter and the minimum compression parameter in the latest parameter range is less than or equal to a preset difference threshold, it means that a satisfactory compression parameter interval has been found, and the median of the latest parameter range is obtained as the target compression parameter.
[0075] Further, after updating the maximum compression parameter or the minimum compression parameter based on the comparison result to obtain the latest parameter range, the method further includes: when the difference between the maximum compression parameter and the minimum compression parameter in the latest parameter range is greater than a preset difference threshold, performing a binary search in the latest parameter range and updating the latest parameter range until the latest parameter range meets the preset conditions, and obtaining the target compression parameter.
[0076] In one embodiment, when the difference between the maximum compression parameter and the minimum compression parameter in the latest parameter range is greater than a preset difference threshold, obtain the median value of the latest parameter range as the second compression parameter; compress the picture to be compressed based on the second compression parameter to obtain a second compressed picture; evaluate the quality of the second compressed picture based on the compressed picture quality evaluation rule to obtain a second quality score; compare the preset quality score threshold with the second quality score to obtain a comparison result; update the maximum compression parameter or the minimum compression parameter based on the comparison result to obtain a second parameter range as the latest parameter range; when the difference between the maximum compression parameter and the minimum compression parameter in the latest parameter range is less than or equal to the preset difference threshold, obtain the second compression parameter as the target compression parameter.
[0077] In one embodiment, the above process is iterated continuously, and each iteration will narrow the parameter range until the compression parameter that meets the conditions is found.
[0078] Exemplarily, assume that the lower limit of compression quality (i.e., the minimum compression parameter) Q_min = 0%, the upper limit of compression quality (i.e., the maximum compression parameter) Q_max = 100%, the set compression quality step value ΔQ = 1%, and the set quality threshold is T. Perform a binary search in the initial parameter range (Q_min, Q_max).
[0079] Specifically, a. Calculate the midpoint quality Q_mid = (Q_min + Q_max) / 2;
[0080] b. Compress the picture using Q_mid to obtain the compressed picture C;
[0081] c. Evaluate the quality of the compressed picture. Use the selected index to evaluate the difference between C and the original picture. If the quality score ≥ T and there is further compression space (for example, Q_mid < Q_max), then update the upper limit Q_max = Q_mid, otherwise (the quality does not meet the standard or is already close to the minimum compression), update the lower limit Q_min = Q_mid + ΔQ (ensure that the search interval is not closed);
[0082] d. Check whether the stop search condition (Q_max-Q_min≤ΔQ) is met: If the stop condition is met, jump out of the loop and record the current Q_mi d as the optimal compression quality. If not, return to step 1 to continue the binary search until the stop condition is met.
[0083] In the above embodiment, the target compression parameters are found by binary search, which improves the efficiency of determining the target compression parameters, avoids redundant compression attempts, and thus improves the efficiency of image compression processing. In addition, the quality score threshold can be intelligently adjusted according to user preferences and device performance to ensure that the quality of the compressed image is close to or meets user expectations, maintaining a good visual experience.
[0084] See also Figure 3 , Figure 3 The embodiment of the present application provides a schematic block diagram of a binary-based image compression processing device, which is used to execute the aforementioned binary-based image compression processing method. The binary-based image compression processing device can be configured on a server.
[0085] like Figure 3 As shown, the image compression processing device 300 based on the binary method includes:
[0086] Related information acquisition module 301, used to obtain the screen resolution and image display requirements of the user's device;
[0087] A parameter range determination module 302, configured to determine an initial parameter range of a compression parameter of the image to be compressed based on the screen resolution and the image display requirement;
[0088] A compression parameter determination module 303 is used to perform a binary search in the initial parameter range and update the initial parameter range until the latest parameter range meets the preset conditions to obtain the target compression parameter;
[0089] The compressed image obtaining module 304 is used to compress the image to be compressed based on a preset compression strategy and the target compression parameter to obtain a compressed image.
[0090] Furthermore, the parameter range determination module 302 includes:
[0091] A parameter set obtaining unit, used for searching the compression parameter set corresponding to the screen resolution and the picture display requirement in the historical picture compression record;
[0092] The parameter range obtaining unit is used to obtain the initial parameter range based on the maximum compression parameter and the minimum compression parameter in the compression parameter set.
[0093] Furthermore, the compression parameter determination module 303 includes:
[0094] A first compression parameter determination unit, configured to obtain a median value of the initial parameter range as a first compression parameter based on the maximum compression parameter and the minimum compression parameter;
[0095] A first compressed picture obtaining unit, configured to compress the picture to be compressed based on the first compression parameter to obtain a first compressed picture;
[0096] A first scoring quality obtaining unit, configured to evaluate the quality of the first compressed image based on a preset compressed image quality evaluation rule to obtain a first quality score;
[0097] A comparison result obtaining unit, wherein the user compares a preset quality score threshold with the first quality score to obtain a comparison result;
[0098] A latest parameter range obtaining unit, configured to update the maximum compression parameter or the minimum compression parameter based on the comparison result to obtain a latest parameter range;
[0099] The target compression parameter determination unit is configured to use the first compression parameter as the target compression parameter when the difference between the maximum compression parameter and the minimum compression parameter in the latest parameter range is less than or equal to a preset difference threshold.
[0100] Furthermore, the latest parameter range obtaining unit is also used for:
[0101] When the comparison result is that the first quality score is greater than or equal to a preset quality score threshold, updating the maximum compression parameter to the first compression parameter to obtain the latest parameter range;
[0102] When the comparison result is that the first quality score is less than the quality score threshold, the minimum compression parameter is updated to the sum of the first compression parameter and a preset quality step value to obtain the latest parameter range.
[0103] Furthermore, the comparison result obtaining unit includes:
[0104] An information acquisition subunit, used to acquire user preference information and performance information of the user equipment;
[0105] The scoring threshold obtaining subunit is used to analyze the user preference information and the performance information to obtain the quality scoring threshold.
[0106] Furthermore, the compression parameter determination module 303 further includes:
[0107] The latest parameter range updating unit is used to perform a binary search in the latest parameter range when the difference between the maximum compression parameter and the minimum compression parameter in the latest parameter range is greater than a preset difference threshold, and update the latest parameter range until the latest parameter range meets the preset conditions to obtain the target compression parameter.
[0108] Furthermore, the image compression processing device 300 based on the binary method further includes:
[0109] A compression strategy acquisition module is used to obtain resource usage of the user device, and adjust the compression strategy of the image to be compressed based on the resource usage, so as to compress the image to be compressed according to the target compression parameters based on the compression strategy to obtain a compressed image.
[0110] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0111] The above-mentioned device can be implemented in the form of a computer program. Figure 4 Runs on the computer device shown.
[0112] See also Figure 4 , Figure 4 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server.
[0113] See also Figure 4 The computer device includes a processor, a memory and a network interface connected through a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.
[0114] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any one of the binary-based image compression processing methods.
[0115] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0116] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any image compression processing method based on the binary method.
[0117] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will appreciate that Figure 4The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0118] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0119] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0120] Get the screen resolution and image display requirements of the user's device;
[0121] Determining an initial parameter range of a compression parameter of the image to be compressed based on the screen resolution and the image display requirement;
[0122] Performing a binary search in the initial parameter range and updating the initial parameter range until the latest parameter range meets the preset conditions, thereby obtaining the target compression parameter;
[0123] Based on a preset compression strategy and the target compression parameters, the image to be compressed is compressed to obtain a compressed image.
[0124] In one embodiment, when determining the initial parameter range of the compression parameter of the image to be compressed based on the screen resolution and the image display requirement, the processor is used to implement:
[0125] Searching the historical picture compression records for a set of compression parameters corresponding to the screen resolution and the picture display requirements;
[0126] The initial parameter range is obtained based on a maximum compression parameter and a minimum compression parameter in the compression parameter set.
[0127] In one embodiment, the processor performs a binary search in the initial parameter range and updates the initial parameter range until the latest parameter range meets the preset conditions, and when the target compression parameter is obtained, is used to implement:
[0128] Based on the maximum compression parameter and the minimum compression parameter, obtaining a median value of the initial parameter range as a first compression parameter;
[0129] Based on the first compression parameter, compress the image to be compressed to obtain a first compressed image;
[0130] Based on a preset compressed picture quality assessment rule, assess the quality of the first compressed picture to obtain a first quality score;
[0131] Comparing a preset quality score threshold with the first quality score to obtain a comparison result;
[0132] Based on the comparison result, the maximum compression parameter or the minimum compression parameter is updated to obtain the latest parameter range;
[0133] When the difference between the maximum compression parameter and the minimum compression parameter in the latest parameter range is less than or equal to a preset difference threshold, the first compression parameter is used as the target compression parameter.
[0134] In one embodiment, when the processor updates the maximum compression parameter or the minimum compression parameter based on the comparison result to obtain the latest parameter range, it is configured to implement:
[0135] When the comparison result is that the first quality score is greater than or equal to a preset quality score threshold, updating the maximum compression parameter to the first compression parameter to obtain the latest parameter range;
[0136] When the comparison result is that the first quality score is less than the quality score threshold, the minimum compression parameter is updated to the sum of the first compression parameter and a preset quality step value to obtain the latest parameter range.
[0137] In one embodiment, when the processor compares a preset quality score threshold with the first quality score to obtain a comparison result, the processor is used to implement:
[0138] Obtaining user preference information and performance information of the user device;
[0139] The user preference information and the performance information are analyzed to obtain the quality score threshold.
[0140] In one embodiment, after the processor updates the maximum compression parameter or the minimum compression parameter based on the comparison result to obtain the latest parameter range, the processor is further configured to implement:
[0141] When the difference between the maximum compression parameter and the minimum compression parameter in the latest parameter range is greater than a preset difference threshold, a binary search is performed in the latest parameter range, and the latest parameter range is updated until the latest parameter range meets the preset conditions, thereby obtaining the target compression parameter.
[0142] In one embodiment, the processor is further configured to implement, before compressing the image to be compressed based on the preset compression strategy and the target compression parameter to obtain the compressed image:
[0143] Obtain resource usage of the user equipment, and adjust the compression strategy of the image to be compressed based on the resource usage, so as to compress the image to be compressed according to the target compression parameter based on the compression strategy to obtain a compressed image.
[0144] A computer-readable storage medium is also provided in an embodiment of the present application, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and the processor executes the program instructions to implement any one of the binary-based image compression processing methods provided in the embodiments of the present application.
[0145] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Medi a Card, SMC), a secure digital (Secure Digital, SD) card, a flash memory card (Flash Card), etc., equipped on the computer device.
[0146] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A method for image compression processing based on binary division, characterized in that: include: Get the screen resolution and image display requirements of the user's device; Determining an initial parameter range of a compression parameter of the image to be compressed based on the screen resolution and the image display requirement; Performing a binary search in the initial parameter range and updating the initial parameter range until the latest parameter range meets the preset conditions, thereby obtaining the target compression parameter; Based on a preset compression strategy and the target compression parameters, the image to be compressed is compressed to obtain a compressed image.
2. The image compression processing method based on binary division according to claim 1 is characterized in that: The determining, based on the screen resolution and the picture display requirement, an initial parameter range of a compression parameter of the picture to be compressed includes: Searching the historical picture compression records for a set of compression parameters corresponding to the screen resolution and the picture display requirements; The initial parameter range is obtained based on a maximum compression parameter and a minimum compression parameter in the compression parameter set.
3. The image compression processing method based on binary division according to claim 2 is characterized in that: The binary search is performed in the initial parameter range, and the initial parameter range is updated until the latest parameter range meets the preset conditions, and the target compression parameter is obtained, including: Based on the maximum compression parameter and the minimum compression parameter, obtaining a median value of the initial parameter range as a first compression parameter; Based on the first compression parameter, compress the image to be compressed to obtain a first compressed image; Based on a preset compressed picture quality assessment rule, assess the quality of the first compressed picture to obtain a first quality score; Comparing a preset quality score threshold with the first quality score to obtain a comparison result; Based on the comparison result, the maximum compression parameter or the minimum compression parameter is updated to obtain the latest parameter range; When the difference between the maximum compression parameter and the minimum compression parameter in the latest parameter range is less than or equal to a preset difference threshold, the first compression parameter is used as the target compression parameter.
4. The image compression processing method based on binary division according to claim 3 is characterized in that: The updating of the maximum compression parameter or the minimum compression parameter based on the comparison result to obtain the latest parameter range includes: When the comparison result is that the first quality score is greater than or equal to a preset quality score threshold, updating the maximum compression parameter to the first compression parameter to obtain the latest parameter range; When the comparison result is that the first quality score is less than the quality score threshold, the minimum compression parameter is updated to the sum of the first compression parameter and a preset quality step value to obtain the latest parameter range.
5. The image compression processing method based on binary division according to claim 3 is characterized in that: The comparing a preset quality score threshold with the first quality score to obtain a comparison result includes: Obtaining user preference information and performance information of the user device; The user preference information and the performance information are analyzed to obtain the quality score threshold.
6. The image compression processing method based on binary division according to claim 3 is characterized in that: After the maximum compression parameter or the minimum compression parameter is updated based on the comparison result to obtain the latest parameter range, the method further includes: When the difference between the maximum compression parameter and the minimum compression parameter in the latest parameter range is greater than a preset difference threshold, a binary search is performed in the latest parameter range, and the latest parameter range is updated until the latest parameter range meets the preset conditions, thereby obtaining the target compression parameter.
7. The image compression processing method based on binary division according to any one of claims 1 to 6, characterized in that: The method further comprises: compressing the image to be compressed based on the preset compression strategy and the target compression parameter, before obtaining the compressed image; Obtain resource usage of the user equipment, and adjust the compression strategy of the image to be compressed based on the resource usage, so as to compress the image to be compressed according to the target compression parameter based on the compression strategy to obtain a compressed image.
8. A picture compression processing device based on binary division, characterized in that: include: Related information acquisition module, used to obtain the screen resolution and image display requirements of the user's device; A parameter range determination module, used to determine an initial parameter range of a compression parameter of the image to be compressed based on the screen resolution and the image display requirement; A compression parameter determination module, used for performing a binary search in the initial parameter range and updating the initial parameter range until the latest parameter range meets the preset conditions, thereby obtaining a target compression parameter; The compressed image obtaining module is used to compress the image to be compressed based on a preset compression strategy and the target compression parameters to obtain a compressed image.
9. A computer device, characterized in that: The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is used to execute the computer program and implement the binary-based image compression processing method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the image compression processing method based on binary division as described in any one of claims 1 to 7.
Citation Information
Cited By
Construction method and system of ancient painting image data set
CN121305268A
