Image arbitrary angle rotation method and device based on Z-shaped segmentation efficient caching
The image rotation method based on Z-shaped segmentation and AXI bus feature optimization solves the problems of complex calculation and low bus transmission efficiency in hardware implementation, and realizes efficient processing of image rotation at any angle.
Patent Information
- Application Number
- CN202510507113.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-09-30
AI Technical Summary
It is difficult to achieve efficient processing of arbitrary-angle image rotation with existing technologies, especially due to the problems of complex calculations and low bus transmission efficiency in hardware implementation.
The Z-shaped segmentation method is used to divide the image into blocks, and the block type is determined by inverse rotation calculation. The burst and advance transmission characteristics of the AXI bus are utilized to improve bus transmission efficiency, reduce diamond boundary and Bresenham line calculations, and cache the original image pixel blocks.
The overall performance of image rotation processing is improved, bus data transmission time is reduced, and the efficiency of image rotation and bus transmission utilization are increased.
Smart Images

Figure CN120725878A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method and device for rotating an image at any angle based on Z-shaped segmentation and efficient caching. Background Art
[0002] Image rotation at any angle means rotating an image counterclockwise or clockwise by a specified angle. The image with the smallest rectangle surrounding the image after rotation is the rotated image.
[0003] The use of fixed-angle rotation technology to achieve image rotation cannot meet the rotation requirements of any angle from 0 to 360. The method of using software calculation to achieve image rotation will take up a lot of CPU resources. Some also use hardware circuits to implement the arbitrary-angle rotation function of the image, but the implementation algorithm is relatively complicated. For example, Guangzhou Jiangxinchuang Technology Co., Ltd. applied for "Implementation Method and Medium for Arbitrary-Angle Rotation of 2D Graphics" on August 20, 2021, application number 202110419500.9, which introduced a hardware implementation method for arbitrary-angle graphic rotation. The main features of this method are: processing the image according to the graphics, dividing the original image into blocks, and then rotating it to the target image to form a diamond-shaped block in the target image. Then, based on the coordinates of the four vertices of the diamond, the boundaries of the four sides of the diamond are calculated, and then the Bresenham line drawing algorithm is used to calculate all the coordinates in the four boundaries, and each pixel in the diamond block is de-mapped to the original image to find the adjacent four pixels. Finally, the target image is calculated using a bilinear interpolation algorithm using these four pixel values and written to the DDR. However, this method has two drawbacks. The first is that the calculation of the four boundaries and internal pixels of the target image's rhombus is cumbersome and requires complex hardware implementation, using a two-point line equation and the Bresenham line drawing algorithm. The second drawback is that the target image is a rhombus, and the target image is stored row-by-row, which makes it difficult to write the target image back to the DDR. This results in bursty bus transfers and low bus utilization. Summary of the Invention
[0004] To achieve the above objectives, this application provides the following technical solutions: According to a first aspect of the present invention, the present invention claims a method for rotating an image at any angle based on Z-shaped segmentation and efficient caching, comprising: The target image to be rotated is divided into blocks, and then the coordinates of the image to be rotated corresponding to the target image are calculated by inverse rotation according to the vertex coordinates of the blocks; Determining the relationship between the coordinates of the image to be rotated corresponding to the vertex coordinates of the target image after the block is divided and the coordinates of the image to be rotated, and determining whether the current target pixel block is a filling block or a scanning block; Write the lower left corner coordinate of the current destination pixel block into the fill block buffer fifo or the block scan buffer fifo.
[0005] Furthermore, the method of dividing the target image to be rotated into blocks and then calculating the coordinates of the image to be rotated corresponding to the target image by inverse rotation according to the vertex coordinates of the blocks further includes: The target image to be rotated is segmented in a z-shape, thereby improving the pixel utilization rate of reading the image to be rotated, which is the ratio of the number of pixels of the image to be rotated to the number of pixels of the original image actually read from the external storage DDR; The target image to be rotated is segmented in a z-shape. Based on the rotation characteristics, the pixels of the original image are read in a row-by-block manner, which increases the spatial correlation of the pixel blocks of the image to be rotated, facilitates the use of a cache structure to cache the image blocks of the image to be rotated, and improves the pixel utilization rate of the image to be rotated. Furthermore, the determining of the relationship between the coordinates of the image to be rotated corresponding to the vertex coordinates of the target image after the block division and the coordinates of the image to be rotated, and determining whether the current target pixel block is a filling block or a scanning block, further includes: Reversely rotate the vertices of the image blocks of the segmented target image; Determine the type of the current block based on the inverse rotation result; If the current block is a fill block, it is sent to the fill block buffer for fill block processing; If it is a scan block, it is sent to the scan block cache for scan block processing.
[0006] Furthermore, if the current block is a filling block, the current block is sent to a filling block cache for filling block reading, further comprising: The AXI bus output module reads the padding block from the padding block cache, and calculates the first address of each row of pixels in the block based on the coordinates of the lower left corner of the padding block and the base address of the destination image. The burst mode of the AXI bus is used, and the burst length is the size of one row of pixels in the block. The advance transmission of the AXI bus is the column size of the block, and the data written by the AXI bus is the padding pixel value, which is configured by the user; Write the pixels of the current filling block to DDR via the AXI bus; Furthermore, if it is a scan block, it is sent to the scan block cache for scan block processing, further comprising: Performing pixel-by-pixel rotation processing on the scanning block; Calculate the coordinates of the internal pixels of the image block of the segmented target image, and calculate the corresponding position of the pixel in the image to be rotated through inverse rotation operation; Read the color values of the four nearest pixels surrounding the position according to the coordinate value of the position and perform bilinear interpolation; After the interpolation is completed, it is cached until all pixels in the scan block are processed; Send a request to the AXI bus output module. The AXI bus uses burst mode and advance transmission mode to write the pixels of the scanned block to DDR.
[0007] According to a second aspect of the present invention, the present invention claims protection for an image arbitrary angle rotation device based on Z-shaped segmentation and efficient caching, which is used to execute the image arbitrary angle rotation method based on Z-shaped segmentation and efficient caching, comprising: apb_cfg module, main_ctrl module, block_scan module and axi_out module; The apb_cfg module parses the apb bus, obtains the user's configuration value, completes interrupt processing, and completes the control of the working mode; The main_ctrl module completes the block calculation of the target image, the determination of the block type of the target image, and the caching of the coordinates of the lower left corner of the filling block and the scanning block; The block_scan module completes the scanning of the internal pixels of the scanning block, then performs inverse rotation processing on the coordinates of each scanned pixel, reads the pixels of the original image through the cache, calculates the color value of the target pixel according to bilinear interpolation, and performs ping-pong caching on the scan results; The axi_out module completes the pixel output work of the filling block and the scanning block.
[0008] The present application relates to the field of image processing technology, and in particular to a method and device for rotating an image at any angle based on Z-shaped segmentation and efficient caching. The method divides both the target image and the original image into blocks, and reversely rotates the four coordinate points of the target block to the original image, and first determines whether the current target block is a filling block or a scanning block. The present invention efficiently utilizes the burst transmission and advance transmission characteristics of the AXI bus, greatly improving the utilization rate of bus transmission, reducing the transmission time of bus data, and improving the overall performance of image rotation processing; the present invention divides the target image into blocks, avoiding complex diamond boundary calculations and Bresenham line drawing calculations. The Z-shaped segmentation method is used for the target image blocks, which increases the correlation of the pixel reading of the original image block when calculating the color of the target image, making it convenient to use cache for caching. The cache form is used to cache the original image pixel blocks, which reduces the number of times the original image pixel blocks are read, reduces the bus reading time, and improves the overall performance of image rotation processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1This is a workflow diagram of a method for rotating an image at any angle based on Z-shaped segmentation and efficient caching as claimed in an embodiment of the present application; Figure 2 A schematic diagram of image segmentation for the purpose of a method for rotating an image at any angle based on Z-shaped segmentation and efficient caching as claimed in an embodiment of the present application; Figure 3 This is a schematic structural diagram of an image arbitrary angle rotation device based on Z-shaped segmentation and efficient caching as claimed in an embodiment of the present application; Figure 4 This is a schematic diagram of the circuit structure of the apb_cfg module of an image arbitrary angle rotation device based on Z-shaped segmentation and efficient caching as claimed in an embodiment of the present application; Figure 5 This is a schematic diagram of the circuit structure of the main_ctrl module of an image arbitrary angle rotation device based on Z-shaped segmentation and efficient caching as claimed in an embodiment of the present application; Figure 6 This is a schematic diagram of the circuit structure of a block scanning module of an image arbitrary angle rotation device based on Z-shaped segmentation and efficient caching as claimed in an embodiment of the present application; Figure 7 This is a schematic diagram of the circuit structure of the axi_out module of an image arbitrary angle rotation device based on Z-shaped segmentation and efficient caching as claimed in an embodiment of the present application. DETAILED DESCRIPTION
[0010] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0011] The terms "first," "second," and "third" in this application are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, features specified as "first," "second," or "third" may explicitly or implicitly include at least one of such features. In the description of this application, "plurality" means at least two, for example, two, three, etc., unless otherwise specifically defined. All directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of this application are intended only to illustrate the relative positional relationships and movement of components in a specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indications will also change accordingly. Furthermore, the terms "including," "having," and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or elements is not limited to the listed steps or elements and may optionally include steps or elements not listed, or may optionally include other steps or elements inherent to such process, method, product, or apparatus.
[0012] References to "embodiments" herein mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0013] In the present invention, the calculation process of rotating an image at any angle first divides the target image into blocks, and then calculates the coordinates of the corresponding original image by inverse rotation based on the coordinates of the four points of the block. Then, the relationship between the coordinates of the original image corresponding to these four points and the original image is determined, and then it is determined whether the current target pixel block is a filling block or a scanning block. After the calculation is completed, the coordinates of the lower left corner of these two types of blocks are written into the filling block cache fifo and the block scan cache fifo respectively. For the processing of the filling block, the output is directly output using the AXI bus burst and advance transmission method. The scanning block needs to be scanned pixel by pixel and row by row, and then each pixel is inversely rotated to find the corresponding coordinates in the original image coordinate system. According to the coordinates, the four pixels surrounding the coordinates are found, and finally the pixel value is calculated through bilinear interpolation. The pixel values of the entire scanning block are calculated in sequence, and then output by the AXI bus in a burst and advance transmission manner. The entire image rotation design scheme is described in detail below.
[0014] According to the first embodiment of the present invention, the present invention claims a method for rotating an image at any angle based on Z-shaped segmentation and efficient caching, referring to Figure 1 ,include: The target image to be rotated is divided into blocks, and then the coordinates of the image to be rotated corresponding to the target image are calculated by inverse rotation according to the vertex coordinates of the blocks; Determining the relationship between the coordinates of the image to be rotated corresponding to the vertex coordinates of the target image after the block is divided and the coordinates of the image to be rotated, and determining whether the current target pixel block is a filling block or a scanning block; Write the lower left corner coordinate of the current destination pixel block into the fill block buffer fifo or the block scan buffer fifo; The filling block directly fills pixels, and the scanning block scans pixel by pixel; The blocks that have been filled and the blocks that have been scanned are output through the AXI bus.
[0015] Furthermore, the method of dividing the target image to be rotated into blocks and then calculating the coordinates of the image to be rotated corresponding to the target image by inverse rotation according to the vertex coordinates of the blocks further includes: The target image to be rotated is segmented in a z-shape, thereby improving the pixel utilization rate of reading the image to be rotated, which is the ratio of the number of pixels of the image to be rotated to the number of pixels of the original image actually read from the external storage DDR; The target image to be rotated is segmented in a z-shape. Based on the rotation characteristics, the pixels of the original image are read in a row-by-block manner, which increases the spatial correlation of the pixel blocks of the image to be rotated, facilitates the use of a cache structure to cache the image blocks of the image to be rotated, and improves the pixel utilization rate of the image to be rotated. Among them, in this embodiment, the target image is first segmented into blocks. The present invention adopts z-shaped segmentation, and this segmentation method can increase the utilization rate of reading the original image pixels. The utilization rate of reading the original image here refers to the ratio of the number of pixels of the original image to the number of original image pixels actually read from the external storage DDR. The smaller the value, the more it means that some pixels stored in the external storage DDR are read multiple times, which also means that the bandwidth utilization of the bus becomes lower, increasing the entire image rotation processing time. The larger the value, the better, and the maximum value is 1, which means that each pixel of the original image is actually read only once. In this case, the bus bandwidth utilization is the highest. Figure 2 As shown, the black dotted box is the rotated target image, the black solid box is the block of the target image, the serial number in the black block is the label of the segmented block, the blue solid box is the original image, the red dotted box is the block of the original image, and the serial number in the red dotted box is the label of the segmented block of the original image.
[0016] The common design adopts the method of segmenting the target image in order of rows and blocks. The segmentation order is in the order described in the "block scanning method" column in Table 1. Figure 2It can be obtained that when calculating the pixel value of each target image block, the number of the original image block required is described in the "required original image pixel block" in Table 1. The numbers of the "required original image pixel block" in Table 1 are arranged in order to obtain the order of "reading original image blocks" in Table 1, which is also the order in which the bus reads the original image pixel blocks. Figure 2 It can be seen that the reading of the original image pixel blocks has spatial correlation, so the cache method is used to cache the original image blocks. In order to explain the advantages of the present invention concisely and conveniently, the cache here only caches 4 pixel blocks (the actual circuit design caches 8 pixel blocks). The "source pixel blocks saved by the cache" in Table 1 are based on the order of "reading the original image blocks" in Table 1 and the LRU (least recently used) replacement algorithm to count the changes in the numbers of the 4 pixel blocks cached in the cache. Then, based on the "source pixel blocks saved by the cache" in Table 1, the statistics of the pixel block numbers read by the cache from the external storage DDR are obtained, and finally the statistics of the "number of times the source pixel block number is read by the cache" in Table 1 are obtained. From the "number of times each block of the original image is read" in Table 1, it can be concluded that Figure 2 In the example rotation, the total number of source pixel blocks read is 27. Theoretically, the best-case scenario is to read the original image only once, meaning 12 pixel blocks. Therefore, the target image is processed sequentially by row and block, resulting in a source image utilization rate of 12 / 27 = 44.4%.
[0017] Table 1 Statistics of target image segmentation by row and block
[0018] To improve the efficiency of reading the original image, the present invention employs a Z-shaped sequential segmentation of the target image into blocks. This Z-shaped segmentation corresponds to the "target image block scanning method" in Table 2. The columns in Table 2 are consistent with those in Table 1. Using this processing method, the original image utilization rate is 12 / 18 = 66.7%. The efficiency of reading the original image can also be increased by increasing the number of pixel blocks cached.
[0019] Table 2 Statistics of sequential segmentation of the target image by Z-shape blocks
[0020] Furthermore, the determining of the relationship between the coordinates of the image to be rotated corresponding to the vertex coordinates of the target image after the block division and the coordinates of the image to be rotated, and determining whether the current target pixel block is a filling block or a scanning block, further includes: Reversely rotate the vertices of the image blocks of the segmented target image; Determine the type of the current block based on the inverse rotation result; If the current block is a fill block, it is sent to the fill block cache for fill block reading; If it is a scan block, it is sent to the scan block cache for scan block processing.
[0021] Furthermore, if the current block is a filling block, the current block is sent to a filling block cache for filling block reading, further comprising: The AXI bus output module reads the padding block from the padding block cache, and calculates the first address of each row of pixels in the block based on the coordinates of the lower left corner of the padding block and the base address of the destination image. The burst mode of the AXI bus is used, and the burst length is the size of one row of pixels in the block. The advance transmission of the AXI bus is the column size of the block, and the data written by the AXI bus is the padding pixel value, which is configured by the user; Write the pixels of the current filling block to DDR via the AXI bus; Furthermore, if it is a scan block, it is sent to the scan block cache for scan block processing, further comprising: Performing pixel-by-pixel rotation processing on the scanning block; Calculate the coordinates of the internal pixels of the image block of the segmented target image, and calculate the corresponding position of the pixel in the image to be rotated through inverse rotation operation; Read the color values of the four nearest pixels surrounding the position according to the coordinate value of the position and perform bilinear interpolation; After the interpolation is completed, it is cached until all pixels in the scan block are processed; Send requests to the AXI bus output module until the AXI bus output module writes to DDR.
[0022] According to the second embodiment of the present invention, the present invention claims a device for rotating an image at any angle based on Z-shaped segmentation and efficient caching, which is used to execute the method for rotating an image at any angle based on Z-shaped segmentation and efficient caching, referring to Figure 3 ,include: apb_cfg module, main_ctrl module, block_scan module and axi_out module; The apb_cfg module parses the apb bus, obtains the user's configuration value, completes interrupt processing, and completes the control of the working mode; The main_ctrl module completes the block calculation of the target image, the determination of the block type of the target image, and the caching of the coordinates of the lower left corner of the filling block and the scanning block; The block_scan module completes the scanning of the internal pixels of the scanning block, then performs inverse rotation processing on the coordinates of each scanned pixel, reads the pixels of the original image through the cache, calculates the color value of the target pixel according to bilinear interpolation, and performs ping-pong caching on the scan results; The axi_out module completes the pixel output work of the filling block and the scanning block.
[0023] In this embodiment, Figure 4 This is the circuit structure of the apb_cfg module, which parses the APB bus protocol, converts it into an internal read-write bus, and then goes through write parsing and read parsing respectively. Write parsing mainly completes the decoding of the internal write address bus to generate the configuration required in the design. In order to parallelize user configuration with rotation calculation, the present invention adopts two sets of configuration parameters, organized into a ping-pong mode. Whenever an image rotation is completed, the hardware circuit will automatically switch to another set of parameters to continue the image rotation process. At the same time, the interrupt control generates an interrupt signal to inform the user that the rotation process is completed. The user can configure the rotation again when the hardware is performing the second rotation process, so that the user configuration and the hardware rotation calculation are processed in parallel. The interrupt supports configurable pulse width interrupts and level interrupts.
[0024] Figure 5This is the circuit structure of the main_ctrl module. This module receives the source image width (imgr_src_h) and height (imgr_src_v), the destination image width (imgr_dst_h) and height (imgr_dst_v), the sine (imgr_sina) and cosine (imgr_cosa) of the rotation angle (configured by the apb_cfg module), and the enable signal st. It first performs a Z-shaped block segmentation process, dividing the image into 16x16 pixel blocks, and then writes the coordinates of the lower left corner of the segmented block to the buffer fifo. Then, based on the sine and cosine values of the rotation angle, the coordinates of the lower left corner of the divided block and the size of the block are read from the cache fifo, and the coordinates of the four vertices of the block are calculated (xd00, yd00)(xd01, yd01)(xd10, yd10)(xd11, yd11), and then the four corresponding vertices of the original image are calculated using the inverse rotation formula (xs00, ys00)(xs01, ys01) (xs10, ys10)(xs11, ys11). The output control receives the vertex coordinates of the four original images and calculates xsmin=min(xs00, xs01, xs10, xs11), xsmax=max(xs00, xs01, xs10, xs11), ysmin=min(ys00, ys01, ys10, ys11), and ysmax=max(ys00, ys01, ys10, ys11). By comparing xsmin / xsmax / ysmin / ysmax with the original image resolution, the result determines whether the current destination block is a fill block or a scan block. Finally, the coordinates of the destination block's lower-left corner are written to the fill block buffer (fill_fifo) or the scan block buffer (bs_fifo), depending on the result.
[0025] Figure 6This is the block scanning module circuit structure. This module reads the coordinates of the lower-left corner of a scan block from the main_ctrl module's scan block buffer and scans the coordinates of each pixel within the block row by row. It then uses the inverse rotation formula to calculate the corresponding coordinates of each pixel in the original image. The calculated coordinates are compared with the width and height of the original image to determine whether the current pixel is a fill pixel or an interpolated pixel. Fill pixels are sent directly to the buffer buffer (buf), while interpolated pixels are sent to the buffer fifo. Bilinear interpolation reads the decimal coordinates (xs, ys) of the pixel to be interpolated from the buffer fifo and obtains the integer part (xsi, ysi) and the fractional part (xsf, ysf) of the coordinates. Based on the coordinates (xsi, ysi), the corresponding color values of the original image for the four coordinate points (xsi, ysi), (xsi+1, ysi), (xsi, ysi+1), and (xsi+1, ysi+1) are read from the cache. It then calculates 1-xsf and 1-ysf. Finally, based on 1-xsf and 1-ysf and the four corresponding source pixel color values, it calculates the color value of the current interpolated pixel using the bilinear interpolation formula and outputs it to the buffer buf. The cache receives the coordinates of the original image pixels sent by bilinear interpolation and outputs the corresponding pixel color value. The cache uses a LRU algorithm, reading data in bursts equal to one cache line per read via the AXI bus. Using eight cache lines, each line can store a 16x16 pixel block. The buffer buf receives the coordinates of the fill pixel and writes the fill pixel color to internal storage based on the coordinates. It also receives the coordinates and color of the interpolated pixel calculated by bilinear interpolation and writes the interpolated pixel color to internal storage based on the coordinates. Once all pixels in a pixel block have been received, a request is sent to the axi_out module, waiting for the axi_out module to read the value. The buffer buf uses a ping-pong buffer structure, with one buffer used for receiving and the other for sending.
[0026] Figure 7The axi_out module circuit structure first arbitrates between fill block and scan block requests, prioritizing scan block requests. Once arbitration is complete, the next arbitration must complete the output of a pixel block. If the arbitration results in a fill block, the lower-left corner coordinates of a block and the user-configured base address of the destination image are read from the main_ctrl module's fill block buffer. The starting address of each row in the block is calculated, and the AXI_WR circuit is enabled, generating an AXI write burst and advance transfer operation. If the arbitration results in a scan block, the scan block processing circuit calculates the starting address of each row in the block based on the lower-left corner coordinates of the current scan block sent by the block scan circuit and the user-configured base address of the destination image. Simultaneously, the block reads row by row from the block scan circuit's buffer, generating an AXI burst transfer for each row and enabling the AXI_WR circuit for the transfer. The AXI_WR circuit generates the AXI bus write burst and advance transfer operation.
[0027] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0028] In addition, the functional units in the various embodiments of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units. The above is only an implementation method of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the description and drawings of this application, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
[0029] The above detailed description of the specific embodiments of the invention is intended only as an example, and the present application is not limited to the specific embodiments described above. For those skilled in the art, any equivalent modifications or substitutions of the invention are also within the scope of the present application. Therefore, equivalent changes, modifications, and improvements made without departing from the spirit and scope of the present application should be included within the scope of the present application.
Claims
1. A method for rotating an image at any angle based on Z-shaped segmentation and efficient caching, characterized in that: include: The target image to be rotated is divided into blocks, and then the coordinates of the image to be rotated corresponding to the target image are calculated by inverse rotation according to the vertex coordinates of the blocks; Determining the relationship between the coordinates of the image to be rotated corresponding to the vertex coordinates of the target image after the block is divided and the coordinates of the image to be rotated, and determining whether the current target pixel block is a filling block or a scanning block; Write the lower left corner coordinate of the current destination pixel block into the fill block buffer fifo or the block scan buffer fifo.
2. The method for rotating an image at any angle based on Z-shaped segmentation and efficient caching according to claim 1, characterized in that: The method further includes dividing the target image to be rotated into blocks, and then calculating the coordinates of the image to be rotated corresponding to the target image by inverse rotation according to the vertex coordinates of the blocks. The target image to be rotated is segmented in a z-shape, thereby improving the pixel utilization rate of reading the image to be rotated, which is the ratio of the number of pixels of the image to be rotated to the number of pixels of the original image actually read from the external storage DDR; The target image to be rotated is segmented in a z-shape. Based on the rotation characteristics, the pixels of the original image are read in a row-by-block manner, which increases the spatial correlation of the pixel blocks of the image to be rotated, facilitates the use of a cache structure to cache the image blocks of the image to be rotated, and improves the pixel utilization rate of reading the image to be rotated.
3. The method for image arbitrary angle rotation based on Z-shaped segmentation and efficient caching according to claim 1, characterized in that: The determining of the relationship between the coordinates of the image to be rotated corresponding to the vertex coordinates of the target image after the block division and the coordinates of the image to be rotated, and determining whether the current target pixel block is a filling block or a scanning block, further includes: Reversely rotate the vertices of the image blocks of the segmented target image; Determine the type of the current block based on the inverse rotation result; If the current block is a fill block, it is sent to the fill block cache for fill block reading; If it is a scan block, it is sent to the scan block cache for scan block processing.
4. The method for rotating an image at any angle based on Z-shaped segmentation and efficient caching according to claim 3, characterized in that: If the current block is a filling block, it is sent to the filling block cache for filling block processing, further comprising: The AXI bus output module reads the padding block from the padding block cache, and calculates the first address of each row of pixels in the block based on the coordinates of the lower left corner of the padding block and the base address of the destination image. The burst mode of the AXI bus is used, and the burst length is the size of one row of pixels in the block. The advance transmission of the AXI bus is the column size of the block, and the data written by the AXI bus is the padding pixel value, which is configured by the user; Write the pixels of the current fill block to DDR via the AXI bus.
5. The method for rotating an image at any angle based on Z-shaped segmentation and efficient caching according to claim 3, characterized in that: If it is a scan block, it is sent to the scan block cache for scan block processing, further comprising: Performing pixel-by-pixel rotation processing on the scanning block; Calculate the coordinates of the internal pixels of the image block of the segmented target image, and calculate the corresponding position of the pixel in the image to be rotated through inverse rotation operation; Read the color values of the four nearest pixels surrounding the position according to the coordinate value of the position and perform bilinear interpolation; After the interpolation is completed, it is cached until all pixels in the scan block are processed; Send a request to the AXI bus output module. The AXI bus uses burst mode and advance transmission mode to write the pixels of the scanned block to DDR.
6. A device for rotating an image at any angle based on Z-shaped segmentation and efficient caching, for executing a method for rotating an image at any angle based on Z-shaped segmentation and efficient caching as claimed in any one of claims 1 to 5, characterized in that: include: apb_cfg module, main_ctrl module, block_scan module and axi_out module; The apb_cfg module parses the apb bus, obtains the user's configuration value, completes interrupt processing, and completes the control of the working mode; The main_ctrl module completes the block calculation of the target image, the determination of the block type of the target image, and the caching of the coordinates of the lower left corner of the filling block and the scanning block; The block_scan module completes the scanning of the internal pixels of the scanning block, then performs inverse rotation processing on the coordinates of each scanned pixel, reads the pixels of the original image through the cache, calculates the color value of the target pixel according to bilinear interpolation, and performs ping-pong caching on the scan results; The axi_out module completes the pixel output work of the filling block and the scanning block.