Image compression method and device for electronic table card
By calculating the number of consecutive repeating bytes of image data in the electronic table card, and automatically selecting extended stroke encoding or JPEG algorithm for compression, the problem of slow image transmission speed of electronic table card is solved, and efficient image compression and transmission is achieved.
Patent Information
- Application Number
- CN202510193946.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-05-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When transmitting image data of participants, electronic table cards have problems with slow transmission speed due to large data volume and communication bandwidth limitations.
By calculating the number of consecutive repeating bytes in the image data to be displayed, the appropriate compression algorithm is automatically selected. If the number of consecutive repeating bytes is large, use the extended stroke encoding algorithm for lossless compression; if there are fewer, use the JPEG algorithm for lossy compression.
It effectively improves the image transmission speed, uses the high repeatability of electronic table card images to achieve a high compression ratio, and avoids the problem of slow transmission speed.
Smart Images

Figure CN120050437A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image compression technology, and particularly relates to an image compression method and device for an electronic nameplate. Background Art
[0002] The electronic nameplate displays relevant information of participants through an electronic display screen, and has the advantages of environmental protection, energy saving and fast updating compared with traditional paper nameplates, and is widely used in meeting places.
[0003] The electronic nameplate displays personnel information through images. Due to the large number of participants and large image sizes, the amount of image data to be transmitted is very large; and currently, the image transmission method of the electronic nameplate is to directly transmit the image data to the display screen, and due to the communication bandwidth limitation, there is a problem of slow transmission speed. Summary of the Invention
[0004] In order to solve the problems existing in the above-mentioned prior art, the purpose of this application is to provide an image compression method and device for an electronic nameplate.
[0005] In a first aspect, this application provides an image compression method for an electronic nameplate, including:
[0006] Obtain the image data to be displayed, and calculate the number of consecutive repeated bytes in the image data to be displayed; the number of consecutive repeated bytes represents the total number of bytes that appear continuously for multiple times;
[0007] When the proportion of the number of consecutive repeated bytes in the total number of bytes of the image data to be displayed is not less than a preset proportion, compress the image data to be displayed based on the extended run-length encoding algorithm to obtain compressed data;
[0008] When the proportion of the number of consecutive repeated bytes in the total number of bytes of the image data to be displayed is less than the preset proportion, compress the image data to be displayed based on the JPEG algorithm to obtain compressed data.
[0009] In one embodiment, the step of compressing the image data to be displayed based on the extended run-length encoding algorithm to obtain compressed data includes:
[0010] Encode the data sequence of the image data to be displayed with a single data byte and the run byte of the data byte to obtain compressed data; the data sequence includes the data of each color channel in the image data to be displayed; the run byte represents the number of consecutive repetitions of the corresponding data byte at the current position; when the number of consecutive repetitions is a multiple of the byte maximum value, a termination byte is also configured at the end of the run byte; the byte maximum value is the maximum number of consecutive repetitions that a single run byte can represent; the termination byte is used to indicate the termination of the run byte.
[0011] Preferably, the maximum value of the byte is 255; the cut-off byte is 0x00.
[0012] In one embodiment, the method further includes:
[0013] When there are multiple pieces of image data to be displayed, perform image grouping; the image grouping includes the following steps:
[0014] Select any piece of image data to be displayed as the reference image data, and subtract the other image data to be displayed from the reference image data to obtain a difference matrix;
[0015] For each difference matrix, if the non-zero values in the difference matrix are only distributed in the central region of the difference matrix, it is determined that the corresponding image data to be displayed and the reference image data are data in the same group; the central region represents a matrix region with a preset size in the center of the difference matrix;
[0016] Repeat the image grouping step to divide the multiple pieces of image data to be displayed into several groups;
[0017] Perform simplified compression on the data in the same group to obtain the simplified compression data of each piece of image data in the same group; the simplified compression includes performing single compression on the background data shared by the image data in the same group.
[0018] In one embodiment, the step of performing simplified compression on the data in the same group to obtain the simplified compression data of each piece of image data in the same group includes:
[0019] Divide the background region and the information region in the image data according to the difference matrix of the data in the same group; the background region includes the regions with the same values in the data in the same group; the information region includes the regions with different values in the data in the same group;
[0020] Divide each piece of image data in the same group with the information region to obtain information image data; the display content of the information image data includes at least one of the name, title, and affiliated unit of the participants;
[0021] Divide the reference image data with the background region and fill the image data in the vacant region to obtain background image data;
[0022] Based on a preferred compression algorithm, compress the background image data and each piece of information image data respectively to obtain the simplified compression data of the data in the same group.
[0023] In one embodiment, the step of dividing the background region and the information region in the image data according to the difference matrix of the data in the same group includes:
[0024] Respectively take the difference regions in the difference matrices of the data in the same group; the difference region represents the smallest matrix region containing all non-zero pixel points in the difference matrix;
[0025] Compare the difference regions of each difference matrix, and select the largest difference region as the information region;
[0026] Cut off the information region in the difference matrix to obtain the background region.
[0027] In one embodiment, the steps of respectively compressing the background image data and each information image data based on a preferred compression algorithm to obtain the simplified compressed data of the same group of data include:
[0028] Based on the number of consecutive repeated bytes of the reference image data, select a compression algorithm with a high compression ratio and compress the background image data to obtain background compressed data;
[0029] Compress the information image data based on the JPEG algorithm to obtain information compressed data, and add the parameters of the information image data before the information compressed data; the parameters of the information image data include the size and position of the information image data;
[0030] Use the background compressed data and each information compressed data as the simplified compressed data of the same group of data.
[0031] In one embodiment, the method further includes:
[0032] After receiving the simplified compressed data, decompress the background compressed data to obtain the background image data, and synchronously send it to the electronic nameplates corresponding to each image data in the same group of data;
[0033] Decompress the information compressed data to obtain each information image data and its parameters, and send them to the electronic nameplates corresponding to each image data respectively.
[0034] In a second aspect, the present application provides an image compression device for an electronic nameplate, and the device includes:
[0035] A data processing module, configured to obtain the image data to be displayed and calculate the number of consecutive repeated bytes in the image data to be displayed; the number of consecutive repeated bytes represents the total number of bytes that appear continuously multiple times;
[0036] An image compression module, configured to, when the ratio of the number of consecutive repeated bytes to the total number of bytes of the image data to be displayed is not less than a preset ratio, compress the image data to be displayed based on the extended run-length encoding algorithm to obtain compressed data; when the ratio of the number of consecutive repeated bytes to the total number of bytes of the image data to be displayed is less than the preset ratio, compress the image data to be displayed based on the JPEG algorithm to obtain compressed data.
[0037] In a third aspect, a computer device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the steps of the method in any one of the first aspects of the present application are implemented.
[0038] An image compression method for an electronic table card described in this application can quickly determine the suitable image compression algorithm for the image data to be displayed by calculating the number of consecutive repeated bytes in the image data to be displayed; in the case of a large number of consecutive repeated bytes, the image data to be displayed is compressed by the extended run-length encoding algorithm, taking advantage of the high repeatability of the electronic table card image, and can have a high compression ratio while losslessly compressing; among them, the extended run-length encoding algorithm allows longer run bytes and has a higher compression ratio than the original run-length encoding; in the case of a small number of consecutive repeated bytes, the image data to be displayed is compressed by the lossy JPEG algorithm, which can improve the compression ratio of complex images. The method compresses the image data to be displayed by automatically selecting a compression algorithm with a higher compression ratio, effectively avoiding the problem of slow image transmission speed of the electronic table card. Description of the Drawings
[0039] In order to more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following-described drawings are only some embodiments of this application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0040] Figure 1 is the step flow chart of an image compression method for an electronic table card in this application;
[0041] Figure 2 is the step flow chart of grouping and compressing data in the same group in this application;
[0042] Figure 3 is the step flow chart of grouping the image data to be displayed in this application;
[0043] Figure 4 is the step flow chart of compressing data in the same group based on the reference image data and the difference matrix in this application;
[0044] Figure 5 is the step flow chart of dividing the background area and the information area in the image according to the difference matrix in this application;
[0045] Figure 6 is the step flow chart of separately compressing the background image data and the information image data based on the preferred compression algorithm in this application;
[0046] Figure 7 is the step flow chart of decompressing the simplified compressed data and transmitting it to the electronic table card in this application;
[0047] Figure 8It is a structural block diagram of an image compression device for an electronic nameplate in this application. Detailed implementation manners
[0048] To facilitate the understanding of this application, the following will describe this application more comprehensively with reference to relevant attached drawings. Embodiments of this application are shown in the attached drawings. However, this application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, these embodiments are provided to make the disclosure of this application more thorough and comprehensive.
[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs. The terms used in the specification of this application herein are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0050] As used herein, the singular forms "a", "an" and "the" may also include the plural forms unless the context clearly indicates otherwise. It should also be understood that the terms "include" or "have" and the like specify the presence of the stated features, wholes, steps, operations, components, parts or combinations thereof, but do not exclude the possibility of the presence or addition of one or more other features, wholes, steps, operations, components, parts or combinations thereof. At the same time, the term "and / or" used in this specification includes any and all combinations of the related listed items.
[0051] In an exemplary embodiment, as Figure 1 shown, this application provides an image compression method for an electronic nameplate, including the following steps S22 to S26:
[0052] S22, obtain the image data to be displayed, and calculate the number of consecutive repeated bytes in the image data to be displayed; the number of consecutive repeated bytes represents the total number of bytes that appear continuously multiple times.
[0053] It can be understood that electronic nameplates are usually used to display information such as the names of participants, and the displayed images are usually images composed of background pictures plus centered identity information; and for clear display, the background images are usually mainly large areas of solid colors. If this image feature can be fully utilized when compressing the images, the compression ratio can be effectively improved.
[0054] Specifically, mark the bytes that appear continuously more than three times in each color channel of the image data as consecutive repeated bytes, and count the total number of consecutive repeated bytes in the image data.
[0055] Furthermore, considering the characteristics of the background image, sample data can be obtained by sampling the image data, and only count the number of consecutive repeated bytes in the sample data, which can effectively reduce the amount of calculation.
[0056] Preferably, the sampling position of the image data to be displayed can be set in the non-identity information area of the image data to be displayed, that is, around the image; since the compression direction of run-length encoding is horizontal, 4-byte-wide horizontal image data on the upper and lower sides of the image data to be displayed are taken as sample data respectively.
[0057] S24. When the proportion of the number of consecutive repeated bytes in the total number of bytes of the image data to be displayed is not less than a preset proportion, the image data to be displayed is compressed based on the extended run-length encoding algorithm to obtain compressed data.
[0058] It can be understood that run-length encoding is a lossless compression algorithm, which has significant advantages in compressing images with high repeatability, but the compressed data may be larger than the original data when compressing complex images; therefore, when selecting a compression algorithm, it is necessary to judge whether the run-length encoding algorithm can be used according to the proportion of consecutive repeated bytes in the whole image data.
[0059] Specifically, when the number of consecutive repeated bytes in the sample image is not less than the preset proportion, the run-length encoding algorithm has a better compression ratio; otherwise, the JPEG algorithm has a better compression ratio.
[0060] It should be noted that the original run-length encoding algorithm encodes the target image by replacing consecutive repeated bytes with a single data byte and a single run byte to obtain compressed data; the run byte represents the number of repetitions of the corresponding data byte.
[0061] Furthermore, considering that the image of the electronic nameplate may have a large range of solid color areas, the number of repetitions of the data byte may exceed the number that can be represented by a single byte; in this case, the extended run-length encoding algorithm further improves the compression efficiency by adding additional run bytes.
[0062] Preferably, the preset proportion of the number of consecutive repeated bytes in the total number of bytes of the image data to be displayed is 70%.
[0063] S26. When the proportion of the number of consecutive repeated bytes in the total number of bytes of the image data to be displayed is less than the preset proportion, the image data to be displayed is compressed based on the JPEG algorithm to obtain compressed data.
[0064] It can be understood that if the number of consecutive repeated bytes in the sample data is less than the preset proportion, it means that the compression efficiency of using run-length encoding to compress the image data to be displayed is not as good as that of the JPEG algorithm. At this time, the JPEG algorithm should be used to compress the image data to be displayed; although JPEG is a lossy compression, since the text image in the image of the electronic nameplate is large, it will not affect the display effect.
[0065] Specifically, the JPEG algorithm converts RGB image data into YUV420 data, then performs block division, discrete cosine transform (DCT), and quantization preprocessing on the YUV420 data, and finally compresses the image through the Huffman coding method.
[0066] The above-mentioned image compression method for an electronic table card can quickly determine the suitable image compression algorithm for the image data to be displayed by calculating the number of consecutive repeated bytes in the image data to be displayed; in the case of a large number of consecutive repeated bytes, the image data to be displayed is compressed by the extended run-length encoding algorithm, taking advantage of the high repeatability of the electronic table card image, and can have a high compression ratio while lossless compression; among them, the extended run-length encoding algorithm allows longer run bytes and has a higher compression ratio than the original run-length encoding; in the case of a small number of consecutive repeated bytes, the image data to be displayed is compressed by the lossy JPEG algorithm, which can improve the compression ratio of complex images. The method compresses the image data to be displayed by automatically selecting a compression algorithm with a higher compression ratio, effectively avoiding the problem of slow image transmission speed of the electronic table card.
[0067] In an exemplary embodiment, compressing the image data to be displayed based on the extended run-length encoding algorithm to obtain compressed data includes the following steps:
[0068] Encoding the data sequence of the image data to be displayed with a single data byte and the run bytes of the data byte to obtain compressed data; the data sequence includes the data of each color channel in the image data to be displayed; the run byte represents the number of consecutive repetitions of the corresponding data byte at the current position; in the case where the number of consecutive repetitions is a multiple of the byte maximum value, a termination byte is also configured at the end of the run byte; the byte maximum value is the maximum number of consecutive repetitions that a single run byte can represent; the termination byte is used to indicate the termination of the run byte.
[0069] It can be understood that considering that the electronic table card needs to be displayed for a long time and the power supply cannot be frequently replaced, most of the electronic table cards on the market use an ink screen, so the RGB format has been converted to the format supported by the corresponding ink screen before image compression.
[0070] Specifically, taking the data sequence of the red channel of a black-and-white-and-red three-color ink screen as an example, the pixel points with a pixel value of 0 in the original data sequence do not display red, and the pixel points with a pixel value of 1 display red; 1 byte represents the 8-bit pixel value vertically; from left to right and from top to bottom, the byte data sequence of the red channel of the image data to be displayed is obtained; the run byte representing the number of repetitions is used to replace all the same bytes after the data byte to obtain compressed data.
[0071] Exemplarily, if a section of data in the byte data sequence has 0x00 appearing continuously 6 times and 0xFE appearing continuously 537 times, then the compressed data obtained after run-length encoding compression is 0x00, 0x06, 0xFE, 0xFF, 0xFF, 0x1B.
[0072] Further, the original run-length encoding algorithm compresses in the encoding mode of one data byte and one run byte, while the run byte of the extended run-length encoding algorithm can be increased according to the repetition times; if the maximum byte value is preset to be less than the byte upper limit, bytes greater than the maximum value can be set for other purposes, such as data checksum and region division.
[0073] Among them, in the case where the repetition times are exactly a multiple of the maximum byte value, if the run byte is terminated with the maximum value byte, it is impossible to distinguish whether the next byte is the next data byte or an unfinished run byte; therefore, a cut-off byte is set after the run byte where the terminated repetition times are exactly a multiple of the maximum byte value, which is convenient for distinguishing the next data byte.
[0074] Preferably, the maximum byte value is 255; the cut-off byte is 0x00; if 0x00 appears after a run byte that is not the maximum value, it is a data byte.
[0075] In an exemplary embodiment, as Figure 2 shown, the method further includes the following steps S32 to S36:
[0076] S32, when there are multiple pieces of image data to be displayed, perform image grouping.
[0077] It can be understood that in a large conference venue, there are a large number of electronic nameplates, and there will be problems of long time consumption and dislocation when transmitting images to each nameplate respectively. Therefore, a centralized controller is usually set up to facilitate batch data transmission and control of the electronic nameplates; in a meeting, the display images of different electronic nameplates are usually set based on the same background image data, and the image difference only lies in the relevant information of the participants; therefore, by uniformly compressing and transmitting the background image data, the amount of compressed data that needs to be transmitted to the centralized controller can be reduced, and the transmission speed can be improved.
[0078] Among them, as Figure 3 shown, the image grouping includes the following steps:
[0079] S322, select any piece of image data to be displayed as the reference image data, and subtract the other image data to be displayed from the reference image data to obtain a difference matrix.
[0080] Specifically, calculate the difference matrix of the corresponding color channel data matrices in the other image data and the reference image data, and then take the absolute value of the matrix data of each channel and sum them to obtain the difference matrix.
[0081] S324. For each difference matrix, if the non-zero values in the difference matrix are only distributed in the central region of the difference matrix, it is determined that the corresponding image data to be displayed and the reference image data are in the same group; the central region represents a matrix region with a preset size in the center of the difference matrix.
[0082] Specifically, the region where the values in the difference matrix are non-zero represents the positions of the data with differences between other images and the reference image data. If the proportion of the difference data is less than the preset proportion, it can be explained that the other images corresponding to this difference matrix and the reference image data share the same background image data and can be used as the same group of data for unified compression.
[0083] Furthermore, in the image to be displayed on the electronic nameplate, the personnel information is usually set in the center position of the image; therefore, it can be determined whether the image data to be displayed and the reference image data are in the same group by judging whether the non-zero values in the difference matrix are only distributed in the central region of the image data.
[0084] Preferably, a matrix region with the number of rows and columns each being half of the difference matrix is selected at the center of the difference matrix as the central region.
[0085] Exemplarily, if the data size of the image to be displayed is 800×480, the size of the central region is 400×240, that is, the central region is the cross region of columns 201 to 600 and rows 121 to 360 in the data matrix of the image to be displayed.
[0086] S34. Repeat the image grouping step to divide multiple image data to be displayed into several groups.
[0087] Specifically, after one grouping is completed, the remaining other image data to be displayed are grouped for the second time until all the image data to be displayed are grouped, and several groups of image data are obtained.
[0088] S36. Perform simplified compression on the data in the same group to obtain the simplified compressed data of each image data in the same group; the simplified compression includes performing single compression on the background data shared by the image data in the same group.
[0089] Specifically, according to the difference matrices in the same group of data, the common background region and information region in the image are obtained, and the simplified compressed data of the same group of data are obtained by using the compressed data of the shared background region and the image data obtained by separately compressing the information region, which can effectively reduce the data volume.
[0090] In an exemplary embodiment, as Figure 4 shown, performing simplified compression on the data in the same group to obtain the simplified compressed data of each image data in the same group includes the following steps S362 to S368:
[0091] S362. Divide the background area and the information area in the image data according to the difference matrix of the same-group data; the background area includes the areas with the same values in the same-group data; the information area includes the areas with different values in the same-group data.
[0092] Specifically, divide the area by whether there are non-zero pixel points in the area of the difference matrix; because they share the same background, there are no non-zero elements in the background area of the difference matrix; because the information of each person is different, there are non-zero elements in the information area of the difference matrix; by identifying the matrix area with non-zero elements, the two areas can be effectively divided.
[0093] S364. Divide each image data in the same-group data with the information area respectively to obtain information image data; the display content of the information image data includes at least one of the name, title, and affiliated unit of the participants.
[0094] Specifically, according to the size and position of the information area, divide the corresponding information image data in each image within the same-group data. According to the different distributions of the information of the participants on the image, information areas displaying different information can be obtained in one image; the information types include at least one of the name, title, unit name, and portrait information of the participants.
[0095] S366. Divide the reference image data with the background area and fill the image data of the vacant area to obtain background image data.
[0096] Specifically, divide the background image data in the reference image data according to the size and position of the background area; for compatibility considerations, fill the white data in the blank area in the background image data due to the information area, because the area for displaying text on the electronic nameplate usually uses a white background, and solid colors are easier to compress.
[0097] S368. Compress the background image data and each information image data respectively based on a preferred compression algorithm to obtain the simplified compressed data of the same-group data.
[0098] Specifically, select a compression algorithm with a higher compression ratio according to the number of consecutive repeated bytes of the reference image data sample to compress the background image data; use the JPEG algorithm to compress the information image data; obtain multiple data as a group of simplified compressed data.
[0099] In an exemplary embodiment, as Figure 5 shown, dividing the background area and the information area in the image according to the difference matrix of the same-group data includes the following steps S3622 to S3626:
[0100] S3622, respectively obtain the difference regions in each difference matrix of the same group of data; the difference region represents the smallest matrix region in the difference matrix that contains all non-zero pixel points.
[0101] Specifically, taking all non-zero elements in the difference matrix as objects, the difference region in the difference matrix that contains all non-zero elements is obtained by the AABB (Axis-Aligned Bounding Box) method.
[0102] S3624, compare the difference regions of each difference matrix, and select the largest difference region as the information region.
[0103] Specifically, since the lengths of the text of personnel information vary, in order to ensure the integrity of the information in the information image data, the largest difference region in the same group of difference matrices should be selected as the information region shared by the images in this group.
[0104] S3626, cut off the information region in the difference matrix to obtain the background region.
[0105] Specifically, after determining the information region, the background region is obtained by cutting off the information region in the complete image data.
[0106] In an exemplary embodiment, as Figure 6 shown, respectively compress the background image data and each information image data based on a preferred compression algorithm, and the steps for obtaining the simplified compressed data of the same group of data include S3682 to S3686 as follows:
[0107] S3682, based on the number of consecutive repeated bytes of the reference image data, select a compression algorithm with a high compression ratio and compress the background image data to obtain background compressed data.
[0108] Specifically, since the same group of data shares a background image data, the compression algorithm preferred according to the sample data of the reference image data can be inherited; the background image data is compressed by the preferred compression algorithm to obtain the background compressed data shared by the same group of data.
[0109] S3684, compress the information image data based on the JPEG algorithm to obtain information compressed data, and add the parameters of the information image data before the information compressed data; the parameters of the information image data include the size and position of the information image data.
[0110] It can be understood that the information image data contains text or picture identifiers and has a high image complexity, which is not suitable for run-length encoding. Therefore, the JPEG algorithm is selected; and the text of the personnel information on the electronic table sign is usually set relatively large to facilitate people to recognize it from a distance. In this case, the detail loss caused by the lossy compression of the JPEG algorithm will not affect the function of the electronic table sign.
[0111] Specifically, the information image data is compressed by the JPEG algorithm, and parameter bytes are added before the compressed data of each information image data; the parameter bytes are used to indicate the size of the information image data and its position in the display image.
[0112] S3686, taking the background compressed data and each information compressed data as the simplified compressed data of the same group of data.
[0113] Specifically, the compressed data of the background image data shared by the same group of data and the information compressed data of each image data are combined and saved, which is convenient for distinguishing different groups of data and processing the same group of data during decompression.
[0114] In an exemplary embodiment, as Figure 7 shown, the method further includes the following steps S42 to S44:
[0115] S42, after receiving the simplified compressed data, decompressing the background compressed data to obtain the background image data, and synchronously sending it to the electronic table signs corresponding to each image in the same group of data.
[0116] Specifically, after receiving the compressed data of the same group of data, the central controller decompresses the compressed data to obtain the background image data and the information image data corresponding to each electronic table sign; the background image data is synchronously sent to the electronic table signs corresponding to each image for display.
[0117] S44, decompressing the information compressed data to obtain each information image data and its parameters, and respectively sending them to the electronic table signs corresponding to each image.
[0118] Specifically, the decompressed information image data and parameters are respectively sent to the electronic table signs corresponding to each image, covering the blank filling area in the background image data to obtain a complete image to be displayed.
[0119] It should be understood that although Figures 1 - 7 the steps in the flowchart of Figures 1 - 7 are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise clearly stated in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover,
[0120] In an embodiment, as Figure 8As shown in the figure, an image compression device 80 for an electronic table card provided by the present application includes:
[0121] A data processing module 81, configured to obtain image data to be displayed and calculate the number of consecutive repeated bytes in the image data to be displayed; the number of consecutive repeated bytes represents the total number of bytes that appear consecutively multiple times.
[0122] An image compression module 82, configured to, when the ratio of the number of consecutive repeated bytes to the total number of bytes of the image data to be displayed is not less than a preset ratio, compress the image data to be displayed based on the extended run-length encoding algorithm to obtain compressed data; when the ratio of the number of consecutive repeated bytes to the total number of bytes of the image data to be displayed is less than the preset ratio, compress the image data to be displayed based on the JPEG algorithm to obtain compressed data.
[0123] For the specific limitations of an image compression device for an electronic table card, reference can be made to the limitations of an image compression method for an electronic table card in the above text, which will not be elaborated here. Each module in the above image compression device for an electronic table card can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to the above modules. It should be noted that the division of modules in the embodiments of the present application is illustrative, only a logical function division, and there may be other division methods in actual implementation.
[0124] In one embodiment, a computer device provided by the present application includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of any one of the image compression methods for an electronic table card provided by the present application.
[0125] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope described in this specification.
[0126] The above-described embodiments only represent several implementation manners of the present application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.
Claims
1. An image compression method for electronic table cards, characterized in that: include: Acquire image data to be displayed, and calculate the number of consecutive repeated bytes in the image data to be displayed; The number of consecutive repeated bytes represents the total number of bytes that appear multiple times in a row; When the ratio of the number of consecutive repeated bytes to the total number of bytes of the image data to be displayed is not less than a preset ratio, compressing the image data to be displayed based on an extended run length coding algorithm to obtain compressed data; When the ratio of the number of consecutive repeated bytes to the total number of bytes of the image data to be displayed is less than a preset ratio, the image data to be displayed is compressed based on a JPEG algorithm to obtain the compressed data.
2. The method according to claim 1, characterized in that: The step of compressing the image data to be displayed based on the extended run length coding algorithm to obtain compressed data comprises: The data sequence of the image data to be displayed is encoded with a single data byte and a run byte of the data byte to obtain the compressed data; the data sequence includes data of each color channel in the image data to be displayed; the run byte indicates the number of consecutive repetitions of the corresponding data byte at the current position; when the number of consecutive repetitions is a multiple of the maximum value of the byte, a stop byte is also configured at the end of the run byte; the maximum value of the byte is the maximum number of consecutive repetitions that can be represented by a single run byte; the stop byte is used to indicate the end of the run byte.
3. The method according to claim 2, characterized in that: The maximum value of the byte is 255; the cutoff byte is 0x00.
4. The method according to claim 2, characterized in that: The method further comprises: In the case where there are multiple image data to be displayed, image grouping is performed; the image grouping comprises the following steps: Select any of the image data to be displayed as reference image data, and obtain a difference matrix by subtracting other image data to be displayed from the reference image data; For each difference matrix, if the non-zero values in the difference matrix are distributed only in the central area of the difference matrix, it is determined that the corresponding image data to be displayed and the reference image data are the same group of data; the central area represents a matrix area of a preset size in the center of the difference matrix; Repeating the image grouping step to divide the plurality of image data to be displayed into a plurality of groups; The data in the same group are simplified and compressed to obtain simplified compressed data of each image data in the data in the same group; the simplified compression includes single compression of background data shared by the image data in the same group.
5. The method according to claim 4, characterized in that: The step of simplifying and compressing the same group of data to obtain simplified compressed data of each image data in the same group of data comprises: Divide the background area and the information area in the image data according to the difference matrix of the same group of data; the background area includes the area with the same value in the same group of data; the information area includes the area with different values in the same group of data; The image data in the same group of data are divided by the information region to obtain information image data; the display content of the information image data includes at least one of the name, title and affiliated unit of the participant; Segmenting the reference image data with the background area and filling the image data of the vacant area to obtain background image data; The background image data and each information image data are compressed based on a preferred compression algorithm to obtain simplified compressed data of the same group of data.
6. The method according to claim 5, characterized in that: The step of dividing the background area and the information area in the image data according to the difference matrix of the same group of data comprises: respectively taking the difference regions in the difference matrices in the same group of data; the difference region represents the minimum matrix region containing all non-zero pixels in the difference matrix; Compare the difference regions of the difference matrices, and select the largest difference region as the information region; The information region is cut off in the difference matrix to obtain the background region.
7. The method according to claim 5, characterized in that: The step of compressing the background image data and each information image data based on a preferred compression algorithm to obtain simplified compressed data of the same group of data comprises: Based on the number of consecutive repeated bytes of the reference image data, a compression algorithm with a high compression ratio is selected to compress the background image data to obtain background compressed data; Compressing the information image data based on the JPEG algorithm to obtain information compressed data, and adding parameters of the information image data before the information compressed data; the parameters of the information image data include the size and position of the information image data; The background compressed data and each information compressed data are used as simplified compressed data of the same group of data.
8. The method according to claim 7, characterized in that: The method further comprises: After receiving the simplified compressed data, decompress the background compressed data to obtain the background image data, and synchronously send it to the electronic table card corresponding to each image data in the same group of data; The information compression data is decompressed to obtain each information image data and its parameters, and are sent to the electronic table card corresponding to each image data respectively.
9. An image compression device for electronic table cards, characterized in that: The device comprises: A data processing module, used for acquiring image data to be displayed, and calculating the number of consecutive repeated bytes in the image data to be displayed; the number of consecutive repeated bytes represents the total number of bytes that appear multiple times in succession; An image compression module is used to compress the image data to be displayed based on an extended run length coding algorithm to obtain compressed data when the ratio of the number of consecutive repeated bytes to the total number of bytes of the image data to be displayed is not less than a preset ratio; and to compress the image data to be displayed based on a JPEG algorithm to obtain the compressed data when the ratio of the number of consecutive repeated bytes to the total number of bytes of the image data to be displayed is less than a preset ratio.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.