A video multi-level encryption transmission method based on Huffman coding
Through the video multi-level encryption transmission method based on Huffman coding, the degree of detail and confusion of each pixel in the video frame is calculated, the position of the node of the paradigm Huffman tree is adjusted, and the multi-level encryption key and encoding data are generated to solve the problem. The existing technology cannot realize the problem of setting different encryption levels for different contents of the video, thereby improving the confidentiality of the video.
Patent Information
- Application Number
- CN202210830733.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-14
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-07-14
AI Technical Summary
Existing Internet video security methods cannot set different encryption levels or permissions for different content in the video, and cannot effectively protect users at different levels from seeing video content in different areas.
A video multi-level encryption transmission method based on Huffman coding is used to classify the video by calculating the degree of detail and confusion of each pixel in the video frame, and use the paradigm Huffman tree to adjust the node positions to generate different levels of Keys and encoded data to achieve multi-level encryption of different content in the video.
It realizes the setting of different encryption levels or permissions for different contents in the video, improves the confidentiality of the video, and ensures that users at different levels can only see the video information within their permission range.
Smart Images

Figure CN115225897B
Abstract
Description
Technical Field
[0001] The invention relates to the field of encrypted transmission, and in particular to a video multi-level encrypted transmission method based on Huffman coding. Background Art
[0002] In some units, only high-level managers can see all the information of the images in important videos, while low-level staff can only see part of the information of the images. However, the existing Internet video confidentiality methods are generally membership-based, that is, the confidentiality of the video is achieved by cutting off the user's access to the Internet video; the existing Internet video confidentiality methods either encrypt the entire video, and only after all the videos are decrypted can the viewing rights of the entire video be obtained. It is impossible to set different encryption levels or permissions for different contents in the video, and achieve different degrees of encryption in the video. Different levels of secret keys represent different levels of permissions, and you can view the content of different areas in the video. If the secret key level is not enough, you can only see the image of the corresponding area, and other areas are covered with masks.
[0003] In view of the above situation, the present invention proposes a video multi-level encryption transmission method based on Huffman coding, which obtains the importance of the data, classifies the data, and obtains encrypted ciphertexts and keys of different levels. Summary of the invention
[0004] The invention provides a video multi-level encryption transmission method based on Huffman coding to solve the existing problem of low security.
[0005] The present invention provides a video multi-level encryption transmission method based on Huffman coding, which adopts the following technical scheme:
[0006] Get the grayscale image of each frame in the video;
[0007] Sliding the window with each pixel in the grayscale image as the center pixel, calculating the information entropy of the window with each pixel as the center pixel as the degree of disorder of the window with the pixel as the center pixel;
[0008] Calculate the gradient amplitude of each pixel in each frame of grayscale image;
[0009] The discrete degree of each pixel in each frame of grayscale image is obtained by the gradient amplitude of each pixel and its neighboring pixel in each frame of grayscale image;
[0010] The detail of each pixel in each frame of grayscale image is obtained by the discrete degree of each pixel in each frame of grayscale image and the disorder degree of the window with the pixel as the center pixel;
[0011] The maximum detail and the minimum detail of all pixels in each frame of the grayscale image are used to obtain the detail value interval of the frame of the grayscale image, and the detail value interval is divided into equal lengths to obtain all detail intervals of the frame of the grayscale image;
[0012] Performing paradigm Huffman coding on the detail degree interval using the ratio of the pixels in each detail degree interval to all the pixels in the grayscale image, obtaining a paradigm Huffman tree of the grayscale image, adjusting the positions of the nodes in the paradigm Huffman tree using the detail degrees of the nodes in the paradigm Huffman tree, adjusting the nodes with large detail degrees to the positions with long paradigm Huffman coding data, and obtaining the coded data after adjustment for each detail degree interval;
[0013] The node sorting sequence in the normal form Huffman tree after the node position is adjusted is used as the key, and the key is symmetrically encrypted to obtain the key encoding data;
[0014] Performing a normalized Huffman encoding on all pixels in each detail level interval according to the gray level frequency of the pixels in each detail level interval, to obtain encoding data of each pixel in each detail level interval;
[0015] The coded data after adjustment in each detail level interval is used as the terminal of the coded data of each pixel point in the detail level interval to obtain the final coded data of each pixel point in the detail level interval;
[0016] The final encoded data and key encoded data of each pixel in each detail interval are transmitted and stored.
[0017] Furthermore, in the Huffman coding-based multi-level encrypted video transmission method, the detail of each pixel in each frame of the grayscale image is the product of the discreteness of each pixel in each frame of the grayscale image and the chaos degree of the window with the pixel as the center pixel.
[0018] Furthermore, in the Huffman coding-based video multi-level encryption transmission method, the method for obtaining the degree of confusion of the window is:
[0019] The grayscale is equally divided into multiple grayscale intervals, and the information entropy of the window with each pixel as the center pixel in the grayscale image is calculated by the ratio of the number of pixels in each grayscale interval in the window with each pixel as the center pixel to the number of all pixels in the window;
[0020] The information entropy of the window with each pixel as the center pixel in the grayscale image is taken as the degree of disorder of the window with the pixel as the center pixel.
[0021] Furthermore, in the Huffman coding-based video multi-level encryption transmission method, the method for obtaining the discrete degree of each pixel in each frame of the grayscale image is:
[0022] The distribution discreteness of the pixels in the window where each pixel and its neighboring pixels are located in each frame of the grayscale image is obtained by the gradient amplitude of each pixel and its neighboring pixels in each frame of the grayscale image;
[0023] The distribution discreteness of each pixel in each frame of grayscale image and the pixel in the window where its neighboring pixels are located is taken as the discreteness of the pixel in each frame of grayscale image.
[0024] Furthermore, in the Huffman coding-based video multi-level encryption transmission method, the expression for the distribution discreteness of each pixel and the pixel in the window where its neighboring pixel is located is:
[0025]
[0026] Where K represents the distribution discreteness of each pixel and its neighboring pixel in the window, f represents the gradient amplitude of each pixel, j represents the jth neighboring pixel of each pixel, and f j Represents the gradient amplitude of the jth neighboring pixel of each pixel, It represents the mean value of the gradient amplitude difference between all neighboring pixels of each pixel and the current pixel, and n represents the side length of the window where each pixel and its neighboring pixels are located.
[0027] Furthermore, in the Huffman coding-based multi-level encrypted video transmission method, adjusting the position of the node in the paradigm Huffman tree is adjusting the position of the detail interval in the paradigm Huffman tree.
[0028] The beneficial effects of the present invention are as follows: the present invention obtains each frame image in a video, calculates the detail of each pixel in the image, performs paradigm Huffman coding according to the proportion of pixels in a detail interval, adjusts the node positions in a paradigm Huffman tree, obtains coded data of the detail interval, uses the node sorting sequence in the paradigm Huffman tree as a key, encrypts the key, and simultaneously encodes the pixels in the detail interval according to the grayscale frequency of the pixels in the detail interval to obtain coded data of the pixels in the detail interval, combines the two obtained coded data to obtain final coded data of the pixels, and compared with the prior art, realizes setting of different encryption levels or permissions for different contents in a video, and realizes encryption of different degrees in the video. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0030] Figure 1 The present invention is a flowchart of an embodiment of a method for multi-level encrypted transmission of video based on Huffman coding. DETAILED DESCRIPTION
[0031] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0032] Example 1
[0033] An embodiment of a video multi-level encryption transmission method based on Huffman coding of the present invention is as follows: Figure 1 As shown, including:
[0034] 101. Get the grayscale image of each frame in the video.
[0035] The encrypted video is preprocessed by splitting the video to obtain each frame image in the video, and each frame image is processed. Below, one frame image is taken as an example, and the processing method of other frame images is the same as that of the frame image.
[0036] The acquired video frame image is usually a color RGB image. In order to facilitate subsequent processing, the acquired RGB image is grayed to obtain a grayscale image.
[0037] So far, each frame of grayscale image is obtained.
[0038] The details of an image often contain rich information. The richer the details of an image, the more information it contains. For special videos, we expect that people at different levels can obtain different image information. The higher the level of the visitor, the more complete the image information that can be obtained. Therefore, we classify the pixels by calculating their detail degree, perform Huffman coding according to the detail degree to obtain multi-level coding terminals, and then perform Huffman coding on the pixels in each category and combine them with the corresponding terminals to obtain the pixel code.
[0039] Huffman coding is a statistical coding. It counts the number of pixels at each gray level of the image and encodes them according to the probability of occurrence. The more times a pixel of a certain gray level appears, the shorter the encoding length of the pixel of that gray level, eventually forming a multi-level Huffman tree. However, the Huffman tree is encoded according to the probability of the gray level. Key information may exist in the gray level with a high probability. At this time, if multi-level encryption is performed according to the traditional Huffman tree, it may result in low confidentiality, and some highly confidential data can be obtained by people of a low level. Therefore, it is necessary to change the traditional Huffman coding method so that the longer the code after grading, the higher the privacy, that is, the highly confidential data always exists at the end of the tree.
[0040] 102. Sliding a window with each pixel in the grayscale image as the center pixel, and calculating the information entropy of the window with each pixel as the center pixel as the degree of disorder of the window with the pixel as the center pixel.
[0041] Establish a sliding window: The amount of information contained in a single pixel is limited. It is impossible to determine whether a pixel is a pixel of a detail by simply looking at the grayscale value and gradient value of a pixel. Therefore, by obtaining the pixels around the target pixel and obtaining the relationship between it and the surrounding pixels, the detail of the corresponding pixel can be calculated. Establish a sliding window of size n×n, where n is an odd number and the minimum value of n is 3, for example, a sliding window of size 3×3 is used.
[0042] Calculate the degree of disorder of the pixels in the sliding window. For the sliding window, the more disordered the gray value distribution of the pixels in the sliding window is, the more likely the pixel is to be a pixel in an area with rich details. However, the gray level is 0-255. The number of pixels in the established sliding window is much smaller than the number of gray levels. The gray values of some background areas are similar but there are slight changes. The gray level distribution of the corresponding pixels is disordered, but the corresponding pixels are not pixels in an area with rich details. The reason is that there are many gray levels. Therefore, we integrate the gray levels and divide them into several intervals. One interval contains multiple gray levels, and the length of each interval is the same. If the gray levels of the pixels in the sliding window are similar, they will be divided into the same interval, that is, the same type of pixels.
[0043] The grayscale value of the pixel in the sliding window is obtained, and the number of interval categories of each pixel in the sliding window is obtained according to the grayscale value of each pixel in the sliding window, so as to calculate the degree of disorder of the sliding window. The degree of disorder of the sliding window is the information entropy of the sliding window. The calculation of information entropy is a well-known technology. The expression of the information entropy H(m) of the window is as follows:
[0044]
[0045] In the formula, p(x i) represents the ratio of the number of pixels in the i-th grayscale interval to the number of all pixels in the window, i represents the i-th grayscale interval, and b represents the base of the logarithmic function.
[0046] 103. Calculate the gradient amplitude of each pixel in each frame of the grayscale image.
[0047] Get the gradient amplitude of each pixel in each frame of grayscale image, and use the Sobel operator to calculate the gradient f in the x and y directions of each pixel in each frame of grayscale image x ,f y . Then the gradient amplitude is At this point, the gradient amplitude of each pixel in each frame of the grayscale image is obtained.
[0048] 104. The discrete degree of each pixel in each frame of the grayscale image is obtained through the gradient amplitude of each pixel and its neighboring pixel.
[0049] Similarly, the discrete degree of distribution of pixels in the sliding window is calculated. The more discrete the gradient amplitude distribution of pixels in the sliding window is, the more likely the target pixel is to be located in an area with rich details. Therefore, the discrete degree of distribution of pixels in the sliding window is:
[0050]
[0051] Where K represents the discrete degree of the pixel distribution in the sliding window, and its value is assigned to the central pixel of the sliding window as the discrete degree of the central pixel of the sliding window. f represents the gradient amplitude of the central pixel of the sliding window, j represents the jth neighboring pixel of the central pixel, and f j Represents the gradient amplitude of the jth neighboring pixel of the central pixel in the sliding window, It represents the average value of the difference between the gradient amplitude of each neighboring pixel of the central pixel in the sliding window and the gradient amplitude of the central pixel, and n represents the side length of the sliding window.
[0052] 105. The detail degree of each pixel in each frame of the grayscale image is obtained through the discrete degree of each pixel in each frame of the grayscale image and the disorder degree of the window with the pixel as the center pixel.
[0053] Calculate the detail of the pixel. For a certain pixel, the greater the difference in grayscale gradient between it and the surrounding pixels, and the more grayscale levels of the pixels in the sliding window, the more likely the pixel is a detail pixel, that is, this type of pixel can reflect more image information. The expression of detail is:
[0054] C==H(m)*K
[0055] In the formula, C represents the detail of the target pixel. The larger the value of C is, the richer the image information contained in the pixel is, so the confidentiality of the pixel is higher.
[0056] 106. Utilize the maximum detail degree and the minimum detail degree of all pixels in each frame of the grayscale image to obtain a detail degree value interval of the frame of the grayscale image, and divide the detail degree value interval into equal lengths to obtain all detail degree intervals of the frame of the grayscale image.
[0057] The pixels are classified according to their detail levels, and pixels with different confidentiality levels are obtained after classification. Specifically, the maximum detail level C of all pixel details in the grayscale image is obtained. max With minimum detail C min , the detail interval [C min ,C max ] is divided into multiple detail intervals.
[0058] 107. Perform paradigm Huffman coding on the detail level interval using the ratio of the pixels in each detail level interval to all the pixels in the grayscale image to obtain a paradigm Huffman tree of the grayscale image. Adjust the positions of the nodes in the paradigm Huffman tree using the detail levels of the nodes in the paradigm Huffman tree, and adjust the nodes with large detail levels to the positions with long paradigm Huffman coded data to obtain the adjusted coded data for each detail level interval.
[0059] The proportion of pixels in each detail interval is counted, and a detail paradigm Huffman tree is constructed based on the proportion. The paradigm Huffman tree adjusts all leaf nodes to the left side of the tree and encodes them in the manner of left 0 and right 1. For the codes in the same layer, the code length is the same.
[0060] We expect that the greater the pixel detail, the better the confidentiality effect. However, the paradigm Huffman tree obtained by the proportion of pixels in each detail interval will have a short encoding of the detail interval with a large detail, and a long encoding of the detail interval with a small detail. Therefore, when decrypting through the Huffman tree at this time, there will be a problem of decrypting important pixels first. Therefore, it is necessary to adjust the position of the leaf node in the Huffman tree according to the value of the detail, and judge the size of the detail in the upper and lower layers of the leaf nodes of the Huffman tree. If the detail of the upper leaf node is greater than that of the lower leaf node, the positions of the upper and lower leaf nodes are exchanged. If there are multiple leaf nodes in the lower layer and only one leaf node in the upper layer, the detail of the upper leaf nodes here is greater than that of the lower leaf nodes, then the leaf node with the smallest detail in the lower layer is exchanged with the upper leaf node. Similarly, traverse the entire Huffman tree for adjustment to ensure that the detail of the lower leaf nodes is greater than that of the upper layer, and the position of the leaf nodes in the same layer is not affected by the detail. After the adjustment, the encoding of each detail interval changes. This is because the encoding of each position is fixed. When the detail interval of the leaf node is changed, the position of the detail interval node changes, and accordingly, the encoding of the detail interval node also changes.
[0061] 108. The node sorting sequence in the normal form Huffman tree after the node position is adjusted is used as a key, and the key is symmetrically encrypted to obtain key encoded data.
[0062] Since the structure of the paradigm Huffman tree is fixed, the encoding of each leaf node can be inferred from the encoding of other leaf nodes. When restoring data, we need to know which detail interval each leaf node represents. Therefore, the order of leaf nodes is particularly important. Therefore, we use the storage order of leaf nodes as encryption keys. For example, the order of the leaf nodes of the detail paradigm Huffman tree is {6, 4, 3, 2, 9, 1, 8, 7, 5, 11, 15, 14, 12, 13, 10}. The order sequence of leaf nodes that can be obtained at different levels is different. For example, if it is divided into three levels, the first level personnel can obtain the sequence of the five detail intervals {6, 4, 3, 2, 9}. In order to ensure the security of the data, the symmetric encryption algorithm is used to encrypt the obtained leaf node sequence to obtain the encoded data of the unique encryption key. Symmetric encryption is a prior art and will not be described in detail here.
[0063] 109. Performing normalized Huffman coding on all pixels in each detail level interval according to the gray level frequency of the pixels in each detail level interval to obtain coded data of each pixel in each detail level interval.
[0064] The above steps obtain the coding information of the detail level interval. For each pixel, accurate coding is not performed. Therefore, for the pixels in each detail level interval, the gray level frequency of the pixels is counted, and the paradigm Huffman coding is performed according to the gray level frequency to obtain the coding data of each pixel in each detail level interval.
[0065] 110. Using the adjusted coded data of each detail level interval as the terminal of the coded data of each pixel point in the detail level interval to obtain the final coded data of each pixel point in the detail level interval.
[0066] The interval coding and the grayscale frequency coding are superimposed to obtain the final coding of the pixel. For example, the code obtained by encoding a pixel of a certain grayscale level through grayscale frequency is 111110110. For the pixels of this grayscale level, due to their different distributions, the detail levels of the pixels are also different. For example, the pixels of this grayscale level are included in three detail level intervals, and the codes of the detail level intervals are 11101, 11111, and 11100, respectively. Then, the final coding of the pixels of this grayscale level is: 11101111110110, 11111111110110, 11100111110110. At this time, pixels of the same grayscale level obtain different codes.
[0067] The different encodings of pixels of the same gray level are due to different terminals.
[0068] 111. The final encoding data and key encoding data of each pixel in each detail level interval are transmitted and stored.
[0069] Save all the encoded data obtained.
[0070] The encrypted transmission and storage of video frame images is a two-dimensional coding matrix. When decrypting it, the code needs to be split, and the leaf node sequence of the dock is obtained through key decryption, and the paradigm Huffman tree is restored to achieve the final decryption.
[0071] The specific steps of decryption are as follows:
[0072] Data splitting, final encoding = detail encoding + grayscale frequency encoding.
[0073] Key acquisition: When a user applies to access an encrypted video, the system generates a key based on the level of the current accessing user.
[0074] The user inputs the key, and the system parses the key through the decryption algorithm to obtain the current decrypted leaf node sequence, and restores the detail normal form Huffman tree based on the leaf node sequence. At this time, the restored normal form Huffman tree is restored according to the key level. The lower the key level, the more incomplete the restored normal form Huffman tree is, and only the part corresponding to the key is restored at this time.
[0075] Data parsing, parse the encrypted ciphertext, compare the terminal code with the decrypted paradigm Huffman tree to obtain the corresponding detail interval, and decrypt according to the detail interval. If the terminal code cannot find the corresponding decrypted paradigm Huffman tree code, it means that the pixel is a pixel with a higher degree of privacy. Since the terminal cannot be parsed, the grayscale value corresponding to the pixel cannot be parsed either, so the pixel is skipped and not processed, and replaced with a suitable pixel.
[0076] After decryption is completed, the corresponding image information is parsed according to the key information, where the successfully parsed pixels are restored to their original grayscale values, and the unparsed pixels are black pixels.
[0077] The present invention obtains each frame of image in a video, calculates the detail of each pixel in the image, performs paradigm Huffman coding according to the proportion of pixels in a detail interval, adjusts the node positions in a paradigm Huffman tree, obtains coded data of the detail interval, uses the node sorting sequence in the paradigm Huffman tree as a key, encrypts the key, and simultaneously encodes the pixels in the detail interval according to the gray level frequency of the pixels in the detail interval to obtain coded data of the pixels in the detail interval, combines the two obtained coded data to obtain final coded data of the pixels. Compared with the prior art, different encryption levels or permissions are set for different contents in a video, and different degrees of encryption in the video are achieved.
[0078] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A video multi-level encryption transmission method based on Huffman coding, characterized in that: include Get the grayscale image of each frame in the video; Sliding the window with each pixel in the grayscale image as the center pixel, calculating the information entropy of the window with each pixel as the center pixel as the degree of disorder of the window with the pixel as the center pixel; Calculate the gradient amplitude of each pixel in each frame of grayscale image; The discrete degree of each pixel in each frame of grayscale image is obtained by the gradient amplitude of each pixel and its neighboring pixel in each frame of grayscale image; The detail of each pixel in each frame of grayscale image is obtained by the discrete degree of each pixel in each frame of grayscale image and the disorder degree of the window with the pixel as the center pixel; The maximum detail and the minimum detail of all pixels in each frame of the grayscale image are used to obtain the detail value interval of the frame of the grayscale image, and the detail value interval is divided into equal lengths to obtain all detail intervals of the frame of the grayscale image; Performing paradigm Huffman coding on the detail degree interval using the ratio of the pixels in each detail degree interval to all the pixels in the grayscale image, obtaining a paradigm Huffman tree of the grayscale image, adjusting the positions of the nodes in the paradigm Huffman tree using the detail degrees of the nodes in the paradigm Huffman tree, adjusting the nodes with large detail degrees to the positions with long paradigm Huffman coding data, and obtaining the coded data after adjustment for each detail degree interval; The node sorting sequence in the normal form Huffman tree after the node position is adjusted is used as the key, and the key is symmetrically encrypted to obtain the key encoding data; Performing a normalized Huffman coding on all pixels in each detail level interval according to the gray level frequency of the pixels in each detail level interval, and obtaining coded data of each pixel in each detail level interval; The coded data after adjustment in each detail level interval is used as the terminal of the coded data of each pixel point in the detail level interval to obtain the final coded data of each pixel point in the detail level interval; The final coded data and key coded data of each pixel in each detail interval are transmitted and stored; The detail of each pixel in each frame of grayscale image is the product of the discreteness of each pixel in each frame of grayscale image and the chaos degree of the window with the pixel as the center pixel; The method to get the degree of confusion of the window is: The grayscale is equally divided into multiple grayscale intervals, and the information entropy of the window with each pixel as the center pixel in the grayscale image is calculated by the ratio of the number of pixels in each grayscale interval in the window with each pixel as the center pixel to the number of all pixels in the window; The information entropy of the window with each pixel as the center pixel in the grayscale image is taken as the degree of disorder of the window with the pixel as the center pixel; The method to obtain the discrete degree of each pixel in each frame of grayscale image is: The distribution discreteness of the pixels in the window where each pixel and its neighboring pixels are located in each frame of the grayscale image is obtained by the gradient amplitude of each pixel and its neighboring pixels in each frame of the grayscale image; The distribution discreteness of each pixel in each frame of grayscale image and the pixel in the window where its neighboring pixel is located is taken as the discreteness of the pixel in each frame of grayscale image; The expression of the distribution discreteness of each pixel and the pixel points in the window where its neighboring pixels are located is: In the formula, Indicates the distribution discreteness of each pixel and the pixel points in the window where its neighboring pixels are located. Represents the gradient magnitude of each pixel, Represents the first Neighborhood pixels, Represents the first The gradient amplitude of the neighboring pixels is Represents the mean value of the gradient amplitude difference between all neighboring pixels and the current pixel of each pixel. Represents the side length of the window where each pixel and its neighboring pixels are located.
2. The method for multi-level encrypted transmission of video based on Huffman coding according to claim 1, characterized in that: Adjusting the position of the node in the normal form Huffman tree is to adjust the position of the detail interval in the normal form Huffman tree.
Citation Information
Patent Citations
Unmanned aerial vehicle cruise image processing system
CN114640853A
Spine image segmentation method
CN114677391A
Method and system for compressing motion image information
US20040247192A1
Fast loss less image compression based on neighborhood comparisons
WO2001084848A2
