Image data rotation optimization method and device
By processing luminance and chromaticity data through block matrix transpose and chromaticity calibration, the problems of low image rotation efficiency and color distortion in existing technologies are solved, achieving efficient and smooth image rotation optimization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING INST OF RADIO METROLOGY & MEASUREMENT
- Filing Date
- 2025-12-08
- Publication Date
- 2026-04-14
AI Technical Summary
Existing image data rotation schemes struggle to balance processing efficiency, image quality, and real-time performance. They are particularly prone to brightness overflow and color distortion in bright light environments, and matrix transpose processing is inefficient, leading to stuttering in real-time previews.
The method of block matrix transpose and chromaticity calibration is adopted to perform block matrix transpose and chromaticity calibration on luminance data and chromaticity data respectively. Combined with luminance fidelity processing, the spatial position binding of luminance and chromaticity is ensured, and the rotated image data is output by merging processing.
It improves the processing efficiency of image rotation, ensures the matching of image brightness and darkness contours with colors, reduces rotation time, and avoids color distortion and real-time preview lag.
Smart Images

Figure CN121865115A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and more particularly to a method and apparatus for optimizing image data rotation. Background Technology
[0002] This section is intended to provide background or context for the embodiments of this application set forth in the claims. The description herein is not an admission that it is prior art simply because it is included in this section.
[0003] Mobile device cameras typically output images in landscape format by default, requiring rotation to adapt for portrait displays. However, existing image rotation solutions suffer from several drawbacks, struggling to balance processing efficiency, image quality, and real-time performance. When capturing images in bright light, the light intensity signal received by the camera sensor can cause some pixels to exceed their normal brightness range. Existing rotation solutions often directly rotate the raw brightness data without pre-correcting overexposed pixels, resulting in a loss of tonal gradation in the rotated portrait image, severely impacting the visual experience. Furthermore, existing solutions suffer from mismatched processing rhythms and block logic between brightness and chrominance data during rotation, leading to misalignments such as brightness areas lacking corresponding colors and color areas lacking corresponding brightness, resulting in color distortion. Finally, matrix transpose processing is inefficient. Existing image rotation solutions often employ full matrix transpose, directly transposing the complete brightness / chrominance data. Due to the large data volume and low CPU cache hit rate, frequent data reads from memory are necessary, resulting in long processing times and potential stuttering in real-time preview scenes. Summary of the Invention
[0004] One objective of this application is to provide an image data rotation optimization method that reduces the overall processing time of image rotation by using a block matrix while ensuring the matching of image brightness and darkness contours with colors. Another objective of this application is to provide an image data rotation optimization apparatus.
[0005] To achieve the above objectives, this application discloses an image data rotation optimization method applied to a data rotation optimization network, the method comprising: The data rotation optimization network includes an application layer, a bridging layer, and a code layer; The application layer obtains the encapsulated image data, processes the image data into initial color space data containing luminance data and chrominance data, and converts the initial color space data into pointer type through the bridging layer; The code layer performs a block matrix transpose operation on the luminance data, and simultaneously performs a block matrix transpose and chromaticity calibration on the chromaticity data to obtain the rotated luminance data and the rotated chromaticity data, respectively. At the code layer, the rotated luminance data and the rotated chrominance data are merged into processed color space data, which is then returned to the application layer through the bridging layer to output the rotated image data.
[0006] Optionally, processing the image data into color space data containing luminance and chrominance data includes: The application layer calls the image proxy callback interface to obtain the encapsulated image proxy image data; The image proxy data is parsed to extract the luminance channel data and chrominance channel data; The chroma channel data is reorganized into an alternating chroma format, and then the reorganized chroma data is spliced with the luminance data to form color space data.
[0007] Optionally, converting the initial color space data to a pointer type via a bridging layer includes: The bridging layer receives the initial color space data transmitted from the application layer and calculates the starting address of the initial color space data; The starting address is converted into an unsigned character pointer, and a first pointer is defined to point to the starting address as a mapping of the luminance data storage address; Calculate the storage address offset of the chromaticity data based on the luminance data, and define a second pointer to point to the position in the initial color space data after offset by the offset, as the mapping of the chromaticity data storage address.
[0008] Optionally, this also includes performing a block matrix transpose operation on the brightness data at the code level: The brightness data is processed to maintain its brightness fidelity at the code level.
[0009] Optionally, the brightness fidelity processing includes: The code layer iterates through each pixel in the brightness data using the first pointer and reads the brightness value corresponding to each pixel. Each brightness value is compared with a preset brightness safety threshold. If the brightness value does not exceed the brightness safety threshold, the brightness value is kept unchanged. If the brightness value exceeds the brightness safety threshold, the pixel is marked as an overexposed pixel. Perform brightness adjustment on all overexposed pixels to correct their brightness values to the normal range, thus completing the brightness fidelity processing of the brightness data.
[0010] Optionally, performing a block matrix transpose operation on the brightness data includes: The code layer divides the brightness data into several brightness pixel blocks of the same size, performs a matrix transpose operation on each brightness pixel block, and swaps the row index and column index of the pixels in the brightness pixel block to obtain the transposed brightness pixel block. The transposed luminance pixel blocks are subjected to a row reversal operation based on a preset rotation angle, adjusting the arrangement order of each row within the luminance pixel blocks.
[0011] Optionally, performing a block matrix transpose on the chroma data includes: The code layer calculates the width and height of the chroma plane based on the image width and image height, and divides the chroma data into several chroma pixel blocks; The spatial position of each chroma pixel block in the chroma plane corresponds to the spatial position of each luma pixel block in the luma plane. Perform a matrix transpose operation on each chroma pixel block, swapping the row and column indices of the chroma component pairs within the chroma pixel block to obtain the transposed chroma pixel block. The transposed chroma pixel block is subjected to a row reversal operation based on a preset rotation angle, adjusting the arrangement order of each row within the chroma pixel block.
[0012] Optionally, performing colorimetric calibration processing on the colorimetric data includes: Each chroma pixel block contains a preset number of consecutive chroma component pairs; Traverse each chroma component pair in the transposed chroma pixel block, read the value of each component and compare it with a preset chroma safety threshold. If the component value exceeds the chroma safety threshold, reduce the component value by a preset ratio to obtain the chroma-calibrated chroma component pair.
[0013] Optionally, merging the rotated luminance data and the rotated chrominance data into processed color space data at the code layer includes: In the code layer, a temporary memory block is allocated, and the rotated luminance data and rotated chrominance data are copied to the temporary memory block. Then, the data in the temporary memory block is passed to the bridging layer.
[0014] In another aspect, this application discloses an image data rotation optimization apparatus, the apparatus comprising: Data processing module: The application layer obtains the encapsulated image data, processes the image data into initial color space data containing luminance data and chrominance data, and converts the initial color space data into pointer type through the bridging layer; Rotation processing module: The code layer performs a block matrix transpose operation on the luminance data, and simultaneously performs block matrix transpose and chromaticity calibration processing on the chromaticity data to obtain the rotated luminance data and rotated chromaticity data, respectively. Merging module: At the code layer, the rotated luminance data and the rotated chrominance data are merged into processed color space data, which is then returned to the application layer through the bridging layer.
[0015] The beneficial effects of this application are as follows: The image data rotation optimization method and apparatus disclosed in this application achieves spatial binding of brightness and chromaticity data by synchronously performing block matrix transpose on the code layer in the layered collaboration of the application layer, bridging layer, and code layer. This ensures the matching of image sensitive contours and colors, and the use of block matrix reduces the processing time of image rotation, thereby quickly outputting the rotated image. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings: Figure 1 This diagram illustrates a specific embodiment of the image data rotation optimization method according to this application. Figure 2 The flowcharts of specific embodiments S110-S130 of the image data rotation optimization method according to the present application are shown. Figure 3 The flowcharts of specific embodiments S140-S160 of the image data rotation optimization method according to the present application are shown. Figure 4 The flowcharts of specific embodiments S410-S430 of the image data rotation optimization method according to the present application are shown. Figure 5 The flowcharts of specific embodiments S210-S220 of the image data rotation optimization method according to the present application are shown. Figure 6 The diagram illustrates a specific example of a specific embodiment of the image data rotation optimization method according to this application. Figure 7 The flowcharts of specific embodiments S230-S250 of the image data rotation optimization method according to the present application are shown. Figure 8 The flowcharts of specific embodiments of the image data rotation optimization method of this application (S260-S270) are shown. Figure 9 This invention provides a schematic diagram of the modules of an image data rotation optimization device according to an embodiment of the present application. Figure 10 A schematic diagram of the structure of a computer device used to implement embodiments of the present invention is shown. Detailed Implementation
[0017] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " indicates "or," for example, A / B can mean A or B; "and / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0018] It should be understood that the terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "include" and "have," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or programmable logic device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or programmable logic devices.
[0019] References to embodiments in this application mean that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.
[0020] In order to solve at least one of the problems existing in the prior art, according to one aspect of this application, such as Figure 1 As shown, this embodiment discloses an image data rotation optimization method, the method comprising: S100: The application layer obtains the encapsulated image data, processes the image data into initial color space data containing luminance data and chrominance data, and converts the initial color space data into a pointer type through the bridging layer.
[0021] Specifically, the application layer acquires the encapsulated image data. This encapsulated image data is a data package formed by the system according to a preset format after the camera sensor captures the raw image information. The encapsulated image data contains pixel information and shooting parameters, therefore it needs to be further processed into initial color space data containing luminance and chrominance data. The initial color space data stores the image's luminance and chrominance data separately. The luminance data is obtained from the light intensity signal captured by the camera sensor through digital-to-analog conversion and is used to reflect the brightness of the image; each pixel corresponds to an independent luminance value. The chrominance data is used to reflect the color attributes of the image and is obtained by calculating the difference between the red and blue components in the image and the luminance value. The bridging layer is an intermediate interaction layer connecting the application layer and the code layer. The application layer and the code layer use different development languages, and the two languages need to be converted through the bridging layer. Converting the initial color space data to a pointer type allows the code layer to directly access the data memory. In the application layer, the initial color space data is stored in the form of an array, and the memory address of the array element is managed by the virtual machine and cannot be directly accessed by the code layer. When converted to a pointer type, the code layer can read and modify the luminance and chrominance data in memory through the pointer to avoid the memory consumption caused by data copying.
[0022] S200: The code layer performs a block matrix transpose operation on the luminance data, and simultaneously performs a block matrix transpose and chromaticity calibration on the chromaticity data to obtain the rotated luminance data and the rotated chromaticity data, respectively.
[0023] Specifically, the code layer can directly manipulate memory. The code layer performs block matrix transpose operations on luminance data, and block matrix transpose and chrominance calibration on chrominance data. Since complete luminance and chrominance data are large, directly performing matrix transpose on the complete data would cause the CPU to frequently read data from memory. However, by dividing the data into small pixel blocks, the CPU can read the entire pixel block into the cache at once, thus improving computational efficiency. Adjusting the spatial position of chrominance data may cause some component values to exceed the normal display range. If not calibrated, this will lead to color distortion in the image after rotation. Therefore, calibration is necessary to correct the chrominance components to a reasonable range.
[0024] S300: At the code layer, the rotated luminance data and the rotated chrominance data are merged into processed color space data, which is then returned to the application layer through the bridging layer to output the rotated image data.
[0025] Specifically, the rotated luminance and chrominance data need to be merged into processed color space data so that the application layer can read the data in a unified format. If the luminance and chrominance data are stored separately, the application layer cannot directly parse them into a complete image. During merging, the storage rules of the initial color space data must be followed so that the application layer can accurately identify the boundaries between the two types of data. Finally, the processed color space data is converted into a format that the application layer can recognize and returned through a bridging layer, thus completing the entire rotation optimization process.
[0026] It should be noted that the application layer can use the processed data for portrait-oriented storage or real-time preview. This application is not limited to this and can also be used for other scenarios such as image editing and video encoding.
[0027] In alternative implementations, such as Figure 2 As shown, S100 processes the image data into color space data containing luminance data and chrominance data, including: S110: The application layer calls the image proxy callback interface to obtain the encapsulated image proxy image data.
[0028] Specifically, the image proxy callback interface is an interface provided by the system for transmitting image data. Traditional methods of directly acquiring image data require the application layer to manually manage the data lifecycle, which can easily lead to memory leaks. The image proxy interface automatically manages the data; the application layer only needs to register a callback. When the camera sensor completes the acquisition of a frame, the system automatically triggers the callback, passing the image proxy image data to the application layer.
[0029] It should be noted that image proxy image data is the specific representation of encapsulated image data. It uses a multi-plane storage structure, that is, luminance data and chrominance data are stored in separate memory planes. This structure is designed to facilitate the system to compress or optimize the transmission of the two types of data separately.
[0030] S120: Analyze the image proxy image data and extract the luminance channel data and chrominance channel data.
[0031] Specifically, because the multi-plane structure of image proxy image data cannot be directly used for color space conversion, functions are needed to obtain the luminance plane index and chrominance plane index, and to read the independent luminance channel data and chrominance channel data respectively. During the extraction process, the type identifier of each plane must first be determined. The system labels each memory plane with either luminance or chrominance type to avoid confusion of plane types that could lead to errors in subsequent processing.
[0032] S130: The chroma channel data is reorganized into a format with alternating chroma values, and then the reorganized chroma data is spliced with the luminance data to form color space data.
[0033] Specifically, the chroma channel data is reorganized into an alternating chroma format, and then the reorganized chroma data is concatenated with the luminance data to form color space data. Different color spaces have specific requirements for the storage order of chroma data, and the default storage order of chroma channel data may be inconsistent with the target color space format. Therefore, it is necessary to iterate and reorganize to adjust the order to an alternating chroma format. During the reorganization process, the integrity of the chroma components must be maintained. For example, every two consecutive chroma values are treated as a pair of chroma components and rearranged according to the target order. The concatenation process is executed in the order of luminance data first and chroma data last to facilitate the subsequent code layer to quickly distinguish the boundary between the two types of data.
[0034] In alternative implementations, such as Figure 3 As shown, S100 converts the initial color space data into a pointer type through a bridging layer, including: S140: The bridging layer receives the initial color space data transmitted by the application layer and calculates the starting address of the initial color space data.
[0035] Specifically, the bridging layer receives data by having the application layer call a predefined function within the bridging layer, passing the initial color space data as a parameter. The memory for array data in the application layer is managed uniformly by the virtual machine. The application layer cannot directly obtain the underlying memory address of the array; it must use the bridging layer to call the memory address retrieval interface of the corresponding programming language to read the array's starting address in memory. This starting address is the basis for subsequent pointer mapping; if the starting address is calculated incorrectly, the code layer will access the wrong memory region.
[0036] S150: Convert the starting address into an unsigned character pointer, and define a first pointer pointing to the starting address as a mapping of the luminance data storage address.
[0037] Specifically, the luminance and chrominance values in the initial color space data are all non-negative integers. Unsigned character pointers can accurately store this type of data without causing data overflow due to the sign bit. The first pointer provides the code layer with an entry point to access the luminance data. Since the luminance data in the initial color space data is stored at the beginning, the address pointed to by the first pointer can cover the memory range of all luminance data. When the code layer subsequently traverses the luminance data, it only needs to use the address offset of the first pointer to read the luminance value of each pixel.
[0038] S160: Calculate the storage address offset of the chromaticity data based on the luminance data, and define a second pointer to point to the position in the initial color space data after offset by the offset, as a mapping of the chromaticity data storage address.
[0039] Specifically, the offset is calculated from the total amount of luminance data. Each pixel corresponds to a luminance value, and each luminance value occupies 1 byte. Therefore, the offset is equal to the image width × image height × 1 byte. This calculation determines the starting position of the chrominance data in the initial color space data. Since the initial color space data is stored in the order of luminance data first and chrominance data last, the offset is used to skip the luminance data area to prevent the second pointer from pointing to the luminance data area and causing access errors.
[0040] This application is not limited to this. In other embodiments, if the luminance data and chrominance data are stored in separate arrays instead of being stored contiguously, the starting address of each array can be calculated directly without deriving the chrominance data address through offset.
[0041] In an optional implementation, the method further includes performing a block matrix transpose operation on the luminance data at the S200 code layer: S400: Perform luminance fidelity processing on the luminance data at the code level.
[0042] Specifically, in bright light environments, excessively strong light signals received by the camera sensor can cause the brightness values of some pixels to exceed the normal display range, resulting in brightness overflow. If the brightness data containing this overflow is directly rotated, the overexposed areas will spread with the rotation and cannot be repaired through subsequent processing. Therefore, brightness fidelity processing is required before rotation to correct the overexposed brightness values to the normal range, thus ensuring the integrity of the brightness levels in the rotated image.
[0043] It should be noted that the brightness fidelity processing must be performed before the brightness data block matrix is transposed. If the data is transposed first and then processed, the overexposed areas will have already spread, and the correction effect will be significantly reduced. This application is not limited to this. In other embodiments, if it is an indoor uniform lighting environment with no risk of brightness overflow, this step can be skipped to reduce processing time.
[0044] In alternative implementations, such as Figure 4 As shown, the brightness fidelity processing includes: S410: The code layer traverses each pixel in the brightness data through the first pointer and reads the brightness value corresponding to each pixel.
[0045] Specifically, the code layer traverses each pixel in the brightness data using the first pointer, reading the brightness value corresponding to each pixel. The traversal uses a row-major order, ensuring the brightness data is stored contiguously in memory. This order reduces the number of memory address jumps, improving the CPU's efficiency in reading one row of data at a time into the cache. When reading the brightness value, it can be directly retrieved through the address offset of the first pointer, without needing to copy the brightness data to a new memory area.
[0046] S420: Compare each brightness value with a preset brightness safety threshold. If the brightness value does not exceed the brightness safety threshold, keep the brightness value unchanged. If the brightness value exceeds the brightness safety threshold, mark the pixel as an overexposed pixel.
[0047] Specifically, each brightness value is compared with a preset brightness safety threshold. If the brightness value does not exceed the brightness safety threshold, the brightness value remains unchanged. If the brightness value exceeds the brightness safety threshold, the pixel is marked as an overexposed pixel. The brightness safety threshold is preset based on the human eye's perception range of brightness and the brightness output capability of mainstream display devices. If the maximum brightness value of the display device is referenced, the threshold is set to a value close to but not exceeding the maximum brightness, used to determine whether the brightness value exceeds the normal display range. Overexposed pixels can be marked by establishing a temporary marker array or setting an identifier in the original brightness data. This application is not limited to these methods, as long as it can accurately distinguish between overexposed pixels and normal pixels.
[0048] S430: Perform brightness adjustment on all overexposed pixels of the marker, correct their brightness values to the normal range, and complete the brightness fidelity processing of the brightness data.
[0049] Specifically, brightness adjustment is performed on all marked overexposed pixels to correct their brightness values to the normal range, thus completing the brightness data fidelity processing. The core principle of brightness adjustment is to reduce the original brightness value of the overexposed pixel according to a preset rule based on the difference between the original brightness value and the brightness safety threshold, so that the adjusted brightness value is within the normal range. For example, a linear attenuation rule can be used: Adjusted brightness value = Brightness safety threshold - Preset ratio × (Original brightness value - Brightness safety threshold). This rule ensures a smooth brightness transition and avoids abrupt brightness changes such as abrupt changes at the boundary between overexposed and normal areas. It should be noted that since the brightness data is an integer type, the adjusted brightness value needs to be integerized, which can be done by rounding or rounding down to ensure that the processed brightness value meets the storage format requirements.
[0050] In an optional implementation, Figure 5 As shown, performing a block matrix transpose operation on the brightness data includes: S210: The code layer divides the brightness data into several brightness pixel blocks of the same size, performs a matrix transpose operation on each brightness pixel block, and swaps the row index and column index of the pixels in the brightness pixel block to obtain the transposed brightness pixel block.
[0051] Specifically, the code layer divides the brightness data into several uniformly sized brightness pixel blocks. This block division is necessary because the complete brightness data is quite large; directly performing matrix transpose on the complete data leads to a high cache miss rate, causing the CPU to frequently read data from memory, resulting in low processing efficiency. By dividing the brightness data into smaller pixel blocks, the CPU can read the entire pixel block into the cache at once, significantly improving data access efficiency. The pixel block size needs to be adapted to the CPU cache line characteristics. In a specific example, if the CPU cache line size is 64 bytes, the pixel block size can be set to 8×8 pixels, with each pixel being 1 byte, for a total size of 64 bytes. This application is not limited to this; in other embodiments, the pixel block size can be adjusted according to the CPU cache characteristics of different devices.
[0052] The mathematical principle of matrix transpose is to treat a pixel block as a two-dimensional matrix, such that a pixel located at (row index, column index) in the original matrix will be located at (column index, row index) after transpose. Transpose changes the spatial row and column orientation of the brightness data. It is important to note that the transpose operation must be performed within a single pixel block to avoid data confusion caused by operations across pixel blocks.
[0053] In specific examples, such as Figure 6 The diagram illustrates the transpose of a 2x4 pixel block. Before transpose: The pixel block has 2 rows and 4 columns. The row and column indices of each pixel are swapped. The pixel in the original row i and column j becomes row j and column i after transpose. After transpose: The pixel block becomes 4 rows and 2 columns. Pixels 0, 1, 2, and 3 in the original row 0 correspond to rows 0-3 and column 0 in the transpose. Pixels 4, 5, 6, and 7 in the original row 1 correspond to rows 0-3 and column 1 in the transpose. This is consistent with the logic of swapping the row and column indices of pixels within the brightness pixel block in the previous step.
[0054] S220: Perform a row reversal operation on the transposed luminance pixel block according to the preset rotation angle, and adjust the arrangement order of each row in the luminance pixel block.
[0055] Specifically, the preset rotation angle is set by the application layer according to actual needs. For example, when the default horizontal image output by the camera needs to be converted to a vertical display, the preset rotation angle can be set to 270°. The purpose of row reversal is to adjust the row order of the pixel blocks based on the matrix transpose, so that it conforms to the spatial direction of the preset rotation angle. In a specific example, the row order of the transposed pixel blocks is row 1, row 2, row 3. After performing row reversal, it becomes row 3, row 2, row 1, ultimately achieving the 270° rotation effect.
[0056] In alternative implementations, such as Figure 7 As shown, performing a block matrix transpose on the chroma data includes: S230: The code layer calculates the width and height of the chroma plane based on the image width and image height, and divides the chroma data into several chroma pixel blocks.
[0057] Specifically, the calculation of the chroma plane's width and height stems from the fact that most color spaces use a specific chroma sampling ratio, meaning that every four luminance pixels correspond to one group of chroma pixels. Therefore, the chroma plane width = image width / 2, and the chroma plane height = image height / 2, ensuring that the spatial dimensions of the chroma plane match the luminance plane and preventing spatial ratio misalignment during subsequent transposition. The size of the chroma pixel blocks must be consistent with the size of the luminance pixel blocks to facilitate synchronous processing of luminance and chroma data.
[0058] S240: The spatial position of each chroma pixel block in the chroma plane corresponds to the spatial position of each luminance pixel block in the luminance plane. Perform a matrix transpose operation on each chroma pixel block, swapping the row and column indices of the chroma component pairs within the chroma pixel block to obtain the transposed chroma pixel block.
[0059] The specific spatial relationship is as follows: a 2×2 pixel luminance pixel block in the luminance plane corresponds to a 1×1 pixel chrominance pixel block in the chrominance plane, ensuring accurate matching of the chrominance regions corresponding to each luminance region after rotation, thus avoiding color misalignment. A chrominance component pair refers to two related chrominance values in the chrominance data; the integrity of the component pairs must be maintained during transpose to avoid loss of color information.
[0060] S250: Perform a row reversal operation on the transposed chroma pixel block according to the preset rotation angle, and adjust the arrangement order of each row in the chroma pixel block.
[0061] Specifically, the transposed chroma pixel blocks are subjected to a row-by-row reversal operation based on a preset rotation angle, adjusting the arrangement order of each row within the chroma pixel block. This ensures that the rotation angle of the chroma data is the same as that of the luminance data. If the luminance data is rotated 270° and the row reversal is performed, the chroma data must also be processed according to the same rule; otherwise, the spatial orientation of luminance and chroma will be inconsistent after rotation. It should be noted that the order of the chroma component pairs must be maintained during the row reversal to avoid confusion of color attributes.
[0062] In alternative implementations, such as Figure 8 As shown, performing colorimetric calibration processing on the colorimetric data includes: S260: Each chroma pixel block contains a preset number of consecutive chroma component pairs.
[0063] Specifically, most discrete color spaces require two complementary chromaticity components to represent colors. A single chromaticity component cannot reflect color attributes, so they must be stored in pairs. The preset number is determined based on the size of the chromaticity pixel block and the chromaticity sampling ratio. For example, an 8×8 pixel chromaticity pixel block contains 64 chromaticity component pairs, corresponding to a 32×32 pixel area in the luminance plane, so that the number of component pairs contained in each chromaticity pixel block matches the number of luminance pixels corresponding to that block.
[0064] S270: Traverse each chroma component pair in the transposed chroma pixel block, read the value of each component and compare it with a preset chroma safety threshold. If the component value exceeds the chroma safety threshold, reduce the component value by a preset ratio to obtain the chroma-calibrated chroma component pair.
[0065] Specifically, a color safety threshold is set based on the normal value range of chroma components in mainstream color coding standards. If the component value exceeds this threshold, it will cause color cast in the image. The traversal method needs to access each component in the component pair one by one, because different components may correspond to different color attributes, and it is necessary to determine whether they exceed the threshold separately. If the component value exceeds the color safety threshold, the component value is reduced by a preset ratio to obtain a color-calibrated chroma component pair. It is necessary to preserve the color gradation while correcting the color cast. If the ratio is too large, it will cause the color to become dull; if the ratio is too small, it will not effectively correct the color cast. For example, a stepped ratio is used: a 10% reduction for slight over-threshold, a 20% reduction for moderate over-threshold, and a 30% reduction for severe over-threshold, so that different degrees of color cast can be corrected in a targeted manner.
[0066] In an optional implementation, S300 merges the rotated luminance data and the rotated chrominance data into processed color space data at the code layer, including: In the code layer, a temporary memory block is allocated, and the rotated luminance data and rotated chrominance data are copied to the temporary memory block. Then, the data in the temporary memory block is passed to the bridging layer.
[0067] Specifically, the rotated luminance and chrominance data are stored in separate memory areas. Luminance data is stored in the target memory on the Y-plane, and chrominance data is stored in the target memory on the chrominance plane. Directly merging them in the original memory area may overwrite unprocessed original data. Requesting temporary memory provides an independent, contiguous storage area, ensuring a safe merging process. The size of the temporary memory must be equal to the sum of the rotated luminance data and the rotated chrominance data, where luminance data = image width × image height × 1 byte, and chrominance data = (image width / 2) × (image height / 2) × 2 bytes. This application is not limited to this; in other embodiments, if the original data does not need to be retained, they can be directly merged in the original memory area. After copying the chrominance data to the memory area of the luminance data, memory allocation time is reduced. The rotated luminance and chrominance data are copied to the temporary memory. The copying order is rotated luminance data first, followed by rotated chrominance data. When the application layer reads color space data, it defaults to first constructing grayscale contours to resolve luminance information, and then superimposing color information to resolve chrominance information. This order allows the application layer to correctly identify the boundaries between the two types of data. The copying process is implemented through the memory copy interface, and the copy length must be strictly controlled: the copy length of luminance data = image width × image height × 1 byte, and the copy length of chrominance data = (image width / 2) × (image height / 2) × 2 bytes, to avoid data overflow or incomplete copying due to incorrect copy length.
[0068] The data in the temporary memory is then passed to the bridge layer. This passing process is necessary because the bridge layer needs to convert the data in the temporary memory into a format recognizable by the application layer. The data in the temporary memory is stored as pointers in the code layer, which the application layer cannot directly access. Therefore, the bridge layer needs to call a data type conversion interface to write the data from the temporary memory into an array recognizable by the application layer. It is important to note that after the data transfer is complete, the temporary memory must be released promptly to avoid memory leaks.
[0069] According to another aspect of this application, such as Figure 9 As shown, this embodiment also discloses an image data rotation optimization device, the device comprising: Data processing module 11: The application layer obtains the encapsulated image data, processes the image data into initial color space data containing luminance data and chrominance data, and converts the initial color space data into pointer type through the bridging layer; Rotation processing module 12: The code layer performs a block matrix transpose operation on the luminance data, and simultaneously performs block matrix transpose and chromaticity calibration processing on the chromaticity data to obtain the rotated luminance data and the rotated chromaticity data, respectively. Merging module 13: At the code layer, the rotated luminance data and the rotated chrominance data are merged into processed color space data, which is then returned to the application layer through the bridging layer.
[0070] Since the principle by which this device solves the problem is similar to the methods described above, the implementation of this device can be found in the implementation of the methods, and will not be repeated here.
[0071] This application also provides a computer programmable logic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described method.
[0072] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.
[0073] Those skilled in the art will understand that the embodiments of this application can provide methods, systems, or computer programs that produce the systems, apparatuses, modules, or units described in the above embodiments. Specifically, they can be implemented by computer chips or entities, or by products with certain functions. A typical implementation of a programmable logic device is a computer programmable logic device. Specifically, a computer programmable logic device can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation programmable logic device, email programmable logic device, game console, tablet computer, wearable programmable logic device, or any combination of these programmable logic devices.
[0074] In a typical example, a computer programmable logic device specifically includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the method executed by the client as described above, or the method executed by the server as described above.
[0075] The following is for reference. Figure 10 It shows a schematic diagram of the structure of a computer programmable logic device 600 suitable for implementing embodiments of the present application.
[0076] like Figure 10As shown, the computer programmable logic device 600 includes a central processing unit (CPU) 601, which can perform various appropriate tasks and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage section 608 into a random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the computer programmable logic device 600. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0077] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal feedback (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed in storage section 608 as needed.
[0078] In particular, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program including program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611.
[0079] Computer-readable media include both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage, programmable logic devices, or any other non-transfer medium that can be used to store information accessible by a computer programmable logic device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0080] For ease of description, the above devices are described separately by function as various units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.
[0081] This application is described with reference to flowchart illustrations and / or block diagrams of methods, programmable logic devices (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing programmable logic device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing programmable logic device, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0082] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing programmable logic device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0083] These computer program instructions can also be loaded onto a computer or other programmable data processing logic device, causing a series of operational steps to be executed on the computer or other programmable logic device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable logic device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0084] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or programmable logic device that includes 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 programmable logic device. Without further limitations, an element defined by the statement "including one..." does not exclude the presence of other identical elements in the process, method, article, or programmable logic device that includes said element.
[0085] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0086] This application can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This application can also be practiced in distributed computing environments where tasks are performed by remotely processed programmable logic devices connected via a communication network. In a distributed computing environment, program modules can reside in local and remote computer storage media, including storage for programmable logic devices.
[0087] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0088] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. An image data rotation optimization method, applied to a data rotation optimization network, characterized in that, The method includes: The data rotation optimization network comprises an application layer, a bridging layer, and a code layer. The application layer acquires the encapsulated image data, processes the image data into initial color space data containing luminance and chrominance data, and then converts the initial color space data into a pointer type through the bridging layer. The code layer performs a block matrix transpose operation on the luminance data, and simultaneously performs a block matrix transpose and chromaticity calibration on the chromaticity data to obtain the rotated luminance data and the rotated chromaticity data, respectively. At the code layer, the rotated luminance data and the rotated chrominance data are merged into processed color space data, which is then returned to the application layer through the bridging layer to output the rotated image data.
2. The image data rotation optimization method according to claim 1, characterized in that, Processing the image data into color space data containing luminance and chrominance data includes: The application layer calls the image proxy callback interface to obtain the encapsulated image proxy image data; The image proxy data is parsed to extract the luminance channel data and chrominance channel data; The chroma channel data is reorganized into an alternating chroma format, and then the reorganized chroma data is spliced with the luminance data to form color space data.
3. The image data rotation optimization method according to claim 1, characterized in that, Converting the initial color space data to a pointer type via a bridging layer includes: The bridging layer receives the initial color space data transmitted from the application layer and calculates the starting address of the initial color space data; The starting address is converted into an unsigned character pointer, and a first pointer is defined to point to the starting address as a mapping of the luminance data storage address; Calculate the storage address offset of the chromaticity data based on the luminance data, and define a second pointer to point to the position in the initial color space data after offset by the offset, as the mapping of the chromaticity data storage address.
4. The image data rotation optimization method according to claim 3, characterized in that, This also includes performing a block matrix transpose operation on the brightness data at the code level: The brightness data is processed to maintain its brightness fidelity at the code level.
5. The image data rotation optimization method according to claim 4, characterized in that, The brightness fidelity processing includes: The code layer iterates through each pixel in the brightness data using the first pointer and reads the brightness value corresponding to each pixel. Each brightness value is compared with a preset brightness safety threshold. If the brightness value does not exceed the brightness safety threshold, the brightness value is kept unchanged. If the brightness value exceeds the brightness safety threshold, the pixel is marked as an overexposed pixel. Perform brightness adjustment on all overexposed pixels to correct their brightness values to the normal range, thus completing the brightness fidelity processing of the brightness data.
6. The image data rotation optimization method according to claim 1, characterized in that, Performing a block matrix transpose operation on the brightness data includes: The code layer divides the brightness data into several brightness pixel blocks of the same size, performs a matrix transpose operation on each brightness pixel block, and swaps the row index and column index of the pixels in the brightness pixel block to obtain the transposed brightness pixel block. The transposed luminance pixel blocks are subjected to a row reversal operation based on a preset rotation angle, adjusting the arrangement order of each row within the luminance pixel blocks.
7. The image data rotation optimization method according to claim 6, characterized in that, Performing a block matrix transpose on the chromaticity data includes: The code layer calculates the width and height of the chroma plane based on the image width and image height, and divides the chroma data into several chroma pixel blocks; The spatial position of each chroma pixel block in the chroma plane corresponds to the spatial position of each luma pixel block in the luma plane. Perform a matrix transpose operation on each chroma pixel block, swapping the row and column indices of the chroma component pairs within the chroma pixel block to obtain the transposed chroma pixel block. The transposed chroma pixel block is subjected to a row reversal operation based on a preset rotation angle, adjusting the arrangement order of each row within the chroma pixel block.
8. The image data rotation optimization method according to claim 7, characterized in that, Performing colorimetric calibration processing on the colorimetric data includes: Each chroma pixel block contains a preset number of consecutive chroma component pairs; Traverse each chroma component pair in the transposed chroma pixel block, read the value of each component and compare it with a preset chroma safety threshold. If the component value exceeds the chroma safety threshold, reduce the component value by a preset ratio to obtain the chroma-calibrated chroma component pair.
9. The image data rotation optimization method according to claim 1, characterized in that, The process of merging the rotated luminance data and the rotated chrominance data into processed color space data at the code level includes: In the code layer, a temporary memory block is allocated, and the rotated luminance data and rotated chrominance data are copied to the temporary memory block. Then, the data in the temporary memory block is passed to the bridging layer.
10. An image data rotation optimization device, characterized in that, The device includes: Data processing module: The application layer obtains the encapsulated image data, processes the image data into initial color space data containing luminance data and chrominance data, and converts the initial color space data into pointer type through the bridging layer; Rotation processing module: The code layer performs a block matrix transpose operation on the luminance data, and simultaneously performs block matrix transpose and chromaticity calibration processing on the chromaticity data to obtain the rotated luminance data and rotated chromaticity data, respectively. Merging module: At the code layer, the rotated luminance data and the rotated chrominance data are merged into processed color space data, which is then returned to the application layer through the bridging layer.