Method of realizing image rotation using cache memory

By using mechanisms such as chunking and Cache adjustment in image rotation, the preloading and use of original image data in Cache memory is optimized, and the trade-offs between bus bandwidth consumption, data processing efficiency and cache space during image rotation in the prior art are solved, and efficient image rotation processing is achieved.

CN113920016BActive Publication Date: 2025-04-25HANGZHOU NATCHIP SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111151087.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-29
Publication Date
2025-04-25
Estimated Expiration
2041-09-29

AI Technical Summary

Technical Problem

The prior art is difficult to balance the bus bandwidth consumption, data processing efficiency and cache space when image rotation, especially when large-resolution image rotation display, it is difficult to meet the bandwidth requirements of the system.

Method used

The blocking mechanism, Cache adjustment mechanism, point-to-point mapping mechanism, starting point search mechanism, data pre-reading mechanism, Cache hit mechanism, Cache failure mechanism and data writeback mechanism are adopted. Through the image processing method of blocking by column and reading by column block row, the pre-loading and use of the original image data in Cache memory is optimized.

Benefits of technology

It realizes the effective utilization of cache space while ensuring bus bandwidth efficiency and data processing efficiency, supports flexible matching of cache width and depth, and adapts to the limitations of different hardware resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113920016B_ABST
    Figure CN113920016B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for realizing image rotation by using a Cache memory. The method of the present invention first divides the maximum area to which the target image area belongs into blocks by columns along the x-axis of a plane rectangular coordinate system through a block mechanism; then determines the width and depth of the Cache according to the Cache adjustment mechanism, and determines the mapping relationship between the points of the target image and the points of the original image according to the point-to-point mapping mechanism; determines the starting point for preloading the original image data of each column block according to the starting point search mechanism; loads the original image data into the Cache according to the data pre-reading mechanism; determines whether the target image data to be output is in the Cache according to the Cache hit mechanism: if not, invalidate the useless data using the Cache invalidation mechanism; if so, output the pixel value of the final target point using the data write-back mechanism. The method of the present invention can efficiently process the original image data in the Cache memory, which not only reduces the limitation of hardware resources, but also effectively reduces the wasted bandwidth.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of integrated circuits, and in particular relates to a method for realizing image rotation by utilizing a Cache memory. Background Art

[0002] Cache memory is a high-speed cache memory in computers. It is located between the CPU and the main memory DRAM (Dynamic Random Access Memory). Cache memory is a small-scale but high-speed memory, usually composed of SRAM (Static Random Access Memory). It is a small-capacity but high-speed memory located between the CPU and the memory. The speed of the CPU is much higher than that of the memory. When the CPU directly accesses data from the memory, it has to wait for a certain period of time. The cache can save part of the data that the CPU has just used or recycled. If the CPU needs to use this part of the data again, it can be called directly from the cache. This avoids repeated access to data, reduces the CPU's waiting time, and thus improves the efficiency of the system. Cache memory is generally integrated on the CPU.

[0003] Image rotation is a commonly used digital image processing technology that has been widely used in various fields. In the hardware design of image rotation, many systems often write image data into the cache memory by line first, and then index it according to the specific implementation method of the target image. Although this traditional rotation method is relatively easy to implement, it is difficult to strike a balance between bus bandwidth consumption, data processing efficiency and cache space.

[0004] If pre-reading or calculation is performed point by point, there is no redundant reading of data, and bus bandwidth will not be wasted, but the processing efficiency will be very low. If a row of data is pre-read to improve efficiency, the original data row will be tilted due to rotation, and only a few points of the cached row of data will actually be used, which will waste bus bandwidth. At the same time, it requires huge hardware resources. For example, for a 1920×1080 image, the target Figure 1 The row data is a column of data in the original image. If the pre-read method is used, the entire image needs to be cached, which is equivalent to 1920×1080 bytes, or about 2 megabytes of cache. Moreover, when a large-resolution image is rotated and displayed, this storage method is difficult to meet the bandwidth requirements of the system. Summary of the invention

[0005] The purpose of the present invention is to address the deficiencies of the prior art and to propose a method for realizing image rotation using a cache memory, which takes into account bus bandwidth consumption, data processing efficiency and cache space size while supporting flexible configuration of cache width and depth.

[0006] The method of the invention comprises a block division mechanism, a cache adjustment mechanism, a point-to-point mapping mechanism, a starting point search mechanism, a data pre-reading mechanism, a cache hit mechanism, a cache invalidation mechanism and a data write-back mechanism.

[0007] Step (1) determining a plane rectangular coordinate system through a block mechanism, dividing the maximum area to which the target image area belongs into blocks by columns along the x-axis direction of the plane rectangular coordinate system;

[0008] Step (2) determining the width and depth of the image data stored in the cache memory according to the cache adjustment mechanism, and determining the point-to-point mapping relationship between the points of the target image and the points of the original image according to the point-to-point mapping mechanism;

[0009] Step (3) determining the starting point for preloading the original image data for each column block according to the starting point search mechanism;

[0010] Step (4) loading the original image data into the cache memory according to the data pre-reading mechanism;

[0011] Step (5) determines whether the target image data to be output is in the cache memory according to the cache hit mechanism: if not, return to step (4) and use the cache invalidation mechanism to invalidate useless data; if so, use the data write-back mechanism to output the pixel value of the final target point.

[0012] The specific contents of the mechanism are described in detail below.

[0013] The block mechanism is as follows: First, establish a plane rectangular coordinate system for the target image area. The target image area is the area formed by rotating the upper left vertex of the original image by θ. The coordinates of the four vertices of the target image area in the plane rectangular coordinate system are respectively the upper vertex k up (0,0), the lower vertex k down (w·cosθ-h·sinθ,w·sinθ+h·cosθ), left vertex k left (-h·sinθ,h·cosθ), right vertex k right (w·cosθ,w·sinθ); the largest area to which the target image area belongs is the full-size image area. The full-size image area is a rectangular area. The coordinates of the four vertices in the plane rectangular coordinate system are (-h·sinθ,0), (-h·sinθ,h·cosθ+w·sinθ), (w·cosθ,h·cosθ+w·sinθ), (w·cosθ,0), w is the width of the original image, and h is the height of the original image; then the full-size image area is divided into columns along the x-axis direction of the plane rectangular coordinate system with the number of bytes len∈{32,64,128,256}, and the width of the last block in pixels is less than or equal to that of other blocks.

[0014] Cache adjustment mechanism, specifically: set cache memory resources to store image data S≤D max , D Max is the maximum resource limit of the Cache memory resources; when the maximum resource limit is met, the image data stored in the Cache memory is S = wc·hc, the width of S is wc = α·wc′, the depth is hc = β·hc′, and the minimum width of the Cache memory required to store data The minimum depth hc′=len·sinθ, α and β are expansion coefficients, 1.1≤α≤1.5, 1.1≤β≤1.5.

[0015] Point-to-point mapping mechanism, specifically: there is a point-to-point mapping relationship Q=T between the point P (Px, Py) of the target graph and the point Q (Qx, Qy) of the original graph -1 P, where the points of the target graph are represented as a matrix The points of the original image are represented as a matrix Transformation Matrix

[0016] The starting point search mechanism is as follows: first, after column-based blocks, a row of each column block is represented as row AB, where the starting point is A (Ax, Ay) and the end point is B (Bx, By); then, in each block, the target image area is searched row by row starting from the first row. When the scanned row AB intersects with the target image area for the first time, the intersection point is used as the pre-read data starting point H; the full-size image area before point H does not preload data, and all pixels in non-intersecting rows are replaced with background colors; there are four cases for the starting point H:

[0017] Case a. Line AB directly intersects the target graph area at the end point B. At this time, the starting point H of the pre-read data is point B;

[0018] Case b. Line AB directly intersects the target graph area at the starting point A. At this time, the starting point H of the pre-read data is point A;

[0019] Case c. The starting point A and the end point B of row AB do not intersect with the original graph, but the middle part intersects with the target graph area. In this case, the starting point H of the pre-read data is the upper vertex k of the target graph area. up ;

[0020] Case d. The starting point A and the end point B of line AB both intersect with the target image area, that is, rotated n×180°, n is an integer, and the starting point H of the pre-read data is point A.

[0021] The data pre-reading mechanism is as follows: first, row AB is reversed in the original image, represented as row A′B′, with the starting point A′(A′x, A′y) and the end point B′(B′x, B′y). The coordinate point H is reversed in the original image as H′(H′x, H′y); a row of original image data currently loaded in the cache memory is represented as row MN, which is horizontal with a width of wc, a starting point of M(Mx, My), an end point of N(Nx, Ny), and satisfies Nx-Mx =wc, Ny=My; Since the target image area is tilted after rotation, the horizontal column block row AB is also tilted in the original image row A′B′, so the complete output row AB needs to pre-read multiple original image data rows MN; Then set the number of loaded original image rows to cnt, and each time a row of data MN is loaded into the cache memory, the number of loaded rows cnt=cnt+1, then My=H′y+cnt; At the same time, each time a row of data is loaded, record the horizontal coordinate Mx of the starting point of the current row;

[0022] If My≥max(A′y,B′y), it means that all the original image data rows corresponding to row A′B′ in the original image of the current column block row AB have been pre-read into the cache memory, so preload the row number + 1 of the next column block row AB; if My<max(A′y,B′y), it means that the original image data rows required by the column block row AB have not been fully loaded, so pre-read a data row MN, at this time Mx=A′x; until the cache memory is fully loaded, suspend preloading and wait for the cache invalidation mechanism to discard useless data in the cache memory; max(A′y,B′y) is the maximum value of the vertical coordinate of row A′B′.

[0023] The cache hit mechanism is as follows: first, the data range in the cache memory is updated in real time, and the four vertices of the loaded data range are a(ax,ay), b(ax+wc,ay), c(cx,cy), d(cx+wc,cy); when loading the first row of data, ax=cx=H′x, ay=cy=H′y; each subsequent row of data is loaded, cy=cy+1; each invalid row of data, ay=ay-1; then, search each column block row by row again, and a row of each column block is represented as row CD, which is represented as original image row C′D′ after inverse mapping, with the starting point being C′(C′x,C′y) and the end point being D′(D′x,D′y). If C′ and D′ are within the range of the data already loaded in the cache, then it is considered to be hit by the cache, and the pixel value of each point in this row in the cache is indexed; if it is not within the range of the data already loaded in the cache, then it is considered not to be hit by the cache, and wait for more data to be loaded in the cache memory.

[0024] The cache invalidation mechanism is as follows: First, set the minimum value of the original image data row number that has been loaded in the cache memory to Y min , Y min =ay; if min(C′y,D′y)≤Y min , then it means that the data in the cache still needs to be used later, waiting for the data write-back mechanism and cache hit mechanism to be performed; if min(C′y,D′y)>Y min , then it means that the minimum original image data row number required by the cache hit mechanism to traverse the column block row C′D′ is greater than Y min , these rows of data will no longer be used, and the number of rows that can be invalidated is line = min (C'y, D'y) - Y min ; Then, the four vertices in the data range that have been loaded in the cache memory after the failure are updated to a(ax,ay), b(ax+wc,ay), c(cx,cy-line), and d(cx+wc,cy-line).

[0025] The data write-back mechanism is as follows: First, for each column block, traverse each point in the full-size image from top to bottom and from left to right. If the point is outside the target image area, its pixel value is replaced by the background color; if the point is within the target image area, take out the pixel value at the location in the cache memory; the target image point P (Px, Py) is an integer point, and the original image point Q (Qx, Qy) after inverse mapping is converted into a floating point due to trigonometric functions;

[0026] Then, according to the original image point Q (Qx, Qy), get the surrounding integer horizontal coordinates and and integer ordinates and The coordinates of the four integer points around are Q1(x left ,y up ), Q2(x right ,y up ), Q3(x left ,y up ), Q4(x right ,y down ),in Indicates rounding down. Indicates rounding up;

[0027] Index the four pixel values ​​in the Cache memory and calculate the relative position R1(x left -Mx,y up -H′y), R2(x right -Mx,y up -H′y), R3(x left-Mx,y down -H′y), R4(x right -Mx,y down -H′y), and then obtain the pixel values ​​pix1, pix2, pix3, and pix4 of the four points in the cache memory;

[0028] According to bilinear interpolation, the pixel value of the final target point is output:

[0029]

[0030] The method of the present invention proposes a hardware cache mechanism for image rotation, and an image processing method combining column-by-column block division with column-by-column block row reading, so that the preloading of original image data is more regular, which can not only reduce the waste of bus bandwidth as much as possible, but also effectively improve the operation efficiency. The present invention provides an image rotation scheme under a fixed cache, which can effectively cope with the limitation of hardware resources, and can be realized by flexible configuration of cache width and depth even in modules with smaller hardware resource allocation. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is a framework diagram of the method of the present invention;

[0032] Figure 2 It is a schematic diagram of the block division mechanism of the present invention;

[0033] Figure 3 It is a schematic diagram of the Cache adjustment mechanism of the present invention;

[0034] Figure 4 Schematic diagrams of four situations of the starting point search mechanism of the present invention. DETAILED DESCRIPTION

[0035] The present invention is further described below in conjunction with the accompanying drawings, with the goal of achieving the goal of minimizing hardware resource overhead, minimizing processing power, minimizing bandwidth waste, or minimizing data cache utilization. The method for implementing image rotation using cache memory is as follows:

[0036] like Figure 1 As shown, the method for realizing image rotation by using cache memory includes a block mechanism, a cache adjustment mechanism, a point-to-point mapping mechanism, a starting point search mechanism, a data pre-reading mechanism, a cache hit mechanism, a cache invalidation mechanism and a data write-back mechanism.

[0037] Step (1) determining a plane rectangular coordinate system through a block mechanism, dividing the maximum area to which the target image area belongs into blocks by columns along the x-axis direction of the plane rectangular coordinate system;

[0038] Step (2) determining the width and depth of the image data stored in the cache memory according to the cache adjustment mechanism, and determining the point-to-point mapping relationship between the points of the target image and the points of the original image according to the point-to-point mapping mechanism;

[0039] Step (3) determining the starting point for preloading the original image data for each column block according to the starting point search mechanism;

[0040] Step (4) loading the original image data into the cache memory according to the data pre-reading mechanism;

[0041] Step (5) determines whether the target image data to be output is in the cache memory according to the cache hit mechanism: if not, return to step (4) and use the cache invalidation mechanism to invalidate useless data; if so, use the data write-back mechanism to output the pixel value of the final target point.

[0042] The specific contents of the mechanism are described in detail below.

[0043] like Figure 2 As shown in the figure, the specific block mechanism is as follows: first, establish a plane rectangular coordinate system for the target image area. The target image area 100 is an area formed by rotating the upper left vertex of the original image by θ. The coordinates of the four vertices of the target image area 100 in the plane rectangular coordinate system are respectively the upper vertex k up (0,0), the lower vertex k down (w·cosθ-h·sinθ,w·sinθ+h·cosθ), left vertex k left (-h·sinθ,h·cosθ), right vertex k right (w·cosθ,w·sinθ); the largest area to which the target image area belongs is the full-size image area 101, the full-size image area 101 is a rectangular area, and the coordinates of the four vertices in the plane rectangular coordinate system are (-h·sinθ,0), (-h·sinθ,h·cosθ+w·sinθ), (w·cosθ,h·cosθ+w·sinθ), (w·cosθ,0), w is the width of the original image, and h is the height of the original image; then the full-size image area 101 is divided into columns along the x-axis direction of the plane rectangular coordinate system with the number of bytes len∈{32,64,128,256} to obtain multiple column blocks 102, and the width of the last column block in pixels is less than or equal to that of other column blocks.

[0044] like Figure 3 As shown, the cache adjustment mechanism is specifically: set the cache memory resources to store image data S≤D max , D Maxis the maximum resource limit of the Cache memory resources; when the maximum resource limit is met, the image data stored in the Cache memory is S = wc·hc, the width of S is wc = α·wc′, the depth is hc = β·hc′, and the minimum width of the Cache memory required to store data The minimum depth hc′=len·sinθ, α and β are expansion coefficients, 1.1≤α≤1.5, 1.1≤β≤1.5.

[0045] Point-to-point mapping mechanism, specifically: there is a point-to-point mapping relationship Q=T between the point P (Px, Py) of the target graph and the point Q (Qx, Qy) of the original graph -1 P, where the points of the target graph are represented as a matrix The points of the original image are represented as a matrix Transformation Matrix

[0046] The starting point search mechanism is as follows: first, after dividing into blocks by columns, a row of each column block is represented as row AB, where the starting point is A (Ax, Ay) and the end point is B (Bx, By); then, in each block, the target image area is searched row by row starting from the first row. When the scanned row AB intersects with the target image area for the first time, the intersection point is used as the pre-read data starting point H; the full-size image area before point H does not pre-load data, and all pixels in non-intersecting rows are replaced with background colors. Figure 4 As shown, there are four situations for the starting point H:

[0047] Case a. Line AB directly intersects the target graph area at the end point B. At this time, the starting point H of the pre-read data is point B;

[0048] Case b. Line AB directly intersects the target graph area at the starting point A. At this time, the starting point H of the pre-read data is point A;

[0049] Case c. The starting point A and the end point B of row AB do not intersect with the original graph, but the middle part intersects with the target graph area. In this case, the starting point H of the pre-read data is the upper vertex k of the target graph area. up ;

[0050] Case d. The starting point A and the end point B of line AB both intersect with the target image area, that is, rotated n×180°, n is an integer, and the starting point H of the pre-read data is point A.

[0051] The data pre-reading mechanism is as follows: first, row AB is reversed in the original image, represented as row A′B′, with the starting point A′(A′x, A′y) and the end point B′(B′x, B′y). The coordinate point H is reversed in the original image as H′(H′x, H′y); a row of original image data currently loaded in the cache memory is represented as row MN, which is horizontal with a width of wc, a starting point of M(Mx, My), an end point of N(Nx, Ny), and satisfies Nx-Mx =wc, Ny=My; Since the target image area is tilted after rotation, the horizontal column block row AB is also tilted in the original image row A′B′, so the complete output row AB needs to pre-read multiple original image data rows MN; Then set the number of loaded original image rows to cnt, and each time a row of data MN is loaded into the cache memory, the number of loaded rows cnt=cnt+1, then My=H′y+cnt; At the same time, each time a row of data is loaded, record the horizontal coordinate Mx of the starting point of the current row;

[0052] If My≥max(A′y,B′y), it means that all the original image data rows corresponding to row A′B′ in the original image of the current column block row AB have been pre-read into the cache memory, so preload the row number + 1 of the next column block row AB; if My<max(A′y,B′y), it means that the original image data rows required by the column block row AB have not been fully loaded, so pre-read a data row MN, at this time Mx=A′x; until the cache memory is fully loaded, suspend preloading and wait for the cache invalidation mechanism to discard useless data in the cache memory; max(A′y,B′y) is the maximum value of the vertical coordinate of row A′B′.

[0053] The cache hit mechanism is as follows: first, the data range in the cache memory is updated in real time, and the four vertices of the data range that have been loaded are a(ax,ay), b(ax+wc,ay), c(cx,cy), and d(cx+wc,cy); when loading the first row of data, ax=cx=H′x, ay=cy=H′y; each subsequent row of data loaded, cy=cy+1; each invalid row of data, ay=ay-1; then, search each column block row by row again, and a row of each column block is represented as row CD, which is represented as original image row C′D′ after inverse mapping, with the starting point being C′(C′x,C′y) and the end point being D′(D′x,D′y). It is independent of row AB of the pre-read mechanism, and is used here to predict whether the original image data corresponding to the current column block row has been pre-read into the cache memory. If C′ and D′ are within the range of data already loaded in the cache, then it is considered a cache hit, and the pixel value of each point in this row in the cache is indexed; if they are not within the range of data already loaded in the cache, then it is considered a cache miss, and wait for more data to be loaded from the cache memory.

[0054] Cache invalidation mechanism, specifically: in order to reduce hardware overhead as much as possible, the cache memory will not be very large, and the amount of data that can be stored is much smaller than the amount of original image data that needs to be stored. Therefore, when the cache memory is full, it is necessary to invalidate the useless data in the cache memory in time and fill in new data. First, set the minimum value of the original image data row number that has been loaded in the cache memory to Y min , Y min =ay; if min(C′y,D′y)≤Y min , then it means that the data in the cache still needs to be used later, waiting for the data write-back mechanism and cache hit mechanism to be performed; if min(C′y,D′y)>Y min , then it means that the minimum original image data row number required by the cache hit mechanism to traverse the column block row C′D′ is greater than Y min , these rows of data will no longer be used, and the number of rows that can be invalidated is line = min (C'y, D'y) - Y min ; Then, the four vertices in the data range that have been loaded in the cache memory after the failure are updated to a(ax,ay), b(ax+wc,ay), c(cx,cy-line), and d(cx+wc,cy-line).

[0055] The data write-back mechanism is as follows: First, for each column block, traverse each point in the full-size image from top to bottom and from left to right. If the point is outside the target image area, its pixel value is replaced by the background color; if the point is within the target image area, take out the pixel value at the location in the cache memory; the target image point P (Px, Py) is an integer point, and the original image point Q (Qx, Qy) after inverse mapping is converted into a floating point due to trigonometric functions;

[0056] Then, according to the original image point Q (Qx, Qy), get the surrounding integer horizontal coordinates and and integer ordinates and The coordinates of the four integer points around are Q1(x left ,y up ), Q2(x right ,y up ), Q3(x left ,y up ), Q4(x right ,y down ),in Indicates rounding down. Indicates rounding up;

[0057] Index the four pixel values ​​in the Cache memory and calculate the relative position R1(x left -Mx,y up -H′y), R2(x right -Mx,y up -H′y), R3(x left -Mx,y down -H′y), R4(x right -Mx,y down -H′y), and then obtain the pixel values ​​pix1, pix2, pix3, and pix4 of the four points in the cache memory;

[0058] According to bilinear interpolation, the pixel value of the final target point is output:

[0059]

[0060] To verify the beneficial effects of the present invention, the data redundancy is calculated Re represents the data pre-reading redundancy, read_sum represents the total amount of original image data read into the cache, and image_sum represents the total amount of data in the original image. The data volume test selects an image with a format of YUV420 and a size of 1280x720. Taking the Y channel as an example, image_sum is 921600 bytes. The column block width is set to 256 bytes, and the rotation angle is [5,85] with a step size of 15°. The test example is shown in Table 1:

[0061]

[0062]

[0063] Table 1

[0064] As can be seen from the table, the cache mechanism of the present invention performs data preloading. Under multiple angles tested, the cache consumes very little resources when the angle is small, and when the angle is large, the resources can be effectively reduced by reducing the column block width. The results of data redundancy also show that the amount of wasted data is small, especially in the case of small angles.

[0065] Therefore, the image rotation hardware cache mechanism proposed in the present invention combines the image processing method of column-by-column block division with column-by-column block row reading, which makes the preloading of original image data more regular, can effectively improve efficiency, and reduce wasted bandwidth. At the same time, an image rotation scheme under a fixed cache is provided, which can effectively cope with the limitation of hardware resources, especially in modules with smaller hardware resource allocation. In addition, in actual hardware implementation, the minimum depth and width will not be used as the actual cache size. In the case of satisfying the minimum cache calculation formula and the maximum resource limitation, increasing the width and depth can not only ensure the hit rate of data, but also improve hardware efficiency.

Claims

1. A method for realizing image rotation using a cache memory, characterized in that: The method includes a block mechanism, a cache adjustment mechanism, a point-to-point mapping mechanism, a starting point search mechanism, a data pre-reading mechanism, a cache hit mechanism, a cache invalidation mechanism and a data write-back mechanism; the method is as follows: Step (1) determining a plane rectangular coordinate system through a block mechanism, dividing the maximum area to which the target image area belongs into blocks by columns along the x-axis direction of the plane rectangular coordinate system; Step (2) determining the width and depth of the image data stored in the cache memory according to the cache adjustment mechanism, and determining the point-to-point mapping relationship between the points of the target image and the points of the original image according to the point-to-point mapping mechanism; Step (3) determining the starting point for preloading the original image data for each column block according to the starting point search mechanism; Step (4) loading the original image data into the cache memory according to the data pre-reading mechanism; Step (5) determines whether the target image data to be output is in the cache memory according to the cache hit mechanism: if not, return to step (4) and invalidate the useless data using the cache invalidation mechanism; if it is, output the pixel value of the final target point using the data write-back mechanism; The block division mechanism is specifically as follows: first, a plane rectangular coordinate system of the target image region is established. The target image region is a region formed by rotating the upper left vertex of the original image by θ. The coordinates of the four vertices of the target image region in the plane rectangular coordinate system are respectively the upper vertex k up (0,0), the lower vertex k down (w·cosθ-h·sinθ,w·sinθ+h·cosθ), left vertex k left (-h·sinθ,h·cosθ), right vertex k right (w·cosθ,w·sinθ); the largest area to which the target image area belongs is the full-size image area, which is a rectangular area. The coordinates of the four vertices in the plane rectangular coordinate system are (-h·sinθ,0), (-h·sinθ,h·cosθ+w·sinθ), (w·cosθ,h·cosθ+w·sinθ), (w·cosθ,0), w is the width of the original image, and h is the height of the original image; then the full-size image area is divided into columns along the x-axis direction of the plane rectangular coordinate system with the number of bytes len∈{32,64,128,256}, and the width of the last block in pixels is less than or equal to that of other blocks; The cache adjustment mechanism is specifically: setting the cache memory resources to store image data S≤D max , D max is the maximum resource limit of the Cache memory resources; when the maximum resource limit is met, the image data stored in the Cache memory is S = wc·hc, the width of S is wc = α·wc′, the depth is hc = β·hc′, and the minimum width of the Cache memory required to store data Minimum depth hc′=len·sinθ, α and β are expansion coefficients, 1.1≤α≤1.5, 1.1≤β≤1.5; The point-to-point mapping mechanism is specifically: there is a point-to-point mapping relationship Q=T between a point P (Px, Py) of the target graph and a point Q (Qx, Qy) of the original graph. -1 P, where the points of the target graph are represented as a matrix The points of the original image are represented as a matrix Transformation Matrix The starting point search mechanism is specifically as follows: first, after being divided into blocks by columns, a row of each column block is represented as row AB, where the starting point is A (Ax, Ay) and the end point is B (Bx, By); then, in each block, the target image area is searched row by row starting from the first row, and when the scanned row AB intersects with the target image area for the first time, the intersection point is used as the pre-read data starting point H; the full-size image area before point H does not pre-load data, and all pixels in non-intersecting rows are replaced with background colors; The data pre-reading mechanism is specifically as follows: first, row AB is reversely mapped in the original image, represented as row A′B′, with a starting point of A′(A′x, A′y) and an end point of B′(B′x, B′y), and the coordinate point of point H reversely mapped in the original image is H′(H′x, H′y); a row of original image data currently loaded in the cache memory is represented as row MN, which is horizontal, has a width of wc, a starting point of M(Mx, My), an end point of N(Nx, Ny), and satisfies Nx- Mx=wc,Ny=My;Since the target image area is tilted after rotation, the horizontal column block row AB is also tilted in the original image row A′B′, so the complete output row AB needs to pre-read multiple original image data rows MN; then set the number of loaded original image rows to cnt, and each time a row of data MN is loaded into the cache memory, the number of loaded rows cnt=cnt+1, then My=H′y+cnt; at the same time, each time a row of data is loaded, record the horizontal coordinate Mx of the starting point of the current row; If My≥max(A′y,B′y), it means that all the original image data rows corresponding to row A′B′ in the original image of the current column block row AB have been pre-read into the cache memory, so the row number of the next column block row AB+1 is pre-loaded; if My<max(A′y,B′y), it means that the original image data rows required by the column block row AB have not been fully loaded, so a data row MN is pre-read, and Mx=A′x at this time; until the cache memory is fully loaded, the pre-loading is suspended, and the cache invalidation mechanism is waited for to discard the useless data in the cache memory; max(A′y,B′y) is the maximum value of the vertical coordinate of row A′B′; The cache hit mechanism is specifically as follows: first, the data range in the cache memory is updated in real time, and the four vertices of the loaded data range are a(ax,ay), b(ax+wc,ay), c(cx,cy), and d(cx+wc,cy); when loading the first row of data, ax=cx=H′x, ay=cy=H′y; each subsequent row of data is loaded, cy=cy+1; each invalid row of data, ay=ay-1; then, each column block is searched row by row again, and a row of each column block is represented as row CD, which is represented as original image row C′D′ after inverse mapping, with the starting point being C′(C′x,C′y) and the end point being D′(D′x,D′y); if C′ and D′ are within the range of the data already loaded in the cache, then it is considered to be hit by the cache, and the pixel value of each point in this row in the cache is indexed; if it is not within the range of the data already loaded in the cache, then it is considered to be not hit by the cache, and more data is waiting to be loaded from the cache memory; The cache invalidation mechanism is as follows: first, set the minimum value of the row number of the original image data loaded in the cache memory to Y min , Y min =ay; if min(C′y,D′y)≤Y min , then it means that the data in the cache still needs to be used later, waiting for the data write-back mechanism and cache hit mechanism to be performed; if min(C′y,D′y)>Y min , then it means that the minimum original image data row number required by the cache hit mechanism to traverse the column block row C′D′ is greater than Y min , these rows of data will no longer be used, and the number of rows that can be invalidated is line = min (C'y, D'y) - Y min ; Then, the four vertices in the data range that have been loaded in the cache memory after the failure are updated to a(ax,ay), b(ax+wc,ay), c(cx,cy-line), d(cx+wc,cy-line); The data write-back mechanism is specifically as follows: first, for each column block, each point in the full-size image is traversed from top to bottom and from left to right. If the point is outside the target image area, its pixel value is replaced by the background color; if the point is within the target image area, the pixel value at the location in the cache memory is retrieved; The target graph point P (Px, Py) is an integer point, and the original graph point Q (Qx, Qy) after inverse mapping is converted into a floating point due to trigonometric functions; Then, according to the original image point Q (Qx, Qy), get the surrounding integer horizontal coordinates and and integer ordinates and The coordinates of the four integer points around are Q1(x left ,y up ), Q2(x right ,y up ), Q3(x left ,y up ), Q4(x right ,y down ),in Indicates rounding down. Indicates rounding up; Index the four pixel values ​​in the Cache memory and calculate the relative position R1(x left -Mx,y up -H′y), R2(x right -Mx,y up -H′y), R3(x left -Mx,y down -H′y), R4(x right -Mx,y down -H′y), and then obtain the pixel values ​​pix1, pix2, pix3, and pix4 of the four points in the cache memory; According to bilinear interpolation, the pixel value of the final target point is output:

2. The method for realizing image rotation using Cache memory as claimed in claim 1, characterized in that: There are four situations for the starting point H: Case a. Line AB directly intersects the target graph area at the end point B. At this time, the starting point H of the pre-read data is point B; Case b. Line AB directly intersects the target graph area at the starting point A. At this time, the starting point H of the pre-read data is point A; Case c. The starting point A and the end point B of row AB do not intersect with the original graph, but the middle part intersects with the target graph area. In this case, the starting point H of the pre-read data is the upper vertex k of the target graph area. up ; Case d. The starting point A and the end point B of line AB both intersect with the target image area, that is, rotated n×180°, n is an integer, and the starting point H of the pre-read data is point A.

Citation Information

Patent Citations

  • Hardware realization for Cache applied to image processing

    CN102136130A

  • Video rotation method

    CN103679630A