Image rotation method and device, chip, electronic equipment and storage medium
By querying the preset pixel position mapping relationship table, the target pixel position data is determined and the rotated image is generated, which solves the problems of large amount of calculation and poor real-time performance of traditional image rotation algorithms, and achieves efficient and real-time image rotation.
Patent Information
- Application Number
- CN202411080534.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-07
- Publication Date
- 2024-12-10
AI Technical Summary
Traditional image rotation algorithms such as affine transformation and Fourier transformation have large calculations and poor real-time performance, which limits their use in practical applications.
By obtaining the target rotation angle of the image to be rotated, querying the preset pixel position mapping relationship table, determining the target pixel position data, generating the rotated image, avoiding repeated calculations, and improving processing efficiency and real-timeness.
Fast image rotation is achieved, processing efficiency and real-time performance is improved, and repeated calculation problems in traditional methods are avoided.
Smart Images

Figure CN119107237A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image rotation method, device, chip, electronic equipment and storage medium. Background Art
[0002] With the rapid development of image processing technology, image rotation, as a basic operation in image transformation, is widely used in computer vision, image analysis, image enhancement and other fields. Image rotation refers to the process of rotating an image by a certain angle with a certain point as the center to form a new image. The color mode of the pixels of the image before and after the rotation remains unchanged, and only the position of each pixel is changed.
[0003] Although traditional image rotation algorithms such as affine transform and Fourier transform can realize the image rotation function well, they have certain limitations in practical applications due to their large amount of calculation and poor real-time performance. Summary of the invention
[0004] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention aims to provide an image rotation method, device, chip, electronic device and storage medium.
[0005] The present invention proposes an image rotation method, the control method comprising the following steps: obtaining a target rotation angle of an image to be rotated; obtaining target pixel position data corresponding to the target rotation angle based on a preset pixel position mapping relationship table, wherein the pixel position mapping relationship table includes corresponding mapping relationships between different rotation angles and pixel position data; and generating a rotated image corresponding to the image to be rotated based on the target pixel position.
[0006] According to the image rotation method of the embodiment of the present invention, the target rotation angle of the image to be rotated is first obtained as the basis for image rotation; then, according to the target rotation angle of the image to be rotated obtained above, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle; finally, a rotated image corresponding to the image to be rotated is generated according to the target pixel position to complete the image rotation; based on this method, image rotation can be performed quickly by only querying the pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, thereby avoiding the problem of repeated calculation when using affine transformation, Fourier transformation, etc. for image rotation, thereby not only improving processing efficiency but also ensuring real-time performance.
[0007] In addition, the image rotation method according to the embodiment of the present invention may also have the following additional technical features:
[0008] Furthermore, the target pixel position data includes a pixel position corresponding to each pixel in the image to be rotated after being rotated by the target rotation angle.
[0009] Further, generating a rotated image corresponding to the image to be rotated based on the target pixel position includes: mapping the image to be rotated pixel by pixel based on the pixel position corresponding to each pixel in the image to be rotated after rotating the target rotation angle to obtain the rotated image.
[0010] Furthermore, before obtaining the target pixel position data corresponding to the target rotation angle based on the preset pixel position mapping relationship table, it also includes: constructing the pixel position mapping relationship table.
[0011] Further, the constructing of the pixel position mapping relationship includes: determining a rotation center; and obtaining, based on the rotation center and the target rotation angle, a pixel position corresponding to each pixel in the image to be rotated after being rotated by the target rotation angle.
[0012] Furthermore, the pixel position corresponding to each pixel in the image to be rotated after being rotated by the target rotation angle is calculated by the following formula:
[0013]
[0014] Where θ is the rotation angle, c x is the X-axis coordinate value of the rotation center, c y is the Y-axis coordinate value of the rotation center, i is the X-axis coordinate value before rotation, j is the Y-axis coordinate value before rotation, i ′ is the X-axis coordinate value after rotation, j ′ is the Y-axis coordinate value after rotation.
[0015] Furthermore, the rotation center is the image center of the image to be rotated.
[0016] In response to the above-mentioned problems, the present invention also proposes an image rotation device, wherein the control device includes: an acquisition module, used to acquire a target rotation angle of an image to be rotated; a first processing module, used to obtain target pixel position data corresponding to the target rotation angle based on a preset pixel position mapping relationship table, wherein the pixel position mapping relationship table includes a corresponding mapping relationship between different rotation angles and pixel position data; and a second processing module, used to generate a rotated image corresponding to the image to be rotated based on the target pixel position.
[0017] The image rotation device of the embodiment of the present invention first obtains the target rotation angle of the image to be rotated as the basis for image rotation; then, according to the target rotation angle of the image to be rotated, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle; finally, a rotated image corresponding to the image to be rotated is generated according to the target pixel position to complete the image rotation; therefore, the image rotation device 100 only needs to query the pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, so as to quickly realize image rotation, thereby avoiding the problem of repeated calculation when performing image rotation using affine transformation, Fourier transformation, etc., thereby not only improving processing efficiency but also ensuring real-time performance.
[0018] In response to the above-mentioned problems, the present invention further proposes a chip, comprising: an image rotation device as described in the above-mentioned second aspect embodiment of the present invention, or the chip comprises: a processor, a memory, and an image rotation program stored in the memory and executable on the processor, wherein the image rotation program, when executed by the processor, implements the image rotation method as described in the above-mentioned first aspect embodiment of the present invention.
[0019] The chip according to the embodiment of the present invention can execute the image rotation method of the embodiment of the present invention, firstly, the target rotation angle of the image to be rotated is obtained as the basis for image rotation; then, according to the target rotation angle of the image to be rotated obtained above, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle; finally, a rotated image corresponding to the image to be rotated is generated according to the target pixel position to complete the image rotation; therefore, when the chip executes the image rotation method of the embodiment of the present invention, it only needs to query the pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, so as to quickly realize image rotation, thereby avoiding the problem of repeated calculation when using affine transformation, Fourier transformation, etc. for image rotation, thereby not only improving processing efficiency but also ensuring real-time performance.
[0020] In view of the above-mentioned problems, the present invention further proposes an electronic device, comprising: a chip as described in the above-mentioned third aspect embodiment of the present invention.
[0021] According to the electronic device of the embodiment of the present invention, the image rotation method of the embodiment of the present invention can be executed. First, the target rotation angle of the image to be rotated is obtained as the basis for image rotation; then, according to the target rotation angle of the image to be rotated obtained above, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle; therefore, when the electronic device executes the image rotation method of the embodiment of the present invention, it only needs to query the pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, so as to quickly realize image rotation, thereby avoiding the problem of repeated calculation when using affine transformation, Fourier transformation, etc. for image rotation, thereby not only improving processing efficiency but also ensuring real-time performance.
[0022] In response to the above-mentioned problems, the present invention further proposes a computer-readable storage medium, on which an image rotation program is stored. When the image rotation program is executed by a processor, the image rotation method as described in the first aspect of the present invention is implemented.
[0023] According to the computer-readable storage medium of an embodiment of the present invention, when the image rotation program stored thereon is executed by the processor, the target rotation angle of the image to be rotated is first obtained as the basis for image rotation; then, according to the target rotation angle of the image to be rotated obtained as above, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle; finally, a rotated image corresponding to the image to be rotated is generated according to the target pixel position to complete the image rotation; therefore, when the image rotation program stored thereon is executed by the processor, the image rotation can be quickly realized only by querying the pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, thereby avoiding the problem of repeated calculation when performing image rotation using affine transformation, Fourier transformation, etc., thereby not only improving processing efficiency but also ensuring real-time performance.
[0024] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0026] Figure 1 is a flow chart of an image rotation method according to an embodiment of the present invention;
[0027] Figure 2 is a schematic diagram of the overall process of an image rotation method according to a specific embodiment of the present invention;
[0028] Figure 3 is a schematic diagram of table lookup preprocessing according to a specific embodiment of the present invention;
[0029] Figure 4 is a schematic diagram of image rotation according to a specific embodiment of the present invention;
[0030] Figure 5 is a structural block diagram of an image rotation device according to an embodiment of the present invention.
[0031] Reference numerals:
[0032] 100 - image rotation device; 101 - acquisition module; 102 - first processing module; 103 - second processing module. DETAILED DESCRIPTION
[0033] Embodiments of the present invention are described in detail below. The embodiments described with reference to the accompanying drawings are exemplary. Embodiments of the present invention are described in detail below.
[0034] Reference below Figure 1-Figure 5 An image rotation method, device, chip, electronic device and storage medium according to an embodiment of the present invention are described.
[0035] Figure 1 FIG. 1 is a flow chart of an image rotation method according to an embodiment of the present invention. Figure 1 As shown, the image rotation method according to an embodiment of the present invention specifically includes the following steps:
[0036] Step S1: Obtain the target rotation angle of the image to be rotated.
[0037] In a specific embodiment, the image to be rotated is composed of a plurality of pixels, and a pixel refers to a small square of the image. These small squares have a clear position and an assigned color value, and the color and position of the small squares determine the appearance of the image. The pixel is regarded as an indivisible unit or element in the entire image. Specifically, the target rotation angle corresponding to the image to be rotated can be a pre-calibrated value, and the range of the target rotation angle is 0-360°. The target rotation angle can be pre-input into a related controller by an operator, such as a control chip of a printer.
[0038] Specifically, this embodiment obtains the target rotation angle of the image to be rotated as a basis for image rotation, thereby facilitating subsequent rotation of the image to be rotated by the target rotation angle, thereby completing the image rotation.
[0039] Step S2: obtaining target pixel position data corresponding to the target rotation angle based on a preset pixel position mapping relationship table, wherein the pixel position mapping relationship table includes corresponding mapping relationships between different rotation angles and pixel position data.
[0040] In a specific embodiment, the pixel position mapping relationship table includes corresponding mapping relationships between different rotation angles and pixel position data. The pixel position mapping relationship table can be pre-inputted by an operator into a related controller, such as a control chip of a printer.
[0041] Specifically, based on the target rotation angle of the image to be rotated obtained as mentioned above, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle, so as to determine the pixel position of the image to be rotated after the image rotation, which helps to complete the image rotation according to the pixel position of the image to be rotated after the image rotation.
[0042] Step S3: generating a rotated image corresponding to the image to be rotated based on the target pixel position.
[0043] Specifically, based on the target pixel position data corresponding to the target rotation angle obtained above, a rotated image corresponding to the image to be rotated is generated to complete the image rotation; based on this method, image rotation can be quickly achieved by simply querying a pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, thereby avoiding the problem of repeated calculations required when using affine transformation, Fourier transformation, etc. for image rotation, thereby not only improving processing efficiency but also ensuring real-time performance.
[0044] Therefore, according to the image rotation method of the embodiment of the present invention, the target rotation angle of the image to be rotated is first obtained as the basis for image rotation; then, according to the target rotation angle of the image to be rotated obtained above, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle; finally, a rotated image corresponding to the image to be rotated is generated according to the target pixel position to complete the image rotation; based on this method, image rotation can be performed by only querying the pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, thereby quickly realizing image rotation, avoiding the problem of repeated calculation when using affine transformation, Fourier transformation, etc. for image rotation, thereby not only improving processing efficiency but also ensuring real-time performance.
[0045] In one embodiment of the present invention, the target pixel position data includes the pixel position corresponding to each pixel in the to-be-rotated image after it is rotated by the target rotation angle.
[0046] In a specific embodiment, the target pixel position data can be represented by coordinates by presetting a position coordinate system, and the target pixel position data includes the pixel position corresponding to each pixel in the image to be rotated after rotating the target rotation angle. Specifically, the position coordinate system can be pre-inputted by an operator into a related controller, such as a control chip of a printer.
[0047] Specifically, based on the target rotation angle of the image to be rotated, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle. The target pixel position data includes the pixel position corresponding to each pixel in the image to be rotated after the target rotation angle is rotated. The pixel position of the image to be rotated after the image rotation is determined, thereby facilitating the subsequent completion of the image rotation based on the pixel position of the image to be rotated after the image rotation.
[0048] In one embodiment of the present invention, a rotated image corresponding to an image to be rotated is generated based on a target pixel position, including: mapping the image to be rotated pixel by pixel based on a pixel position corresponding to each pixel in the image to be rotated after being rotated by a target rotation angle to obtain a rotated image.
[0049] Specifically, since the pixel position mapping relationship table includes the corresponding mapping relationship between different rotation angles and pixel position data, according to the obtained target rotation angle of the image to be rotated, the pre-calibrated pixel position mapping relationship table is queried to determine the pixel position corresponding to each pixel in the image to be rotated after being rotated by the target rotation angle. Therefore, a rotated image corresponding to the image to be rotated is generated based on the target pixel position. It is only necessary to map the image to be rotated pixel by pixel based on the pixel position corresponding to each pixel in the image to be rotated after being rotated by the target rotation angle, so as to quickly obtain the rotated image, thereby avoiding the problem of repeated calculation when using affine transformation, Fourier transformation, etc. for image rotation, thereby not only improving processing efficiency but also ensuring real-time performance.
[0050] In one embodiment of the present invention, before obtaining the target pixel position data corresponding to the target rotation angle based on the preset pixel position mapping relationship table, the method further includes: constructing a pixel position mapping relationship table.
[0051] In a specific embodiment, the pixel position mapping relationship table includes corresponding mapping relationships between different rotation angles and pixel position data. The pixel position mapping relationship table can be pre-inputted by an operator into a related controller, such as a control chip of a printer.
[0052] Specifically, by presetting a position coordinate system, the pixel position corresponding to each pixel after being rotated by a target rotation angle can be determined according to the rotation center and the rotation angle, and each target pixel position data can be represented by coordinates to construct a pixel position mapping relationship table.
[0053] Specifically, by constructing a pixel position mapping relationship table, it is convenient to query the pixel position mapping relationship table according to the target rotation angle of the image to be rotated, determine the target pixel position data corresponding to the target rotation angle, and thereby determine the pixel position of the image to be rotated after the image rotation, thereby completing the image rotation according to the pixel position of the image to be rotated after the image rotation.
[0054] In one embodiment of the present invention, constructing a pixel position mapping relationship includes: determining a rotation center; and obtaining a corresponding pixel position of each pixel in the image to be rotated after rotating by the target rotation angle based on the rotation center and the target rotation angle.
[0055] In a specific embodiment, the rotation center of the image to be rotated includes but is not limited to the geometric center. Specifically, by presetting a position coordinate system, based on the rotation center and the target rotation angle, the corresponding pixel position of each pixel after being rotated by the target rotation angle can be determined, and each target pixel position data can be represented by coordinates to construct a pixel position mapping relationship table.
[0056] Specifically, the rotation center is first determined, and then based on the rotation center and the target rotation angle, the pixel position corresponding to each pixel in the image to be rotated after being rotated by the target rotation angle is obtained, thereby constructing a pixel position mapping relationship table, so as to facilitate subsequent query of the pixel position mapping relationship table according to the obtained target rotation angle of the image to be rotated, determine the target pixel position data corresponding to the target rotation angle, thereby determining the pixel position of the image to be rotated after the image rotation, and then completing the image rotation according to the pixel position of the image to be rotated after the image rotation.
[0057] In one embodiment of the present invention, the pixel position corresponding to each pixel in the image to be rotated after being rotated by the target rotation angle is calculated by the following formula:
[0058]
[0059] Where θ is the rotation angle, c x is the X-axis coordinate value of the rotation center, c y is the Y-axis coordinate value of the rotation center, i is the X-axis coordinate value before rotation, j is the Y-axis coordinate value before rotation, i ′ is the X-axis coordinate value after rotation, j ′ is the Y-axis coordinate value after rotation.
[0060] In a specific embodiment, by presetting a position coordinate system, the position (i, j) of each pixel in the image to be rotated is determined, based on the rotation center (c x , c y ) and the target rotation angle θ, the above formula can be used to determine the corresponding pixel position (i ′ , j ′ ).
[0061] Specifically, the pixel position corresponding to each pixel in the image to be rotated after the target rotation angle is calculated through the above formula, so as to construct a pixel position mapping relationship table, so as to facilitate the subsequent query of the pixel position mapping relationship table according to the obtained target rotation angle of the image to be rotated, and determine the target pixel position data corresponding to the target rotation angle, so as to determine the pixel position of the image to be rotated after the image rotation, and then facilitate the completion of the image rotation according to the pixel position of the image to be rotated after the image rotation.
[0062] In one embodiment of the present invention, the rotation center is the image center of the image to be rotated.
[0063] In a specific embodiment, the rotation center of the image to be rotated is the image center, and determining the rotation center as the image center is in line with the image rotation operation habits.
[0064] Specifically, first determine the image center of the image to be rotated as the rotation center, and then based on the rotation center and the target rotation angle, obtain the pixel position corresponding to each pixel in the image to be rotated after the target rotation angle is rotated, thereby constructing a pixel position mapping relationship table, so as to facilitate subsequent query of the pixel position mapping relationship table according to the obtained target rotation angle of the image to be rotated, determine the target pixel position data corresponding to the target rotation angle, thereby determining the pixel position of the image to be rotated after the image rotation, and then facilitate completing the image rotation according to the pixel position of the image to be rotated after the image rotation.
[0065] In order to better understand the present invention, the following Figure 2-4 , the image rotation method of the embodiment of the present invention is described in detail with a specific embodiment.
[0066] Figure 2 FIG. 1 is a schematic diagram of the overall process of an image rotation method according to a specific embodiment of the present invention. Figure 2 As shown, in a specific embodiment, the image rotation method includes the following steps:
[0067] Step S10: table lookup preprocessing: calculating and storing the pixel position mapping relationship corresponding to different rotation angles.
[0068] Step S20: Image rotation: Use the pre-generated lookup table to achieve rapid rotation of the image.
[0069] Figure 3 is a schematic diagram of table lookup preprocessing according to a specific embodiment of the present invention. Figure 3 As shown, in a specific embodiment, step S10 includes:
[0070] Step S101: Determine the rotation center and the rotation angle range.
[0071] Step S102: For each pixel position, calculate its new position after rotation.
[0072] Step S103: Store the calculation result in a lookup table.
[0073] Figure 4 is a schematic diagram of image rotation according to a specific embodiment of the present invention, such as Figure 4 As shown, in a specific embodiment, specifically, step S20 includes:
[0074] Step S201: According to a given rotation angle, a corresponding pixel position mapping relationship is obtained from a lookup table.
[0075] Step S202: For each pixel of the original image, look up the table to obtain its new position, and assign its value to the new position.
[0076] Step S203: Generate a rotated image.
[0077] Based on the above steps, a 512x512 image is rotated with the image center as the rotation center and the rotation angle range from 0° to 360°, calculated every 1°.
[0078] The pixel position corresponding to each pixel in the image to be rotated after the target rotation angle is calculated by the following formula:
[0079]
[0080] Where θ is the rotation angle, c x is the X-axis coordinate value of the rotation center, c y is the Y-axis coordinate value of the rotation center, i is the X-axis coordinate value before rotation, j is the Y-axis coordinate value before rotation, i ′ is the X-axis coordinate value after rotation, j ′ is the Y-axis coordinate value after rotation.
[0081] For a given rotation angle, such as 45°, the corresponding pixel position mapping relationship is obtained from the lookup table, and the mapping is performed pixel by pixel to generate a rotated image.
[0082] In terms of hardware implementation, FPGA (Field Programmable Gate Array) or ASIC (Application Specific Integrated Circuit) design can be used to further improve the real-time performance of image rotation. By implementing table lookup and position mapping in hardware, higher processing speed and efficiency can be achieved, which is suitable for image processing applications that require high real-time performance, such as video processing, real-time monitoring, etc.
[0083] The image rotation method according to the above steps has the following advantages: 1. High efficiency: through the table lookup method, repeated calculations are avoided and the speed of image rotation is significantly improved; 2. Real-time: the pre-stored lookup table data enables the rotation operation to respond quickly in real-time applications; 3. Flexibility: supports rotation at any angle and has strong scalability, suitable for images of different sizes and resolutions.
[0084] In summary, according to the image rotation method of the embodiment of the present invention, the target rotation angle of the image to be rotated is first obtained as the basis for image rotation; then, according to the target rotation angle of the image to be rotated obtained as above, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle; finally, a rotated image corresponding to the image to be rotated is generated according to the target pixel position to complete the image rotation; based on this method, image rotation can be performed by only querying the pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, thereby quickly realizing image rotation, avoiding the problem of repeated calculation when using affine transformation, Fourier transformation, etc. for image rotation, thereby not only improving processing efficiency but also ensuring real-time performance.
[0085] A further embodiment of the present invention also discloses an image rotation device, Figure 5 is a structural block diagram of an image rotation device according to an embodiment of the present invention. Figure 5 As shown, the image rotation device 100 includes: an acquisition module 101 , a first processing module 102 and a second processing module 103 .
[0086] Specifically, the acquisition module 101 is used to acquire a target rotation angle of the image to be rotated.
[0087] The first processing module 102 is used to obtain target pixel position data corresponding to the target rotation angle based on a preset pixel position mapping relationship table, wherein the pixel position mapping relationship table includes corresponding mapping relationships between different rotation angles and pixel position data.
[0088] The second processing module 103 is used to generate a rotated image corresponding to the image to be rotated based on the target pixel position.
[0089] In one embodiment of the present invention, the target pixel position data includes the pixel position corresponding to each pixel in the to-be-rotated image after it is rotated by the target rotation angle.
[0090] In one embodiment of the present invention, the second processing module 103 generates a rotated image corresponding to the image to be rotated based on the target pixel position, including: mapping the image to be rotated pixel by pixel based on the pixel position corresponding to each pixel in the image to be rotated after rotating the target rotation angle to obtain the rotated image.
[0091] In one embodiment of the present invention, the target pixel position data includes the pixel position corresponding to each pixel in the to-be-rotated image after it is rotated by the target rotation angle.
[0092] In one embodiment of the present invention, the first processing module 102 is further configured to: construct a pixel position mapping relationship table before obtaining the target pixel position data corresponding to the target rotation angle based on the preset pixel position mapping relationship table.
[0093] In one embodiment of the present invention, the first processing module 102 constructs a pixel position mapping relationship, including: determining a rotation center; and obtaining a corresponding pixel position of each pixel in the image to be rotated after rotating by the target rotation angle based on the rotation center and the target rotation angle.
[0094] In one embodiment of the present invention, the pixel position corresponding to each pixel in the image to be rotated after being rotated by the target rotation angle is calculated by the following formula:
[0095]
[0096] Where θ is the rotation angle, c x is the X-axis coordinate value of the rotation center, c y is the Y-axis coordinate value of the rotation center, i is the X-axis coordinate value before rotation, j is the Y-axis coordinate value before rotation, i ′ is the X-axis coordinate value after rotation, j ′ is the Y-axis coordinate value after rotation.
[0097] In one embodiment of the present invention, the rotation center is the image center of the image to be rotated.
[0098] According to the image rotation device 100 of the embodiment of the present invention, the target rotation angle of the image to be rotated is first obtained as the basis for image rotation; then, according to the target rotation angle of the image to be rotated, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle; finally, a rotated image corresponding to the image to be rotated is generated according to the target pixel position to complete the image rotation; therefore, the image rotation device 100 only needs to query the pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, so as to quickly realize image rotation, thereby avoiding the problem of repeated calculation when performing image rotation using affine transformation, Fourier transformation, etc., thereby not only improving processing efficiency but also ensuring real-time performance.
[0099] A further embodiment of the present invention also discloses a chip.
[0100] In some embodiments, the chip includes: an image rotation device 100 as described in any of the above embodiments of the present invention.
[0101] In other embodiments, the chip includes: a processor, a memory, and an image rotation program stored in the memory and executable on the processor, wherein the image rotation program, when executed by the processor, implements the image rotation method as described in any of the above embodiments of the present invention.
[0102] In a specific embodiment, the chip can be applied to the printing field, and specifically can be applied to printing equipment or printing equipment, etc.
[0103] The chip according to the embodiment of the present invention can execute the image rotation method of the embodiment of the present invention, firstly, the target rotation angle of the image to be rotated is obtained as the basis for image rotation; then, according to the target rotation angle of the image to be rotated obtained above, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle; finally, a rotated image corresponding to the image to be rotated is generated according to the target pixel position to complete the image rotation; therefore, when the chip executes the image rotation method of the embodiment of the present invention, it only needs to query the pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, so as to quickly realize image rotation, thereby avoiding the problem of repeated calculation when using affine transformation, Fourier transformation, etc. for image rotation, thereby not only improving processing efficiency but also ensuring real-time performance.
[0104] A further embodiment of the present invention also discloses an electronic device, which includes: the chip described in the above embodiment of the present invention.
[0105] In a specific embodiment, the electronic device is, for example, an image rotation device, including but not limited to a printing device or a printing device.
[0106] According to the electronic device of the embodiment of the present invention, the image rotation method of the embodiment of the present invention can be executed. First, the target rotation angle of the image to be rotated is obtained as the basis for image rotation; then, according to the target rotation angle of the image to be rotated obtained above, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle; therefore, when the electronic device executes the image rotation method of the embodiment of the present invention, it only needs to query the pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, so as to quickly realize image rotation, thereby avoiding the problem of repeated calculation when using affine transformation, Fourier transformation, etc. for image rotation, thereby not only improving processing efficiency but also ensuring real-time performance.
[0107] A further embodiment of the present invention further discloses a computer-readable storage medium, on which an image rotation program is stored. When the image rotation program is executed by a processor, the image rotation method described in any of the above embodiments of the present invention is implemented.
[0108] According to the computer-readable storage medium of an embodiment of the present invention, when the image rotation program stored thereon is executed by the processor, the target rotation angle of the image to be rotated is first obtained as the basis for image rotation; then, according to the target rotation angle of the image to be rotated obtained as above, a pre-calibrated pixel position mapping relationship table is queried to determine the target pixel position data corresponding to the target rotation angle; finally, a rotated image corresponding to the image to be rotated is generated according to the target pixel position to complete the image rotation; therefore, when the image rotation program stored thereon is executed by the processor, the image rotation can be quickly realized only by querying the pre-calibrated pixel position mapping relationship table to determine the target pixel position data corresponding to the target rotation angle, thereby avoiding the problem of repeated calculation when performing image rotation using affine transformation, Fourier transformation, etc., thereby not only improving processing efficiency but also ensuring real-time performance.
[0109] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example.
[0110] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. An image rotation method, characterized in that: include: Obtain the target rotation angle of the image to be rotated; Obtaining target pixel position data corresponding to the target rotation angle based on a preset pixel position mapping relationship table, wherein the pixel position mapping relationship table includes corresponding mapping relationships between different rotation angles and pixel position data; A rotated image corresponding to the to-be-rotated image is generated based on the target pixel position.
2. The image rotation method according to claim 1, characterized in that: The target pixel position data includes the pixel position corresponding to each pixel in the to-be-rotated image after being rotated by the target rotation angle.
3. The image rotation method according to claim 2, characterized in that: Generating a rotated image corresponding to the image to be rotated based on the target pixel position includes: Based on the pixel position corresponding to each pixel in the image to be rotated after being rotated by the target rotation angle, the image to be rotated is mapped pixel by pixel to obtain the rotated image.
4. The image rotation method according to claim 2, characterized in that: Before obtaining the target pixel position data corresponding to the target rotation angle based on the preset pixel position mapping relationship table, the method further includes: Construct the pixel position mapping relationship table.
5. The image rotation method according to claim 4, characterized in that: The step of constructing the pixel position mapping relationship includes: Determine the center of rotation; Based on the rotation center and the target rotation angle, a pixel position corresponding to each pixel in the to-be-rotated image after being rotated by the target rotation angle is obtained.
6. The image rotation method according to claim 5, characterized in that: The pixel position corresponding to each pixel in the image to be rotated after being rotated by the target rotation angle is calculated by the following formula: Where θ is the rotation angle, c x is the X-axis coordinate value of the rotation center, c y is the Y-axis coordinate value of the rotation center, i is the X-axis coordinate value before rotation, j is the Y-axis coordinate value before rotation, i ′ is the X-axis coordinate value after rotation, j ′ is the Y-axis coordinate value after rotation.
7. The image rotation method according to claim 5, characterized in that: The rotation center is the image center of the image to be rotated.
8. An image rotation device, characterized in that: include: An acquisition module is used to acquire a target rotation angle of the image to be rotated; A first processing module, configured to obtain target pixel position data corresponding to the target rotation angle based on a preset pixel position mapping relationship table, wherein the pixel position mapping relationship table includes corresponding mapping relationships between different rotation angles and pixel position data; The second processing module is used to generate a rotated image corresponding to the image to be rotated based on the target pixel position.
9. A chip, characterized in that: include: The image rotation device as claimed in claim 8; or, A processor, a memory, and an image rotation program stored in the memory and executable on the processor, wherein the image rotation program implements the image rotation method according to any one of claims 1 to 7 when executed by the processor.
10. An electronic device, characterized in that: Comprising the chip as claimed in claim 9.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an image rotation program, and when the image rotation program is executed by the processor, the image rotation method according to any one of claims 1 to 7 is implemented.
