JPEG compression verification method and device and storage medium
By performing grayscale processing and edge detection on the JPEG compression module, and generating an affine transformation matrix for feature comparison, the automation and compatibility issues of traditional JPEG compression module verification are solved, achieving an efficient and accurate verification process, and reducing costs and development cycles.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
- Filing Date
- 2026-04-20
- Publication Date
- 2026-05-15
AI Technical Summary
Verification of traditional JPEG compression modules requires manual intervention, cannot be automated, and the verification results based on manual intervention are unreliable, costly, and incompatible with existing chip verification platforms, resulting in excessively long chip development cycles.
A JPEG compression verification method is adopted, which acquires the original image frame and the compressed image, performs grayscale processing and image segmentation, edge detection, generates an affine transformation matrix, performs feature comparison, and uses a hardware description language to realize automated verification, avoiding the need to call external software and simplifying the configuration process.
The automated verification of the JPEG compression module has been achieved, which improves verification efficiency and accuracy, reduces learning costs and computing resource consumption, and shortens the chip development cycle.
Smart Images

Figure CN122053850A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to JPEG compression verification methods, devices and storage media. Background Technology
[0002] The Joint Photographic Experts Group (JPEG) compression module is an image processing hardware module that uses the JPEG compression algorithm to perform real-time lossy compression of images. It significantly reduces the data size of a single image frame while preserving as many key image features as possible and maintaining visually acceptable image quality, achieving a balance between image quality and data transmission efficiency. Considering the high commercial value of JPEG compression modules and the application scenarios such as video streaming and remote video sharing by chip manufacturers, integrating JPEG compression modules into commercial SoC (System-on-a-Chip) chips has become a mainstream choice.
[0003] However, traditional verification methods for JPEG compression modules have the following drawbacks: Firstly, manual intervention is required, making it impossible to automate the chip verification process. Furthermore, verification results based on manual intervention are unreliable in scenarios involving the comparison of a large number of image frames. Alternatively, specialized software or software containing professional image processing algorithms is required as a reference, resulting in excessively high actual verification costs. Moreover, such specialized software is difficult to be compatible with general verification platforms built on the System Verilog language, and it has high computational resource requirements in scenarios involving the comparison of a large number of image frames. In addition, the configuration and usage procedures of such specialized software need to be clearly defined, which increases the learning cost for verification personnel and lengthens the chip development cycle. Summary of the Invention
[0004] This application provides a JPEG compression verification method, device, and storage medium to at least solve one or more technical problems in related technologies, such as unreliability of JPEG compression verification, high cost, incompatibility, and long verification cycle.
[0005] This application provides a JPEG compression verification method, including: Obtain the original image frame and the corresponding compressed image; Perform grayscale processing and image segmentation on the compressed image to obtain multiple compressed image blocks and a corresponding grayscale image block for each compressed image block; Perform edge detection on each grayscale image block to obtain a binary edge image; Based on the pixel values of all pixels in the binary edge image, obtain the affine transformation matrix corresponding to each grayscale image block; Based on the original image frame, the pre-acquired image configuration parameters, each compressed image block, and the affine transformation matrix corresponding to each grayscale image block, multiple feature image blocks are generated. The i-th compressed image block and the i-th feature image block are compared to obtain the i-th similarity comparison result, where the i-th feature image block corresponds to the i-th compressed image block, and i is a positive integer; The i-th similarity comparison result is compared with the pre-configured preset threshold to obtain the i-th comparison result. When the i-th comparison result obtained meets the preset stopping condition, the compression verification result is obtained.
[0006] This application also provides a JPEG compression verification device, comprising: The acquisition module is used to acquire the original image frame and the compressed image corresponding to the original image frame; The processing module is used to perform grayscale processing and image segmentation on the compressed image, obtain multiple compressed image blocks, and grayscale image blocks corresponding to each compressed image block; The edge detection module is used to perform edge detection on each grayscale image block to obtain a binary edge image; The processing module is also used to obtain the affine transformation matrix corresponding to each grayscale image block based on the pixel values of all pixels in the binary edge image; The generation module is used to generate multiple feature image blocks based on the original image frame, pre-acquired image configuration parameters, each compressed image block, and the affine transformation matrix corresponding to each grayscale image block. The processing module is also used to perform feature comparison between the i-th compressed image block and the i-th feature image block to obtain the i-th similarity comparison result, where the i-th feature image block corresponds to the i-th compressed image block and i is a positive integer; compare the i-th similarity comparison result with a pre-configured preset threshold to obtain the i-th comparison result; and obtain the compression verification result when the i-th comparison results obtained meet the preset stopping condition.
[0007] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described JPEG compression verification methods.
[0008] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described JPEG compression verification methods.
[0009] This application describes a method for obtaining a compressed image. First, the image is converted to grayscale and cut into small blocks. Then, edge detection is performed on each block to analyze its structural features and calculate an "affine transformation image block." This matrix can be understood as a mathematical description of the geometric deformation (e.g., slight stretching, tilting) caused by JPEG compression on the image block. Next, the original high-resolution image block is deformed based on this "deformation description" (affine transformation image block). The generated image block serves as a prediction model. Then, the actual compressed image block is compared with the predicted image block from the previous step. Finally, the comparison result is compared with a preset threshold. For example, if the similarity is extremely high, it indicates that the compression effect matches the prediction and the quality is good; if the similarity is extremely low, it indicates that the compression may have caused serious distortion, and the verification can immediately fail and stop.
[0010] This solution completely eliminates the inefficiency and lack of objectivity of manual frame-by-frame inspection. The verification process can be completed automatically by machines, resulting in high speed and consistent results. The entire algorithm (edge detection, matrix operations, feature comparison) can be implemented using hardware description languages commonly used in chip verification (such as SystemVerilog), ensuring the verification efficiency of the JPEG compression module. Moreover, it can be seamlessly integrated into existing chip verification platforms without the need for additional external software such as MATLAB or OpenCV, eliminating compatibility issues and software licensing costs. Furthermore, the JPEG compression module reference model can be modified according to actual verification conditions to support more verification scenarios. In addition, since this method is specifically designed for verification, it avoids running a complete image processing software stack, resulting in lower computational overhead. At the same time, verification personnel only need to configure a few threshold parameters without having to learn and operate complex image processing software, greatly reducing the barrier to entry and learning costs, and helping to shorten the chip development cycle. Moreover, because this application uses image patches as the comparison benchmark, it further reduces computational resource consumption while significantly improving verification efficiency and real-time performance. Attached Figure Description
[0011] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic flowchart of a JPEG compression verification method provided in an embodiment of this application; Figure 2 A verification system architecture diagram provided for an embodiment of this application; Figure 3This is a schematic diagram of another JPEG compression verification method provided in the embodiments of this application; Figure 4 This is a schematic diagram of another JPEG compression verification method provided in the embodiments of this application; Figure 5 This is a schematic diagram of the overall method flow of the JPEG compression verification method provided in the embodiments of this application; Figure 6 A schematic diagram of a JPEG compression verification device provided in an embodiment of this application; Figure 7 This is a schematic diagram of an electronic device structure provided in an embodiment of this application. Detailed Implementation
[0013] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0014] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0015] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0016] The Joint Photographic Experts Group (JPEG) compression module is an image processing hardware module that uses the JPEG compression algorithm to perform real-time lossy compression of images. It significantly reduces the data size of a single image frame while preserving as many key image features as possible and maintaining visually acceptable image quality, achieving a balance between image quality and data transmission efficiency. Considering the high commercial value of JPEG compression modules and the application scenarios such as video streaming and remote video sharing by chip manufacturers, integrating JPEG compression modules into commercial SoC (System-on-a-Chip) chips has become a mainstream choice.
[0017] Traditionally, there are two main methods for verifying JPEG compression modules: The first method involves building a verification platform using System Verilog (a high-level hardware design verification language) and adding a VGA (Video Graphic Array) model to the platform. This model is used to post-process the compressed image data output by the JPEG compression module to create a visually appealing image. Then, manual intervention is used to inspect the compressed image and the original image.
[0018] The second method is to use data comparison. The compressed image data to be verified output by the JPEG compression module is uploaded to a computer host running dedicated image compression algorithm software, and the original image is uploaded to the host at the same time. The dedicated image compression algorithm software compresses the original image to obtain the comparison compressed image data, and finally the two parts of compressed image data are compared.
[0019] The above two traditional methods for verifying JPEG compression modules require manual intervention, making it impossible to automate the chip verification process. Furthermore, the verification results based on manual intervention are unreliable in scenarios involving the comparison of a large number of image frames. Secondly, it requires the use of specialized software or the computational results of software containing professional image processing algorithms as a reference, resulting in excessively high actual verification costs. Furthermore, such specialized software is difficult to be compatible with general verification platforms built on the System Verilog language. In scenarios involving the comparison of a large number of image frames, the demand for computing resources is high. In addition, it is necessary to clarify the configuration and usage process of such specialized software, which increases the learning cost for verification personnel and makes the chip development cycle too long.
[0020] For example, in related technologies, a minimal system supporting the operation of a JPEG compression module is constructed and connected to a computer host running dedicated testing software. The original video image data is synchronously sent to both the minimal system and the computer host. The JPEG compression module in the minimal system compresses and encrypts the original video image data before transmitting the data stream information to the computer host. The dedicated software on the computer host compresses and encrypts the original video image data using the same configuration as the minimal system, generates comparison data stream information, and compares it with the data stream information from the minimal system to complete the entire verification process. This method connects the minimal system (verification platform) containing the JPEG compression module to a computer peripheral running dedicated software. It relies on the dedicated software to perform the same processing on the same video image data and compares the processed compressed image data information, increasing verification costs. Furthermore, this method is only suitable for chip prototype verification. The minimal system runs on a Field Programmable Gate Array (FPGA) development board, relying on the existing peripheral interfaces of the FPGA development board to complete data interaction with the computer host. The peripheral interfaces require additional driver modules to be written and adapted to the minimal system, further increasing the verification difficulty.
[0021] To address the aforementioned problems, embodiments of this application provide a JPEG compression verification method, as detailed below. Figure 1 As shown. This method is performed by the JPEG compression verification model. Before introducing the method itself, we will first introduce the verification system to which this method is applicable. See details. Figure 2 As shown, the device includes a verification platform and a design-under-test (DUT) unit connected to the verification platform. The DUT unit includes a JPEG compression module and other sub-modules. This application primarily focuses on testing the JPEG compression module. Therefore, the other sub-modules of the DUT unit will not be described in detail here.
[0022] The verification platform can be a module-level verification platform or a verification platform of other scales. The verification platform includes a driver, a JPEG compression verification model, a Video Graphics Array (VGA) model, and a receiver.
[0023] The register interface and image data interface of the design unit under test are connected to the verification platform driver, the data output interface of the JPEG compression module is connected to the verification platform receiver, and the reference model of the JPEG compression module is connected to the verification platform driver, receiver, and VGA model.
[0024] At the start of the simulation, the verification platform randomly generates pre-configured parameters, i.e., image configuration parameters. These parameters are written to the design unit under test (DUT) via the driver's configuration register. Simultaneously, the verification platform imports the original image frame into the DUT through the driver's image data interface. Then, the configuration register enables the JPEG compression module to start, and the verification platform sends the image configuration parameters and the original image frame to the JPEG compression module reference model. The platform waits for the JPEG compression module to output the compressed image data stream, which is then captured by the receiver and imported into the VGA model. The VGA model then outputs the compressed image block and image refresh interrupt signal to the JPEG compression module reference model. The JPEG compression module reference model then executes the following steps. See below for details: Step S101: Obtain the original image frame and the compressed image corresponding to the original image frame.
[0025] Specifically, the compressed image corresponding to the original image frame is a compressed image generated by the JPEG compression module.
[0026] Step S102: Perform grayscale processing and image segmentation on the compressed image to obtain multiple compressed image blocks and grayscale image blocks corresponding to each compressed image block.
[0027] Specifically, the compressed image can first be processed into a grayscale image to obtain a grayscale image. Then, based on the pixels in the grayscale image, the image block size information can be determined.
[0028] Specifically, in a grayscale image, locations containing image data will have different pixel values, while locations without image data will have the same value. Based on this principle, the size of an image block can be clearly determined. Then, by segmenting the compressed image / grayscale image according to this block size, multiple compressed image blocks and their corresponding grayscale image blocks can be obtained.
[0029] Step S103: Perform edge detection on each grayscale image block to obtain a binary edge image.
[0030] Step S104: Based on the pixel values of all pixels in the binary edge image, obtain the affine transformation matrix corresponding to each grayscale image block.
[0031] Specifically, the pixel value of the content edges in a compressed image patch is typically 255, while the pixel value of the black border region is 0. This allows for edge detection to obtain a binary edge map. Then, by performing projection analysis on the pixel values of all pixels in the binary edge image, the affine transformation image patch corresponding to each grayscale image patch can be obtained.
[0032] Step S105: Generate multiple feature image blocks based on the original image frame, the pre-acquired image configuration parameters, each compressed image block, and the affine transformation matrix corresponding to each grayscale image block.
[0033] Specifically, the pre-configured image configuration parameters can include one or more resolutions. When multiple resolutions exist, a corresponding feature pyramid is generated based on the original image frame; or when only one resolution exists, a downsampling operation is performed to obtain the feature map at the specific resolution corresponding to the original image frame. Considering that the original image frame does not contain black border information, affine transformation image blocks are also used to perform an affine transformation on the compressed image block, generating corresponding transformed image blocks. Then, the transformed image blocks are used to perform image segmentation operations on the feature map at each resolution in the generated feature pyramid, obtaining multiple feature image blocks corresponding to each resolution's feature map; or the transformed image blocks are used to perform image segmentation operations on the feature map at a specific resolution, obtaining multiple feature image blocks.
[0034] Step S106: Perform feature comparison between the i-th compressed image block and the i-th feature image block to obtain the i-th similarity comparison result.
[0035] Specifically, in each set of feature image blocks, the i-th feature image block is selected and compared with the corresponding i-th compressed image block to obtain the i-th similarity comparison result.
[0036] Step S107: Compare the i-th similarity comparison result with the pre-configured preset threshold to obtain the i-th comparison result. When the i-th comparison result obtained meets the preset stopping condition, obtain the compression verification result.
[0037] Specifically, the preset thresholds include a first preset threshold and a second preset threshold. The second preset threshold is greater than the first preset threshold. The i-th comparison result is compared with the first preset threshold and the second preset threshold respectively, and the comparison results are obtained respectively.
[0038] For example, if the i-th comparison result is greater than or equal to the second preset threshold, it indicates that the features of the original image frame and the compressed image block match well.
[0039] Alternatively, if the i-th comparison result is less than the second preset threshold and greater than or equal to the first preset threshold, it indicates that the features of the original image frame and the features of the compressed image block generally match.
[0040] Alternatively, if the i-th comparison result is less than the first preset threshold, it indicates that the features of the original image frame and the compressed image block match poorly.
[0041] Analyze all comparison results to determine the frequency of occurrences that are good, average, and poor.
[0042] For example, when i reaches a certain value, the results of the first i comparisons are evaluated. Then, it is determined whether the first i results meet the preset stopping condition. If they do, the compression verification result is obtained.
[0043] For example, if more than half of the i obtained results are any of the aforementioned comparison results, then the stopping condition is met, and the compression verification result is obtained.
[0044] For example, if there are 20 image patches corresponding to the entire image, and the statistical results of the first 10 patches are all good / average / poor, then the operation meets the direct stopping condition, and the verification compression result is obtained as good / average / poor.
[0045] Alternatively, if only one of the current 15 results falls into a category with a total number of comparison results exceeding 10, such as "Good / Average / Poor," then the operation should also be stopped, and the verification and compression result should be directly obtained as "Good / Average / Poor."
[0046] More specifically, in a more concrete example, if a preset number of the current i comparison results have a similarity comparison result greater than or equal to the second preset threshold, then the compression verification result is determined to be verified as passed.
[0047] In another scenario, if a preset number of the current i comparison results have a similarity comparison result less than the second preset threshold, but greater than or equal to the first preset threshold, then the compression verification result is determined to be pending correction.
[0048] Alternatively, if a preset number of the current i comparison results have a similarity comparison result less than a first preset threshold, the compression verification result is determined to be a verification failure.
[0049] This application provides a JPEG compression verification method. When a compressed image is obtained, it is first converted into a grayscale image and cut into small blocks. Then, edge detection is performed on each block, its structural features are analyzed, and an "affine transformation image block" is calculated. This matrix can be understood as a mathematical description of the geometric deformation caused by JPEG compression to this image block (such as slight stretching, tilting, etc.). Then, according to this "deformation description" (affine transformation image block), the original high-definition image block is deformed. The generated image block is equivalent to a prediction model. Then, the actual compressed image block is compared with the image block predicted in the previous step. Finally, the comparison result is compared with a preset threshold. For example, if the similarity is extremely high, it means that the compression effect matches the prediction and the quality is very good; if the similarity is extremely low, it means that the compression may have caused serious distortion, and the verification can immediately fail and stop.
[0050] This solution completely eliminates the inefficiency and lack of objectivity of manual frame-by-frame inspection. The verification process can be completed automatically by machines, resulting in high speed and consistent results. The entire algorithm (edge detection, matrix operations, feature comparison) can be implemented using hardware description languages commonly used in chip verification (such as SystemVerilog), ensuring the verification efficiency of the JPEG compression module. Moreover, it can be seamlessly integrated into existing chip verification platforms without the need for additional external software such as MATLAB or OpenCV, eliminating compatibility issues and software licensing costs. Furthermore, the JPEG compression module reference model can be modified according to actual verification conditions to support more verification scenarios. In addition, since this method is specifically designed for verification, it avoids running a complete image processing software stack, resulting in lower computational overhead. At the same time, verification personnel only need to configure a few threshold parameters without having to learn and operate complex image processing software, greatly reducing the barrier to entry and learning costs, and helping to shorten the chip development cycle. Moreover, because this application uses image patches as the comparison benchmark, it further reduces computational resource consumption while significantly improving verification efficiency and real-time performance.
[0051] In an optional example, based on the foregoing embodiments, grayscale processing and image segmentation are performed on the compressed image to obtain multiple compressed image blocks and a grayscale image block corresponding to each compressed image block. The specific steps include the following, see details below. Figure 3 As shown, it includes: Step S301: After performing grayscale processing on the compressed image, a grayscale image is obtained.
[0052] Step S302: Determine the image block specification information and the set of boundary points of the first compressed image block based on the pixels in the grayscale image.
[0053] Specifically, the compressed image is the image output by the VGA model after being compressed by the JPEG compression module. Since VGA imaging uses a progressive scan method, the VGA model outputs fixed-size pixel blocks sequentially at a fixed frequency, moving to the next line after completing the previous one. The already output portion is an image composed of pixel blocks, while the unoutput portion is pure gray. Simultaneously, the image refresh interrupt signal is set during the output of the image block. The image capture unit extracts the compressed image block by reading the pixel grayscale values.
[0054] Therefore, when the image refresh interrupt signal is detected, the compressed image generated by the VGA model is captured, and after converting the image into a grayscale image, the grayscale values of the pixels are read sequentially from top to bottom, starting from the first column on the left, forming a one-dimensional grayscale array A. The last element of this array and several consecutive identical grayscale values are taken as the grayscale values b of the unoutput portion of the compressed image. Then, the length of the consecutive identical grayscale values in this array from the last element to the front is determined. Using the length of a one-dimensional array Subtract the bit width of consecutive identical gray values Obtain the column width of the compressed image block Then, read the grayscale values of the column pixels sequentially from left to right until all the grayscale values of the column pixels are grayscale values. This indicates that the horizontal direction has exceeded the image patch area, thus determining the line width of the compressed image patch. , This refers to the image block specification information.
[0055] Then, the set of boundary points for the first compressed image patch is determined, including: vertex pixel positions. .
[0056] Step S303: According to the image block specification information and the boundary point set, the compressed image and the grayscale image are cut in sequence to obtain each compressed image block and the grayscale image block corresponding to each compressed image block.
[0057] Specifically, the compressed image and grayscale image are sequentially cut according to the image block specification information and the boundary point set to obtain each compressed image block and the corresponding grayscale image block.
[0058] For example, according to row and column width and vertex pixel position By segmenting the compressed image and its corresponding grayscale image, compressed image blocks and their corresponding grayscale images can be obtained. The vertex pixel positions are saved as boundary points for subsequent segmentation of image blocks. Subsequent segmentation will use these points as boundaries to continue to the right or downwards according to a fixed pixel size. Cut and compress the image and its corresponding grayscale image.
[0059] In this method, the compressed color image is first converted into a grayscale image. This reduces the burden on subsequent edge detection by retaining only brightness information and discarding color information. Instead of mechanically starting the cut from the top left corner (0,0), the system automatically calculates the set of boundary points for the first image block based on the pixel distribution of the grayscale image. This essentially allows the system to find the "valid starting position" of the image itself. Then, according to the calculated starting point and block size, the original compressed image and its corresponding grayscale image are simultaneously cut, generating one-to-one image block pairs. This method eliminates manual intervention and achieves full automation, compared to traditional verification methods that may rely on manually specifying the "region of interest (ROI)" or starting point. This method automatically analyzes the grayscale image to determine the boundaries, completely eliminating the uncertainty of human configuration, allowing the verification process to run truly unattended. The "synchronous cutting" mechanism ensures that each compressed image block and its grayscale image block are perfectly aligned in space. This strict correspondence is the physical basis for subsequent affine transformation calculations and feature comparisons. By dynamically determining boundary points, the system can better adapt to test scenarios with different resolutions and different effective content (such as the main subject of the image not being in the center), thus enhancing the generalization ability of the verification environment.
[0060] Further, optionally, based on the pixel values of all pixels in the binary edge image, the affine transformation matrix corresponding to each grayscale image patch can be obtained, which may include the following steps, as detailed below: Step a1: Determine the black boundary of the compressed image block based on the pixel values of all pixels in the binary edge image; Step a2: Determine the affine transformation matrix based on the black boundary.
[0061] In an optional embodiment, when determining the black boundary of the compressed image block based on the pixel values of all pixels in the binary edge image, the following method steps can be followed: Step a21: Traverse the pixel values of all pixels in the binary edge image and store all pixel values in a two-dimensional array according to the position of each pixel.
[0062] Step a22: Sum all pixel values in each column of the two-dimensional array to obtain the sum of pixel values in each column.
[0063] Step a23: Sum the pixel values of all pixels in each row of the two-dimensional array to obtain the sum of the pixel values of each row.
[0064] Step a24: Determine the black boundary of the compressed image block based on the sum of pixel values in each column and the sum of pixel values in each row.
[0065] Specifically, in the standard JPEG compression algorithm, the original image is divided into 8x8 pixel blocks for processing. Therefore, the compressed image resolution is a multiple of 8 in both width and height. When the original image resolution is not a multiple of 8, the JPEG compression algorithm automatically pads the edges, expanding the original image resolution to a multiple of the nearest neighbor's width and height before processing. This results in the compressed image having stripes of pure black pixels at the image edges, i.e., black borders. Black borders are also a characteristic of the compressed image; therefore, black border detection is necessary. In this embodiment, edge detection combined with projection methods can be used to statistically analyze the black border pixel information.
[0066] In this application, the Canny algorithm is used to perform edge detection on the grayscale image corresponding to the compressed image block, extracting the edges of the image content, where the pixel value at the edge is 255; while the black border area has no edge, and its pixel value is 0, thus obtaining a binary edge map.
[0067] Then, the pixel values of all points on the binary edge map are read and stored in a two-dimensional array according to their positions. The algorithm iterates through the pixel values of all pixels in the binary edge image, storing all pixel values in a two-dimensional array according to the position of each pixel. It then sums the pixel values in each column of the two-dimensional array to obtain the sum of the pixel values in each column; and finally sums the pixel values in each row of the two-dimensional array to obtain the sum of the pixel values in each row. Based on the sums of the pixel values in each column and each row, the black boundary of the compressed image patch is determined.
[0068] Specifically, for two-dimensional arrays The sum of all column values in each column is used to obtain the sum of pixel values in that column, which is called the edge density of the current column; similarly, for a two-dimensional array... The same process is performed on each row to obtain the edge density of each row. A row or column edge density value of 0 indicates that the current row or column is within a black border; a row or column edge density value that is not 0 indicates that the current row or column is within the image. The row number corresponding to the position of the edge density 0 value can then be determined. Column number Determine the pixel size of the black border. The black border can be considered as the remaining black area without image content after the image content in the compressed image block has been shifted. The amount of image content shift is... The corresponding transformed image block in the affine transformation is .
[0069] In the above method steps, edge detection is performed on the grayscale image patch to generate a binary image. At this point, the edges of the actual image content are white, while invalid black borders that may be introduced by compression remain black. All pixels of the binary image are stored in a two-dimensional array according to their positions. The sum of all pixel values in each column of the two-dimensional array is calculated, as is the sum of all pixel values in each row of the two-dimensional array. This is because in a binary image, white (edge) pixel values are high, and black (background / black border) pixel values are 0. If there is a black border on the left side of the image, then the "column sum" of the leftmost columns will be 0; similarly, if there is a black border at the top, the "row sum" of the topmost rows will also be 0. By finding the critical point where the column sum and row sum change from 0 to non-zero, the coordinates of the black border can be accurately determined. Based on the previously calculated black border coordinates (e.g., left border x_min and top border y_min), an affine transformation image patch is generated. This matrix is essentially a translation matrix, which guides the system to shift the image content in the reverse direction (-x_min, -y_min), thereby "cutting out" the black borders and returning the effective image content to the standard position.
[0070] General-purpose image libraries (such as OpenCV) typically use connected component analysis or contour finding to detect boundaries, which is computationally complex and difficult to implement in a hardware environment. In contrast, this embodiment only requires basic row / column summation and comparison, resulting in extremely low computational cost and achieving a significant "dimensionality reduction" at the algorithmic level. Since the core operations (summation and comparison) are purely mathematical, they can be easily implemented using hardware description languages such as Verilog / SystemVerilog, seamlessly integrated into the UVM platform for chip verification, without requiring any external software libraries. JPEG compression sometimes introduces small geometric offsets. This "automatic alignment" step ensures that subsequent feature extraction and cosine similarity comparison are performed under the premise of content alignment. If the images are not aligned, all subsequent feature matching will fail. This step is a crucial preliminary step to ensure the robustness of the entire verification system.
[0071] In an optional example, noise interference may exist within the pixels; for example, edge burrs can cause row and column sums to be too large, expanding the boundaries. Therefore, in determining the black boundary, in addition to the methods described above, the following methods can also be used: Step 1: Traverse the binary edge image and use flood fill or connected component algorithms to identify all black pixel clusters (connected components) in the image.
[0072] Step 2: Calculate the area (number of pixels) of each connected component and select the connected components with the largest area (usually the first 1-3 are selected to exclude isolated noise points).
[0073] Step 3: Perform weighted calculation on the coordinates (x, y) of all pixel points within the selected main connected component to obtain the geometric center (centroid Cx, Cy) of these core pixels.
[0074] Step 4: Use the centroid as the origin and perform ray detection in four directions: up, down, left, and right.
[0075] Specifically, traverse the pixels along the ray direction until the first black pixel (edge point) is encountered, and record the distance between this point and the centroid.
[0076] Step 5: Integrate the maximum distances in the four directions to determine the final black boundary (left = centroid x - leftward distance, right = centroid x + rightward distance, and so on).
[0077] After determining the black boundary, calculate the translation vector.
[0078] To remove the black edge, we need to move the upper left corner of the current content located at (L, T) to the origin (0, 0) of the target coordinate system.
[0079] Horizontal displacement (tx): Since the content is shifted to the right, it needs to be moved left by L units, so tx = L.
[0080] Vertical displacement (ty): Since the content is shifted downwards, it needs to be moved up by T units, so ty = T.
[0081] Therefore, we can then add the parameters tx = L, ty = T, etc. to the affine transformation matrix mentioned in the previous text.
[0082] In a specific example, it specifically includes the following steps: First, the system scans the entire image and, for example, finds two independent black pixel clusters.
[0083] Connected component A (main body): Shaped like a "hui" character and contains a total of 20 black pixels.
[0084] Connected component B (noise): There is an isolated noise point in the upper right corner, with only 1 pixel.
[0085] Then, at this time, the algorithm can set the connected components to be retained as those with the number of pixels greater than a preset threshold (for example, > 5 pixels). Therefore, connected component B is directly discarded. We only retain the 20 pixels of connected component A for the next calculation.
[0086] Then, list out the coordinates (x, y) of all 20 pixels in the connected region A (for simplicity, we assume that these 20 points are evenly distributed on the zigzag outline), and calculate their average value.
[0087] If the sum of the x-coordinates of these 20 points is 100, then Cx = 100 / 20 = 5.0; If the sum of the y-coordinates of these 20 points is 120, then Cy = 120 / 20 = 6.0; This determines the core geometric center (5.0, 6.0).
[0088] Step 3: Radial search based on centroid (defining the boundary).
[0089] Scan in four directions (up, down, left, and right) with the centroid (5,0,6,0) as the center: 1) Search to the left (along the negative x-axis direction); Path: (5.0, 6.0) → (4.0, 6.0) → (3.0, 6.0) → (2.0, 6.0) Detection result: At coordinates (2.0, 6.0), the pixel value is 1 (reaching the black edge).
[0090] Define the left boundary: Left boundary = 5.0 3.0 = 2.0.
[0091] 2. Search to the right (along the positive x-axis); Path: (5.0,6.0)→(6.0,6.0)→(7.0,6.0)→(8.0,6.0); Detection result: At coordinates (8.0, 6.0), the pixel value is 1.
[0092] Determine the right boundary: Right boundary = 5.0 + 3.0 = 8.0.
[0093] 3. Search upwards (along the negative y-axis direction); Path: (5.0,6.0)→(5.0,5.0)→(5.0,4.0)→(5.0,3.0); Detection result: At coordinates (5.0, 3.0), the pixel value is 1.
[0094] Define the upper boundary: Upper boundary = 6.0 3.0 = 3.0.
[0095] 4. Search downwards (along the positive y-axis direction); Path: (5.0,6.0)→(5.0,7.0)→(5.0,8.0)→(5.0,9.0); Detection result: The pixel value is 1 at coordinates (5.0, 9.0).
[0096] Determine the lower boundary: Lower boundary = 6.0 + 3.0 = 9.0.
[0097] The final output shows the black bounding box of the compressed image patch as follows: left boundary: 2.0, top boundary: 3.0, right boundary: 8.0, bottom boundary: 9.0.
[0098] Horizontal direction (X-axis): The distance moved is L (i.e. -2.0); Vertical direction (Y-axis): The distance moved is T (i.e., -3.0); Therefore, the translation vector: (tx, ty) = ( 2.0 3.0).
[0099] This method employs a first step, "connected component filtering," to perform shape-based semantic cleaning of the image content. It distinguishes isolated, meaningless pixels (noise) from coherent, shaped entities (subject edges) and directly removes the former. This ensures that the final boundary decision is based entirely on the truly important, structured content of the image, effectively avoiding misjudgments caused by sporadic noise, preventing "false inflation" of boundaries, and significantly improving the algorithm's stability and output purity under non-ideal input conditions. "This method is an active, target-oriented detection approach, starting from the centroid of the core region and exploring linearly outwards like a radar wave. This method can 'capture' the effective edge points farthest from the centroid and located on the subject's contour. The found boundaries are defined by actual entity edge pixels, rather than a statistical threshold. Therefore, the resulting bounding boxes more closely and accurately fit the actual outer contour of the subject, reducing meaningless background inclusion and achieving pixel-level positioning accuracy."
[0100] In many real-world scenarios, the edges of a target object may not be fully connected (e.g., edge breaks due to image quality), or it may be hollow (e.g., the letter "O" or a ring-shaped part). Connectivity analysis does not require the target to be a solid whole; it only identifies the adjacency relationships of pixels. Even if a ring-shaped object is hollow in the middle, its outer ring contour will still be identified as a large connected region. Centroid calculation is based on the positions of all points on this contour, reliably falling at the center of the ring. Subsequent radial search accurately reaches the edge of the outer ring. Therefore, this scheme can robustly handle complex structures such as "hollow" or "broken" structures (as long as the gaps are small), making it more adaptable.
[0101] In an optional example, multiple feature image blocks are generated based on the original image frame, pre-acquired image configuration parameters, each compressed image block, and the affine transformation matrix corresponding to each grayscale image block. The specific steps include the following methods; see [link to details]. Figure 4 As shown: Step S401: Generate a feature map corresponding to the original image frame based on the original image frame and the pre-acquired image configuration parameters.
[0102] Step S402: Based on the affine transformation matrix corresponding to the i-th grayscale image block, perform an affine transformation on the i-th compressed image block corresponding to it, and determine the image block specification information of the i-th transformed image block corresponding to the i-th compressed image block.
[0103] Step S403: After determining the image block specification information of each transformed image block, the feature map is segmented according to the image block specification information of all transformed image blocks to obtain multiple feature image blocks.
[0104] As described above, image configuration parameters may include one or more resolutions. Therefore, the image configuration parameters also include an enable random resolution signal. When the signal value of the enable random resolution signal is used to indicate that the enable random resolution signal is set, the image configuration parameters also include multiple resolutions; Based on the original image frame and the pre-acquired image configuration parameters, a feature map corresponding to the original image frame is generated, specifically including: For multiple resolutions, corresponding feature maps are generated for the original image frames, resulting in multiple feature maps. These multiple resolutions are all output resolutions supported by the JPEG compression module's reference model. This is what is referred to as the feature pyramid mentioned earlier.
[0105] In another optional example, when the signal value of the enable random resolution signal is used to indicate that the enable random resolution signal is not set, the image configuration parameters also include a pre-configured target resolution value (specific resolution); based on the original image frame and the pre-acquired image configuration parameters, a feature map corresponding to the original image frame is generated, specifically including: For each target resolution, a corresponding feature map is generated for the original image frame.
[0106] Then, based on the affine transformation matrix corresponding to the i-th grayscale image block, an affine transformation is performed on the i-th compressed image block corresponding to it to determine the image block specification information of the i-th transformed image block corresponding to the i-th compressed image block.
[0107] In a specific example, after receiving the verification platform configuration parameter information and the original image frame, it first determines whether the enable random resolution signal in the verification platform configuration parameter information is set. If it is set, a corresponding feature pyramid is generated for the original image frame, that is, the feature map of the original image frame at multiple specific resolutions. The multiple specific resolutions are all output resolutions supported by the JPEG compression module. If it is not set, the original image frame is downsampled according to the specified resolution configuration value in the platform configuration parameter information to obtain the feature map of the original image frame at the specified resolution.
[0108] Since the feature pyramid or feature image at a specified resolution generated from the original image frame does not contain black border information, it is necessary to add the black border information to the corresponding feature map of the original image in order to ensure feature correspondence between the original image and the compressed image. Therefore, after receiving the affine transformed image block, an affine translation transformation is performed on all feature maps at various resolutions in the feature pyramid generated from the original image frame, or on the feature image at a specified resolution. It should be noted that the affine translation transformation on the corresponding feature map of the original image frame here is "partially cumulative".
[0109] Specifically, the affine transformation image block of the first compressed image block in the current row (top left corner) is shifted by both rows and columns. Subsequent affine transformation image blocks in the same row no longer have their row values set to 0. This continues until the last compressed image block in the current row (top right corner), where row values remain 0, and only column values are shifted (expanding to the right). Similarly, the affine transformation image block of the first compressed image block in the current row (bottom left corner) is shifted by both rows (expanding downwards), and column values are set to 0. Subsequent affine transformation image blocks in the same row no longer have their row values set to 0. This continues until the last compressed image block in the current row (bottom right corner), where both row and column values are set to 0, and no further shifting is performed. After this process, each compression module has undergone an affine transformation, resulting in the specification information of the corresponding transformed image block.
[0110] Finally, based on the specification information of the transformed image blocks, the feature maps corresponding to all resolutions in the feature pyramid of the original image frame after affine transformation, or the feature maps at a specified resolution, are divided into blocks.
[0111] In an optional example, it might be necessary to scale up the transformed image patch according to a certain ratio. Specifically, consider compressing the image patch into a scaled-down version of the original image. Even after alignment using affine transformation, there may still be some scaling down. If this occurs, then scale it up proportionally. If not, then simply perform the patch processing.
[0112] Similarly, the vertex pixel positions are saved to serve as boundary points for subsequent segmentation of feature image blocks. This operation is similar to the principle of segmenting compressed and grayscale images described earlier, and will not be elaborated further here.
[0113] Further, optionally, based on the aforementioned embodiments, feature comparison is performed between the i-th compressed image block and the i-th feature image block to obtain the i-th similarity comparison result, specifically including the following method steps: Step b1: Perform dilated convolution, pooling, stitching, and normalization on the i-th compressed image block in sequence to obtain the i-th first stitched image.
[0114] Step b2: After sequentially performing pooling, stitching, and normalization on the i-th feature image, the i-th second stitched image is obtained.
[0115] Step b3: Calculate the cosine similarity between the i-th first stitched image and the i-th second stitched image, and use it as the i-th similarity comparison result.
[0116] Specifically, in a concrete example, firstly, the received compressed image patch is subjected to dilated convolution without loss of resolution to obtain a compressed image patch feature map, thereby improving image features at low resolution. Then, this compressed image patch feature map and the original image frame feature map are respectively subjected to pooling processing, successively through global average pooling, global max pooling, and Gaussian weighted pooling. The pooling formulas used in this method are shown below: (Formula 1) Formula 1 is the global average pooling formula. This pooling function extracts global statistical information from the feature map and suppresses noise. GAP (Global Average Pooling) is the global average pooling method. This is the output vector of global average pooling, where H and W are the height and width of the feature map, respectively. The input feature map contains the feature values at position (x, y).
[0117] (Formula 2) Formula 2 is the global max pooling formula. This pooling function extracts the most salient features from the feature map, preserves local details, and is sensitive to noise. GMP (Global Max Pooling) is the global max pooling method. This is the output vector of global max pooling, where the max function is used to find the maximum value by iterating through all feature space locations.
[0118] (Formula 3) Formula 3 is the Gaussian weighted average pooling formula. This pooling method assigns higher weights to the central region of the feature map and lower weights to the edge regions, thus suppressing background interference at the edges. Here, GWAP (Gaussian Weighted Average Pooling) is the Gaussian weighted average pooling method. This is the output vector of Gaussian weighted average pooling. In Formula 3... Given a Gaussian kernel function, the formula body is as follows:
[0119] in the formula , , indicating the coordinates of the Gaussian kernel center, i.e., the center point of the feature map; , where is the standard deviation, controlling the rate of weight decay. The larger the value, the more evenly the weight distribution. Here is the Gaussian weight value at position (x,y).
[0120] After pooling through the three channels mentioned above, feature vectors of the original image frame feature blocks and feature vectors of the compressed image blocks are concatenated. The feature concatenation formula is as follows: (Formula 4) In formula 4 The function indicates that the vectors are concatenated along the channel dimension to form a three-dimensional vector. The concatenated feature vectors are then subjected to L2 norm normalization. The L2 normalization formula used in this method is as follows: (Formula 5) In formula 5 The L2 norm of the eigenvectors is given by the formula: (Formula 6) In formula 6 It is a very small value to prevent division by zero errors; This is the L2-normalized feature vector. Finally, the feature vectors of the original image frame feature blocks, after being L2-normalized, are... , and the feature vector of the compressed image patch Cosine similarity calculation is performed, and the calculation is simplified due to the normalization of the feature vectors. The cosine similarity calculation formula used in this method is as follows: (Formula 7) Equation 7 shows that calculating cosine similarity is equivalent to finding the inner product of two normalized eigenvectors.
[0121] It is important to note that the received compressed image blocks are only one set, while the original image frame feature image blocks may consist of one or more sets. These multiple sets of original image frame feature image blocks correspond to different resolutions and all require pooling and normalization processing. Then, cosine similarity calculations are performed between these original sets and the feature vectors corresponding to the single compressed image blocks, resulting in multiple sets of calculation results.
[0122] In this method, dilated convolution is first performed on the compressed image blocks. This step aims to "repair" or "enhance" details lost due to compression, expand the receptive field, and make low-resolution image features more apparent. Next, pooling, stitching, and normalization are performed to generate the first stitched image (essentially a feature vector). The feature blocks of the original image frame are not subjected to dilated convolution; instead, pooling, stitching, and normalization are performed directly to generate the second stitched image. This is because the original image serves as a high-resolution reference and does not require "repair." Then, the cosine similarity between the i-th first stitched image and the i-th second stitched image is calculated. This reflects the degree of matching between the compressed block and the original block after feature enhancement.
[0123] In this method, dilated convolution is a key design element. Compression (especially JPEG) can lead to loss of high-frequency details, making direct comparison prone to misjudgment. Applying dilated convolution to compressed blocks before comparison essentially "enhances" their feature representation, allowing subsequent pooling and comparison to capture deeper features that, while blurred, still retain their structure, rather than being affected by surface noise. Through a completely consistent pooling, stitching, and normalization process, image blocks from two different sources (compressed / raw) are mapped to the same vector space, ensuring fairness and mathematical rigor in the comparison. Cosine similarity, being a definite scalar, can be directly received by the automated scripts of the verification platform for pass / fail decisions.
[0124] Further optionally, based on the foregoing embodiments, when the compression verification result is determined to be successful, the method further includes: Upload the resolution corresponding to the i-th compressed block to the verification platform.
[0125] Further optionally, when the compression verification result is determined to be in need of correction, the method further includes: The location information of the original frame image block corresponding to the feature image block whose similarity comparison result is less than the second preset threshold and greater than or equal to the first preset threshold is fed back to the verification platform.
[0126] In a specific example, after receiving the cosine similarity calculation results, the calculation results are compared with preset dual thresholds. If a preset number of the current i results are greater than the larger of the preset dual thresholds, it indicates that the original image frame and the compressed image feature match well at the current block position, and the resolution corresponding to the original image frame feature image block of the preset number of calculation results is adopted. Alternatively, if a preset number of the current i comparison results are between the preset dual thresholds, it indicates that the original image frame and the compressed image feature match at the current block position is average, and only the block position of the image block (including the original image and / or compressed image) corresponding to the preset number of calculation results is recorded. If a preset number of the current i results are less than the smaller of the preset dual thresholds, it indicates that the original image frame and the compressed image feature match is poor, the original image frame and the compressed image feature match fails, and the simulation ends directly.
[0127] Optionally, after comparing the i-th similarity comparison result with the pre-configured preset threshold, the method further includes detecting whether the frame end interrupt is triggered. If triggered, it indicates that the current compressed image output is complete, the current feature comparison is the last feature comparison, and the simulation can be terminated.
[0128] Alternatively, if the interrupt at the end of the detection frame is not pulled high, then prepare to enter the next feature comparison process and send out matching resolution information at the same time.
[0129] In addition, the method also includes: in subsequent affine translation transformations, only affine translation transformations and cuts are performed on the feature maps corresponding to the matching resolution, so as to reduce the amount of computation in subsequent transformations.
[0130] Figure 5 The diagram below illustrates the overall flow of an embodiment of this application. See below for details: The process begins by compressing the image. First, the compressed image is captured. Then, the pixel information of the image blocks is obtained. Edge detection is performed to check for black borders. If black borders are found, horizontal projection statistics are performed to locate the top and bottom black border boundaries, and vertical projection statistics are performed to locate the left and right black border boundaries. Finally, the pixel sizes of the black border regions are integrated to generate simulated transformed image blocks.
[0131] On the original image side, the original image is captured, pre-configured parameters are obtained, and it is determined whether to configure the generation of random pixels. If yes, a feature pyramid is generated from the original image. If no, the original image is convolved and downsampled to generate a feature image. An affine transformation is performed on the image blocks according to the affine transformation to obtain feature image blocks. The compressed image also needs to be divided into blocks according to the pixel information (image block specification information) of the image blocks to obtain the feature image blocks of each compressed image block. Then, preprocessing is performed on each group of feature image blocks, including operations such as image spatial convolution, global average pooling, global max pooling, and Gaussian weighted pooling. Then, feature concatenation, L2 normalization, etc. are performed, and finally, cosine similarity calculation is performed.
[0132] In this application embodiment, the first preset threshold is, for example, 90%, and the second preset threshold is, for example, 80%.
[0133] The cosine similarity is compared with a first preset threshold and a second preset threshold. If the number of values greater than or equal to the first preset threshold exceeds half, the resolution can be determined to be preserved. If the number of values less than the first preset threshold but greater than or equal to the second preset threshold exceeds half, only the positions of image patches matching this condition are recorded. If the number of values less than or equal to the second preset threshold exceeds half, the simulation ends directly.
[0134] Of course, the simulation can also be terminated when the frame end interrupt signal is received and pulled high.
[0135] The specific implementation process has been described in detail above, so it will only be briefly described here and will not be repeated.
[0136] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0137] Embodiments of this application also provide a JPEG compression verification device, see details below. Figure 6 As shown, the device includes: an acquisition module 601, a processing module 602, an edge detection module 603, and a generation module 604.
[0138] The acquisition module 601 is used to acquire the original image frame and the compressed image corresponding to the original image frame; The processing module 602 is used to perform grayscale processing and image segmentation operations on the compressed image, obtain multiple compressed image blocks, and grayscale image blocks corresponding to each compressed image block; Edge detection module 603 is used to perform edge detection on each grayscale image block to obtain a binary edge image; The processing module 602 is also used to obtain the affine transformation matrix corresponding to each grayscale image block based on the pixel values of all pixels in the binary edge image; The generation module 604 is used to generate multiple feature image blocks based on the original image frame, the pre-acquired image configuration parameters, each compressed image block, and the affine transformation matrix corresponding to each grayscale image block. The processing module 602 is further configured to perform feature comparison between the i-th compressed image block and the i-th feature image block to obtain the i-th similarity comparison result, wherein the i-th feature image block corresponds to the i-th compressed image block and i is a positive integer; compare the i-th similarity comparison result with a pre-configured preset threshold to obtain the i-th comparison result; and obtain the compression verification result when the i-th comparison results obtained meet the preset stopping condition.
[0139] In an optional example, the processing module 602 is specifically used to perform grayscale processing on the compressed image to obtain a grayscale image; Based on the pixels in the grayscale image, determine the image block specification information and the set of boundary points of the first compressed image block; Based on the image block specification information and boundary point set, the compressed image and grayscale image are sequentially cut to obtain each compressed image block and the corresponding grayscale image block.
[0140] In an optional example, the processing module 602 is specifically used to determine the black boundary of the compressed image block based on the pixel values of all pixels in the binary edge image; Determine the affine transformation matrix based on the black boundary.
[0141] In an optional example, the processing module 602 is specifically used to traverse the pixel values of all pixels in the binary edge image and store all pixel values into a two-dimensional array according to the position of each pixel. Sum all pixel values in each column of the two-dimensional array to obtain the sum of pixel values in each column; Additionally, the pixel values of all pixels in each row of the two-dimensional array are summed to obtain the sum of the pixel values of each row; The black boundaries of the compressed image patch are determined by the sum of the pixel values in each column and the sum of the pixel values in each row.
[0142] In an optional example, the generation module 604 is specifically used to generate a feature map corresponding to the original image frame based on the original image frame and the pre-acquired image configuration parameters; Based on the affine transformation matrix corresponding to the i-th grayscale image block, perform an affine transformation on the i-th compressed image block corresponding to it to determine the image block specification information of the i-th transformed image block corresponding to the i-th compressed image block; Once the image block specification information of each transformed image block is determined, the feature map is segmented according to the image block specification information of all transformed image blocks to obtain multiple feature image blocks.
[0143] In an optional example, the image configuration parameters include an enable random resolution signal; the generation module 604 is specifically used to generate corresponding feature maps for the original image frame for multiple resolutions when the signal value of the enable random resolution signal is used to indicate that the enable random resolution signal is set, and to obtain multiple feature maps, wherein the multiple resolutions are all output resolutions supported by the JPEG compression module reference model.
[0144] In an optional example, when the signal value of the enable random resolution signal is used to indicate that the enable random resolution signal is not set, the image configuration parameters also include a pre-configured target resolution value; the generation module 604 is specifically used to generate a corresponding feature map for the original image frame for the target resolution.
[0145] In an optional example, the processing module 602 is specifically used to sequentially perform dilated convolution, pooling, stitching, and normalization processing on the i-th compressed image block to obtain the i-th first stitched image. After sequentially performing pooling, stitching, and normalization on the i-th feature image, the i-th second stitched image is obtained. Calculate the cosine similarity between the i-th first stitched image and the i-th second stitched image, and use it as the i-th similarity comparison result.
[0146] In an optional example, the preset threshold includes a first preset threshold and a second preset threshold, where the second preset threshold is greater than the first preset threshold. The processing module 602 is specifically used to determine that the compression verification result is passed if a preset number of comparison results among the current i comparison results have a similarity comparison result greater than or equal to the second preset threshold.
[0147] In an optional example, the device also includes a transmitting module 605; The sending module 605 is used to upload the resolution corresponding to the i-th compressed block to the verification platform when the compression verification result is determined to be successful.
[0148] In an optional example, the processing module 602 is further configured to determine that the compression verification result is to be corrected when a preset number of comparison results among the current i comparison results are less than a second preset threshold and greater than or equal to a first preset threshold.
[0149] In an optional example, when the compression verification result is determined to be to be corrected, the processing module 602 is also used to record the position information of the original frame image block corresponding to the feature image block whose similarity comparison result is less than the second preset threshold and greater than or equal to the first preset threshold and feed it back to the verification platform.
[0150] In an optional example, the processing module 602 is further configured to determine that the compression verification result is a verification failure when a preset number of the current i comparison results have a similarity comparison result less than a first preset threshold.
[0151] The description of the features of the JPEG compression verification device provided in this application can be found in the relevant description of the JPEG compression verification method, which will not be repeated here.
[0152] This application provides a JPEG compression verification device. When a compressed image is acquired, it is first converted into a grayscale image and cut into small blocks. Then, edge detection is performed on each block to analyze its structural features and calculate an "affine transformation image block." This matrix can be understood as a mathematical description of the geometric deformation caused by JPEG compression on this image block (such as slight stretching or tilting). Then, based on this "deformation description" (affine transformation image block), the original high-definition image block is deformed. The generated image block is equivalent to a prediction model. Next, the actual compressed image block is compared with the predicted image block from the previous step. Finally, the comparison result is compared with a preset threshold. For example, if the similarity is extremely high, it indicates that the compression effect matches the prediction and the quality is very good; if the similarity is extremely low, it indicates that the compression may have caused serious distortion, and the verification can immediately fail and stop.
[0153] This solution completely eliminates the inefficiency and lack of objectivity of manual frame-by-frame inspection. The verification process can be completed automatically by machines, resulting in high speed and consistent results. The entire algorithm (edge detection, matrix operations, feature comparison) can be implemented using hardware description languages commonly used in chip verification (such as SystemVerilog), ensuring the verification efficiency of the JPEG compression module. Moreover, it can be seamlessly integrated into existing chip verification platforms without the need for additional external software such as MATLAB or OpenCV, eliminating compatibility issues and software licensing costs. Furthermore, the JPEG compression module reference model can be modified according to actual verification conditions to support more verification scenarios. In addition, since this method is specifically designed for verification, it avoids running a complete image processing software stack, resulting in lower computational overhead. At the same time, verification personnel only need to configure a few threshold parameters without having to learn and operate complex image processing software, greatly reducing the barrier to entry and learning costs, and helping to shorten the chip development cycle. Moreover, because this application uses image patches as the comparison benchmark, it further reduces computational resource consumption while significantly improving verification efficiency and real-time performance.
[0154] Embodiments of this application also provide an electronic device, such as... Figure 7 As shown, it includes a memory 10 and a processor 20. The memory 10 stores a computer program, and the processor 20 is configured to run the computer program to perform the steps in any of the above-described JPEG compression verification method embodiments.
[0155] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described JPEG compression verification method embodiments or the steps in any of the above-described data reading method embodiments when running.
[0156] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0157] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the JPEG compression verification method embodiments described above.
[0158] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described data reading method embodiments.
[0159] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0160] The foregoing has provided a detailed description of a JPEG compression verification method, device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A JPEG compression verification method, characterized in that, The method includes: Obtain the original image frame and the compressed image corresponding to the original image frame; The compressed image is subjected to grayscale processing and image segmentation to obtain multiple compressed image blocks and a grayscale image block corresponding to each compressed image block; Edge detection is performed on each of the grayscale image blocks to obtain a binary edge image; Based on the pixel values of all pixels in the binary edge image, obtain the affine transformation matrix corresponding to each grayscale image block; Based on the original image frame, the pre-acquired image configuration parameters, each compressed image block, and the affine transformation matrix corresponding to each grayscale image block, multiple feature image blocks are generated. The i-th compressed image block and the i-th feature image block are compared to obtain the i-th similarity comparison result, where the i-th feature image block corresponds to the i-th compressed image block, and i is a positive integer; The i-th similarity comparison result is compared with the pre-configured preset threshold to obtain the i-th comparison result. When the i-th comparison results obtained meet the preset stopping condition, the compression verification result is obtained.
2. The method according to claim 1, characterized in that, The grayscale processing and image segmentation operations performed on the compressed image to obtain multiple compressed image blocks and a corresponding grayscale image block for each compressed image block specifically include: After performing grayscale processing on the compressed image, a grayscale image is obtained; Based on the pixels in the grayscale image, determine the image block specification information and the set of boundary points of the first compressed image block; According to the image block specification information and the boundary point set, the compressed image and the grayscale image are sequentially cut to obtain each compressed image block and the grayscale image block corresponding to each compressed image block.
3. The method according to claim 1, characterized in that, The step of obtaining the affine transformation matrix corresponding to each grayscale image block based on the pixel values of all pixels in the binary edge image specifically includes: Determine the black boundary of the compressed image block based on the pixel values of all pixels in the binary edge image; The affine transformation matrix is determined based on the black boundary.
4. The method according to claim 3, characterized in that, The step of determining the black boundary of the compressed image block based on the pixel values of all pixels in the binary edge image specifically includes: Iterate through the pixel values of all pixels in the binary edge image, and store all pixel values in a two-dimensional array according to the position of each pixel. Sum all pixel values in each column of the two-dimensional array to obtain the sum of pixel values in each column; In addition, the pixel values of all pixels in each row of the two-dimensional array are summed to obtain the sum of the pixel values of each row; The black boundary of the compressed image block is determined based on the sum of the pixel values in each column and the sum of the pixel values in each row.
5. The method according to claim 1, characterized in that, The step of generating multiple feature image blocks based on the original image frame, pre-acquired image configuration parameters, each compressed image block, and the affine transformation matrix corresponding to each grayscale image block specifically includes: Based on the original image frame and the pre-acquired image configuration parameters, a feature map corresponding to the original image frame is generated; Based on the affine transformation matrix corresponding to the i-th grayscale image block, perform an affine transformation on the i-th compressed image block corresponding to it to determine the image block specification information of the i-th transformed image block corresponding to the i-th compressed image block; After determining the image block specification information of each of the transformed image blocks, the feature map is segmented according to the image block specification information of all the transformed image blocks to obtain multiple feature image blocks.
6. The method according to claim 5, characterized in that, The image configuration parameters include an enable random resolution signal; when the signal value of the enable random resolution signal is used to indicate that the enable random resolution signal is set, the image configuration parameters also include multiple resolutions; The step of generating a feature map corresponding to the original image frame based on the original image frame and the pre-acquired image configuration parameters specifically includes: For each of the multiple resolutions, corresponding feature maps are generated for the original image frame, and multiple feature maps are obtained, wherein the multiple resolutions are all output resolutions supported by the reference model of the JPEG compression module.
7. The method according to claim 6, characterized in that, When the signal value of the enable random resolution signal is used to indicate that the enable random resolution signal is not set, the image configuration parameters also include a pre-configured target resolution value; the step of generating a feature map corresponding to the original image frame based on the original image frame and the pre-acquired image configuration parameters specifically includes: For the target resolution, a corresponding feature map is generated for the original image frame.
8. The method according to any one of claims 1-7, characterized in that, The step of performing feature comparison between the i-th compressed image block and the i-th feature image block to obtain the i-th similarity comparison result specifically includes: After sequentially performing dilated convolution, pooling, stitching, and normalization on the i-th compressed image block, the i-th first stitched image is obtained. After sequentially performing pooling, stitching, and normalization processing on the i-th feature image, the i-th second stitched image is obtained. Calculate the cosine similarity between the i-th first stitched image and the i-th second stitched image, and use it as the i-th similarity comparison result.
9. The method according to any one of claims 1-7, characterized in that, The preset thresholds include a first preset threshold and a second preset threshold, where the second preset threshold is greater than the first preset threshold. The step of comparing the i-th similarity comparison result with the pre-configured preset thresholds to obtain the i-th comparison result, and obtaining the compression verification result when the current i comparison results meet the preset stopping condition, specifically includes: If a preset number of the current i comparison results have a similarity comparison result greater than or equal to the second preset threshold, then the compression verification result is determined to be verified as passed.
10. The method according to claim 9, characterized in that, When the compression verification result is determined to be a successful verification, the method further includes: The resolution corresponding to the i-th compressed block is uploaded to the verification platform.
11. The method according to claim 9, characterized in that, The method further includes: If a preset number of the current i comparison results have a similarity comparison result less than the second preset threshold, or greater than or equal to the first preset threshold, then the compression verification result is determined to be to be corrected.
12. The method according to claim 11, characterized in that, When the compression verification result is determined to be in need of correction, the method further includes: The location information of the original frame image block corresponding to the feature image block whose similarity comparison result is less than the second preset threshold and greater than or equal to the first preset threshold is recorded and fed back to the verification platform.
13. The method according to claim 9, characterized in that, The method further includes: If a preset number of the current i comparison results have a similarity comparison result less than the first preset threshold, the compression verification result is determined to be a verification failure.
14. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the JPEG compression verification method as described in any one of claims 1 to 13 when executing the computer program.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the JPEG compression verification method as described in any one of claims 1 to 13.