Image processing method, processor, system on chip, electronic equipment and storage medium
By reading and merging pixel points with preset row counts and storing them as single-column pixel points, the problem of low image rotation processing efficiency is solved, and more efficient image rotation processing is achieved, especially in the application of RVV instruction sets, which is significantly improved. performance.
Patent Information
- Application Number
- CN202410805681.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-11-26
AI Technical Summary
On chips without hardware acceleration support, image rotation processing efficiency is low, and the prior art has failed to effectively solve this problem.
By reading the pixel points with a preset number of rows from the original image and merging them, a single row of pixel points is obtained and stored in memory as a single column of pixel points, thereby obtaining the rotating image and making full use of the processor's memory access Bit width reduces the number of storage times and improves processing efficiency.
This improves the processing speed and efficiency of image rotation, solves the problem of low image rotation processing efficiency, especially when using RVV instruction sets, which significantly improves performance.
Smart Images

Figure CN119027318A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of processors, and in particular, to an image processing method, a processor, a system on a chip, an electronic device, and a storage medium. Background Art
[0002] In current computer systems, image processing is one of the most computationally intensive tasks, especially on chips without hardware acceleration support such as graphics processing units (GPUs) and 2D graphics accelerators (G2Ds). Operations such as image rotation need to be completed by the processor (Central Processing Unit, CPU). When processing tasks such as image rotation, the CPU can implement them based on different instruction sets, which are mainly divided into two categories: scalar and vector. However, whether it is scalar or vector implementation, on chips without hardware acceleration support, the CPU has certain performance bottlenecks in processing tasks such as image rotation, resulting in low processing efficiency of image rotation.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present application provide an image processing method, a processor, a system on chip, an electronic device and a storage medium to at least solve the technical problem of low processing efficiency of image rotation.
[0005] According to one aspect of an embodiment of the present application, there is provided an image processing method, which is applied to a processor, and includes: reading a preset number of rows of pixels from an original image, wherein the preset number of rows matches the processor; performing a merging operation on the preset number of rows of pixels to obtain a single row of pixels; storing the single row of pixels as a single column of pixels in a memory; and obtaining multiple columns of pixels stored in the memory to obtain a rotated image corresponding to the original image.
[0006] According to another aspect of an embodiment of the present application, an image processing device is also provided, including: a reading module, used to read a preset number of rows of pixels from an original image, wherein the preset number of rows matches a processor; an operation module, used to perform a merging operation on the preset number of rows of pixels to obtain a single row of pixels; a storage module, used to store the single row of pixels as a single column of pixels in a memory; and an acquisition module, used to acquire multiple columns of pixels stored in the memory to obtain a rotated image corresponding to the original image.
[0007] According to another aspect of the embodiments of the present application, a processor is also provided, including: a memory for storing pixel points in an original image; a processing unit connected to the memory, for reading a preset number of rows of pixel points from the original image, performing a merging operation on the preset number of rows of pixel points to obtain a single row of pixel points, storing the single row of pixel points as a single column of pixel points in the memory, obtaining multiple columns of pixel points stored in the memory, and obtaining a rotated image corresponding to the original image, wherein the preset number of rows matches the processor.
[0008] According to another aspect of the embodiments of the present application, a system on chip is also provided, including: a storage device for storing pixel points in an original image; a processor, connected to the storage device, for reading a preset number of rows of pixel points from the original image, performing a merging operation on the preset number of rows of pixel points to obtain a single row of pixel points, storing the single row of pixel points as a single column of pixel points in the storage device, acquiring multiple columns of pixel points stored in the storage device, and obtaining a rotated image corresponding to the original image, wherein the preset number of rows matches the processor.
[0009] According to another aspect of the embodiments of the present application, an electronic device is further provided, including: a memory storing an executable program; and a processor for running the program, wherein the method of each embodiment of the present application is executed when the program is running.
[0010] According to another aspect of an embodiment of the present application, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in each embodiment of the present application.
[0011] According to another aspect of the embodiments of the present application, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present application is implemented.
[0012] According to another aspect of an embodiment of the present application, a computer program product is also provided, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present application is implemented.
[0013] According to another aspect of the embodiments of the present application, a computer program is also provided, and when the computer program is executed by a processor, the methods in the various embodiments of the present application are implemented.
[0014] In an embodiment of the present application, a preset number of rows of pixels can be read from the original image, wherein the preset number of rows matches the processor, and the preset number of rows of pixels are merged to obtain a single row of pixels, and the single row of pixels is stored in the memory as a single column of pixels, and the multiple columns of pixels stored in the memory are obtained to obtain a rotated image corresponding to the original image, thereby improving the processing efficiency of image rotation. It is easy to notice that by loading the preset number of rows of pixels at the same time, the efficiency of reading pixels can be improved, and the preset number of rows of pixels read are merged to widen the bit width during writing, and the memory access bit width of the processor is fully utilized, thereby reducing the writing operation and improving the speed of image rotation, thereby solving the technical problem of low processing efficiency of image rotation.
[0015] It is easy to notice that the above general description and the following detailed description are only for the purpose of exemplifying and explaining the present application, and do not constitute a limitation of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 is a hardware structure block diagram of a RISC-V system for implementing an image processing method according to an embodiment of the present application;
[0018] Figure 2 is a schematic diagram of a system on chip according to an embodiment of the present application;
[0019] Figure 3 is a flowchart of an image processing method according to an embodiment of the present application;
[0020] Figure 4 is a schematic diagram of image rotation according to an embodiment of the present application;
[0021] Figure 5 is a flow chart of image rotation according to an embodiment of the present application;
[0022] Figure 6 is a schematic diagram of an image processing device according to an embodiment of the present application;
[0023] Figure 7 is a schematic diagram of a processor according to an embodiment of the present application;
[0024] Figure 8 is a schematic diagram of a system on chip according to an embodiment of the present application;
[0025] Fig. 9It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0029] Image rotation: refers to rotating an image at a certain angle to better observe or process the image.
[0030] RISC-V Vector Extension (RVV) is an extended instruction set for a reduced instruction set computer (RISC-V architecture), designed to provide support for vector data operations.
[0031] In general, the RVV instruction set adds support for vector operations to the RISC-V architecture, improves the efficiency and performance of processing vector data, and makes the RISC-V architecture more competitive when processing large-scale data and complex computing tasks.
[0032] Load: refers to loading data from memory into registers.
[0033] Store: Store the data in the register into the memory.
[0034] At present, when the CPU processes tasks such as image rotation, it can be implemented based on different instruction sets, which are mainly divided into two categories: scalar and vector. Scalar implementation refers to using the basic instructions of the CPU to perform image processing tasks. Although this method can achieve the function, it does not fully utilize the CPU's memory bandwidth because it operates on a pixel basis, resulting in the inability to effectively improve processing performance.
[0035] However, in the existing vector implementation, although it can realize the simultaneous processing of multiple pixels when reading pixel data, it does not fully utilize the parallel processing capability of SIMD instructions when storing pixel data, resulting in insignificant performance improvement. This is because in the process of multi-pixel storage, sequential access is still used, and parallel processing is not realized.
[0036] Among the chips currently used, especially those with limited computing power, in products that require screen interface interaction, if RVV is not used to accelerate the rotation of the image, the product's interactive interface will be severely stuck and difficult to mass produce.
[0037] Based on this scenario, this application optimizes the drawing of image elements in the UI based on the RVV instruction set. Among them, the performance of image rotation has the greatest impact on the overall product.
[0038] In view of the above problems, combined with the SIMD-based image rotation implementation on X86 and ARM, this application proposes an RVV-based image rotation acceleration implementation. In order to further improve the processing efficiency, this application fully utilizes the CPU's memory access bandwidth and the parallel processing capability of SIMD instructions to achieve more efficient image processing and increase the smoothness of the interface.
[0039] According to an embodiment of the present application, an image processing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0040] The method embodiment provided in Embodiment 1 of the present application can be executed in a RISC-V system, a RISC-V chip or a similar device. Figure 1 1 is a hardware structure block diagram of a RISC-V system for implementing an image processing method according to an embodiment of the present application. Figure 1As shown, the RISC-V system 100 can be divided from the bottom layer to the upper layer into a reduced instruction set architecture 101 (including a basic instruction set 101-1 and an extended instruction set 101-2), a hardware layer 102 (including a processor 102-1, a peripheral hardware circuit 102-2, etc.), an interface layer 103, an operating system layer 104 (supporting multiple operating systems 104-1, 104-2, ..., 104-n, such as Linux, FreeSBD, RT-Tread, etc.), a middleware and library layer 105 (including a system library 105-1, an API 105-2 and a middleware service 105-3) and an application layer 106 (including multiple user programs and services 106-1, 106-2, ..., 106-n). The RISC-V system 100 also includes a tool chain 107 from the underlying hardware to the application layer, which may include a compiler and assembler 107-1, a linker 107-2, a debugger 107-3, a simulator and emulator 107-4, an integrated development environment 107-5, a hardware description language tool 107-6, a performance analysis tool 107-7 and a version control system 107-8, etc.
[0041] The instruction set architecture 101 defines the basic operations and instruction sets supported by the processor 102-1, including a basic instruction set and an extended instruction set, wherein the basic instruction set represents a basic integer instruction set, such as RV32I and RV64I, and the extended instruction set can be floating point, atomic operations, compressed instructions, etc.
[0042] The interface layer 103 includes the specific design of the processor, such as pipeline design, cache structure, execution unit, branch prediction, etc. This layer is the process of mapping abstract instructions to physical hardware.
[0043] The operating system layer 104 is located at the hardware level and provides a hardware abstraction layer and management mechanism, so that applications can interact with the hardware through system calls. The operating system is responsible for managing processor resources, memory, device drivers, task scheduling, etc.
[0044] The middleware and library layer 105 provides a rich set of services and interfaces to help applications run more efficiently. For example, the standard library provides functions such as file operations and mathematical calculations, while the middleware can provide complex services such as network communications and graphical user interfaces.
[0045] The application layer 106 uses the functions and services provided by the lower layer to implement specific application logic. These applications can be command line tools, graphical interface applications, server-side services, etc.
[0046] The tool chain 107 is a key component that connects the underlying hardware to the upper-level software. Various tools in the tool chain 107 function at different levels to support the entire process from hardware design to software development, ensuring the consistency and effectiveness of the entire system design.
[0047] It should be noted that the layered design of the RISC-V architecture allows decoupling between different layers, so that each layer can be developed and optimized independently.
[0048] In an optional embodiment, Figure 2 is a schematic diagram of a system on chip according to an embodiment of the present application, Figure 2 Shown using the above Figure 1 The schematic diagram of the RISC-V architecture system on chip (System On Chip, SOC) is shown in FIG. Figure 2 As shown, the SOC includes at least one RISC-V core 202 (only one is shown in the figure), and the RISC-V core 202 is connected to peripheral devices through a bus 204, including but not limited to ROM 206, RAM 208, timer 210, UART (Universal Asynchronous Receiver / Transmitter) 212, GPIO (General Purpose Input / Output) 214, SPI (Serial Peripheral Interface Bus) 216, etc.
[0049] Under the above operating environment, this application provides Figure 3 The image processing method shown. Figure 3 is a flowchart of an image processing method according to an embodiment of the present application.
[0050] Step S302, reading a preset number of rows of pixels from the original image.
[0051] The preset number of rows matches the processor.
[0052] The original image mentioned above may be an image to be rotated.
[0053] The above-mentioned preset number of rows can be determined according to the loading capacity of the processor to ensure that the processor can effectively process pixels without being overloaded. If the loading capacity of the processor is higher, the preset number of rows can be set larger, and if the loading capacity of the processor is lower, the preset number of rows can be set smaller.
[0054] In an optional embodiment, the image data of the original image can be processed in stages by reading a preset number of rows of pixels, so as to avoid overloading the processor by processing too many pixels at one time. At the same time, the preset number of rows of pixels to be read can be flexibly adjusted according to the processing capacity of the processor to improve the image processing effect and processing speed. According to the characteristics and performance of the processor, the preset number of rows of pixels can be reasonably selected and read, which can improve the efficiency and quality of image processing.
[0055] Step S304: merging a preset number of rows of pixels to obtain a single row of pixels.
[0056] The bit width of the above-mentioned single row of pixels may be the same as the memory access bit width of the processor.
[0057] In an optional embodiment, the vector merge instruction provided by RVV can be used to merge the pixels of a preset number of rows to obtain a single row of pixels. For example, a vertical slide up instruction (vs l ideup) can be used to merge the pixels of a preset number of rows by sliding upward to obtain a single row of pixels. The vertical slide up instruction will move the pixels of a preset number of rows upward according to a specified step size.
[0058] In the process of merging a preset number of rows of pixels, if the preset number of rows of pixels need to be aligned in the horizontal direction, the displacement instructions provided by RVV can be used to adjust the relative positions of the pixels, so as to accurately merge the preset number of rows of pixels to obtain a single row of pixels.
[0059] By merging a preset number of rows of pixels to obtain a single row of pixels, it is convenient for the processor to access the single row of pixels.
[0060] Step S306, storing the single row of pixels as a single column of pixels in the memory.
[0061] The above-mentioned memory may be a pre-specified memory address, which may be set according to actual usage scenarios.
[0062] In an optional embodiment, after a single row of pixels is obtained by merging, the single row of pixels can be stored in memory using a storage instruction in RVV. For example, a vector store element instruction (Vector StoreElement, referred to as VSE) can be used to store a single row of pixels in a vector register to a specified memory address.
[0063] During the storage process, the storage position of a single row of pixels can be controlled by a pre-set storage strategy so that the single row of pixels can be stored in a single column. For example, the stride store instruction (Stride Store) in RVV can be used to specify the storage interval, thereby controlling the storage position of a single row of pixels so that they are finally stored in a single column of pixels.
[0064] In another optional embodiment, the position of a single row of pixels stored in the memory may be set according to the rotation angle of the original image, and the single row of pixels may be stored in the memory to a rotated image corresponding to the rotation angle.
[0065] Step S308, obtaining multiple columns of pixel points stored in the memory to obtain a rotated image corresponding to the original image.
[0066] The above-mentioned multiple columns of pixel points may be multiple single columns of pixel points obtained through multiple merging operations and storage operations.
[0067] In an optional embodiment, after storing the pixels in the original image in the memory, multiple single columns of pixels of the original image can be obtained, that is, the multiple columns of pixels mentioned above. If the multiple columns of pixels completely contain the pixels in the original image, it means that the original image has been rotated, and the image displayed by the multiple columns of pixels is the rotated image corresponding to the original image.
[0068] By reading a preset number of rows of pixels and merging them into a single row of pixels, the storage bit width is increased, the processor's memory access bit width is fully utilized, and the number of times the pixels are stored is reduced, thereby improving the efficiency of storing pixel points, and further improving the efficiency of rotating the original image.
[0069] Figure 4 is a schematic diagram of an image rotation according to an embodiment of the present application, such as Figure 4 As shown, the preset number of rows can be two rows, and the pixels of the two rows can be merged to obtain a single row of pixels with the same memory access bit width as the processor. The single row of pixels can be stored in the memory as a single column of pixels. After the pixels of the original image are merged and stored, a rotated image corresponding to the original image is obtained.
[0070] Through the above steps, a preset number of rows of pixels can be read from the original image, wherein the preset number of rows matches the processor, and the preset number of rows of pixels are merged to obtain a single row of pixels, and the single row of pixels is stored in the memory as a single column of pixels, and the multiple columns of pixels stored in the memory are obtained to obtain a rotated image corresponding to the original image, thereby improving the processing efficiency of image rotation. It is easy to notice that by loading the preset number of rows of pixels at the same time, the efficiency of reading pixels can be improved, and the preset number of rows of pixels read are merged to widen the bit width during writing, and the memory access bit width of the processor is fully utilized, thereby reducing the writing operation and improving the speed of image rotation, thereby solving the technical problem of low processing efficiency of image rotation.
[0071] In the above embodiment of the present application, reading a preset number of rows of pixels from an original image includes: determining a loading instruction from an instruction set corresponding to a processor; and using the loading instruction to read a row of pixels from the original image in sequence to obtain a preset number of rows of pixels.
[0072] The instruction set corresponding to the above-mentioned processor may refer to a set of specific machine language instructions, which are designed for a specific processor so that specific operations and tasks can be performed through the instructions in the instruction set. Different processors may have an instruction set architecture corresponding to the processor, and the instruction set architecture may define the types of instructions that the processor can understand and execute.
[0073] The above-mentioned instruction set includes but is not limited to data transfer instructions, arithmetic operation instructions, logic instructions, control flow instructions, input and output instructions, system instructions, loading instructions, etc. There is no limitation on the instruction type contained in the instruction set here, and it can be set according to the actual needs of the processor.
[0074] The above-mentioned load instruction (vector load) may be a type of data transfer instruction, and is mainly used to load data from a memory into a register of a processor, so that the processor can further process or operate the data.
[0075] In an optional embodiment, when reading the pixels in the original image, a load instruction can be used to read the pixels from the original image row by row. By executing the load instruction, the processor can load the pixels from the memory into a register or cache to facilitate subsequent processing operations. By reading a row of pixels in sequence, a preset number of rows of pixels can be obtained, so that the operation of merging the preset number of rows of pixels can be performed later. The load instruction can help the processor to efficiently read the preset number of rows of pixels from the memory.
[0076] In the process of image processing, an image is usually composed of multiple pixels, and different pixels represent the color or brightness of a point in the image. The above-mentioned row of pixels refers to a horizontal scan line in the image. On the display, the image is displayed line by line. A row of pixels can be read from the original image from top to bottom, but it is not limited to this. It can also be read according to the actual set reading method, or a row of pixels can be read from bottom to top.
[0077] In the above embodiment of the present application, a merging operation is performed on a preset number of rows of pixel points to obtain a single row of pixel points, including: determining a merging operation instruction from an instruction set corresponding to the processor; and using the merging operation instruction to sequentially merge pixel points at the same position in the preset number of rows of pixel points to obtain a single row of pixel points.
[0078] The above-mentioned merge operation instruction (vector or) is used to perform a logical OR operation on the pixels at the same position in a preset number of rows of pixels.
[0079] The above same position can be used to represent pixel points belonging to the same column in a preset number of rows.
[0080] If the preset number of rows is a single row, there is no need to perform a merging operation on the pixels of the single row, and the pixels of the preset number of rows can be directly determined as a single row of pixels. If the preset number of rows is multiple rows, it is necessary to perform a merging operation on the pixels of multiple rows. The pixels in the same column of the multiple rows of pixels can be merged into a pixel in a single row, and the pixels in each column in the preset number of rows can be merged in turn. The pixels in a single row are obtained based on the pixels obtained by merging different columns in the single row.
[0081] Exemplarily, pixels at the same position in a preset number of rows (for example, all are the first column, the second column, etc.) will be selected to perform a merging operation. For each row in the image, if the pixel points in the first column of the first row are merged with the pixel points in the first column of the second row, the merged pixel points of the first column of a single row of pixels can be obtained. The single row of pixels can be determined based on the merged pixel points of multiple columns.
[0082] In an optional embodiment, a merge operation instruction can be used to merge the pixels at the same position in the preset number of rows of pixels. The merge operation instruction can merge multiple pixels into a single pixel, thereby reducing the amount of data and improving processing efficiency. By performing a merge operation on the pixels of each row in turn, a single row of pixel data can be obtained to facilitate memory access by a subsequent processor. This method can effectively reduce the amount of calculation and memory usage, and improve processing speed and efficiency.
[0083] In the above embodiment of the present application, a single row of pixel points is stored in a memory as a single column of pixel points, including: determining a stride storage instruction from an instruction set corresponding to the processor; and using the stride storage instruction to store the single row of pixel points in the memory to obtain a single column of pixel points.
[0084] The vector stride store instruction means that the processor can skip a certain number of elements or addresses when performing a store operation. The vector stride store instruction can be used to convert data from one format to another format, for example, from rows to columns.
[0085] When executing a stride store instruction in the processor, data can be stored across a certain distance by specifying a stride length. This allows for flexible storage of data, such as storing a row of pixels in memory at a specified stride length. When it is necessary to convert these stored pixels into a column of pixels, the corresponding stride store instruction can be executed according to the angle to be rotated to reassemble the stored pixels into a column of pixels. The stride store instruction can help achieve flexible storage and processing of data, and by reasonably combining and executing these instructions, data conversion and processing operations can be achieved.
[0086] The above-mentioned storage of a single row of pixels into a memory to obtain a single column of pixels mainly involves a data rearrangement operation, whereby a single row of pixels can be stored into a memory so that the pixels in the row are arranged in the order of columns in the memory. The rotation angle of the original image can be taken into account during the storage process, so that the stored pixels can be displayed according to the rotation angle.
[0087] In an optional embodiment, a single row of pixels can be stored in memory according to a certain step length according to a stride storage instruction. If the step length is 1, the column transfer operation can be performed directly. If the step length is greater than 1, some pixels will be skipped during the storage process. In practical applications, the step length of the stride storage instruction can be set according to the angle of rotation required. For example, if the image needs to be rotated 90 degrees, the step length may be set to the width of the image so that the pixels are stored in column order in the memory. If it is necessary to rotate 45 degrees or other angles, the step length may need to be adjusted accordingly to accommodate the rotation operation.
[0088] In the above embodiment of the present application, a single row of pixel points is stored in the memory using a stride storage instruction to obtain a single column of pixel points, including: determining the rotation angle of the original image; determining the target storage direction based on the rotation angle; and storing the single row of pixel points in the memory according to the target storage direction using a stride storage instruction to obtain a single column of pixel points.
[0089] The above rotation angle can be set according to the actual needs of the user for the display purpose of the original image. The rotation angle can be 90 degrees, 45 degrees, etc., which is not limited here.
[0090] The above-mentioned target storage direction refers to the storage direction after the original image is rotated, that is, the pixel storage order is determined according to the determined rotation angle. Under the target storage direction, the pixel storage order may change to adapt to the change of the image angle.
[0091] In an optional embodiment, a rotation instruction for an original image may be received, and the angle at which the original image is to be rotated may be obtained from the rotation instruction, thereby determining the rotation angle of the original image. The rotation angle is determined based on the current angle of the original image, and the target storage direction of a single row of pixels in the memory may be determined based on the rotation angle. The single row of pixels may be stored in the memory in a specific order according to the target storage direction based on the stride storage instruction to obtain a single column of pixels. This process needs to take into account the effect of the rotation angle on the data arrangement, and a row of pixels in the original image may be converted and stored as a column of pixels in the memory. This facilitates the correct display of the rotated image during image processing or display.
[0092] For example, if you have a 100x100 pixel image and you want to rotate it 90 degrees, before the rotation, the image pixels are stored in row and column order. After the rotation, the original rows become columns, and the original columns become rows. You can store the pixels of a single row of pixels one by one in memory, but the order of storage must be in the order of columns, so that the address of each pixel in memory will reflect the position in the rotated image.
[0093] In the above embodiment of the present application, before reading a preset number of rows of pixels from the original image, the method further includes: obtaining a memory access bit width of the processor; and determining the preset number of rows based on the memory access bit width.
[0094] The memory access bit width of the processor mentioned above refers to the number of bits of the memory address that the processor can access simultaneously. For example, a 32-bit processor can access 2^32 memory addresses simultaneously. The memory access bit width is generally related to the data bus width of the processor, because the data bus width determines the speed at which the processor reads or writes data from the memory.
[0095] In an optional embodiment, the processor reads or writes a whole row of data at one time when accessing the memory. The preset number of rows of pixels can be determined according to the memory access bit width so that the processor can read or write a whole row of pixels at one time, thereby improving the access speed and efficiency of the memory. This speeds up the data transmission efficiency between the processor and the memory, thereby speeding up the overall performance of the computer system.
[0096] In the above embodiment of the present application, after storing a single row of pixels in a memory as a single column of pixels, the method further includes: determining whether there are unread pixels in the original image; if there are no unread pixels in the original image, acquiring multiple columns of pixels stored in the memory to obtain a rotated image; if there are unread pixels in the original image, repeatedly executing the steps of reading a preset number of rows of pixels from the original image, merging the preset number of rows of pixels, and storing a single row of pixels in the memory as a single column of pixels.
[0097] In an optional embodiment, after storing a single row of pixels in a memory as a single column of pixels, it can be determined whether there are unread pixels in the original image. If there are no unread pixels, multiple columns of pixels stored in the memory can be directly obtained, and the rotated image can be obtained by merging the multiple columns of pixels. If there are unread pixels, it is necessary to repeatedly read a preset number of rows of pixels from the original image, merge these pixels, and store the single row of pixels in the memory as a single column of pixels. By determining whether there are unread pixels, it can be ensured that no pixels are lost when rotating the image, and the situation where there are unread pixels in the original image can be handled. The entire process can achieve the rotation of the original image while maintaining the integrity and clarity of the image.
[0098] In the above embodiment of the present application, when there are unread pixels in the original image, the method also includes: determining the number of rows of unread pixels in the original image; when the number of rows of unread pixels in the original image is greater than or equal to a preset number of rows, repeatedly executing the steps of reading a preset number of rows of pixels from the original image, merging the preset number of rows of pixels, and storing a single row of pixels in a memory as a single column of pixels; when the number of rows of unread pixels is less than the preset number of rows, sequentially storing the unread pixels in the memory as at least one column of pixels.
[0099] In an optional embodiment, the number of rows of unread pixel points in the original image can be determined, and when the number of rows of unread pixel points in the original image is greater than or equal to the preset number of rows, the steps of reading the preset number of rows of pixel points from the original image are repeated according to the memory access capability of the processor, and the steps of merging the preset number of rows of pixel points, and storing the single row of pixel points in the memory as a single column of pixel points can be repeated. When the number of rows of unread pixel points is less than the preset number of rows, the remaining pixel points can be directly stored in the memory as at least one column of pixel points, so that when the number of rows of pixel points is less than the preset number of rows, the unread pixel points can also be stored in the memory, thereby ensuring that all the pixel points of the original image are stored in the memory.
[0100] In another optional embodiment, if the number of rows of unread pixels is greater than or equal to the preset number of rows, then the preset number of rows of pixels will be read from the original image repeatedly, and these pixels will be merged, and finally the single row of pixels will be stored in the memory as a single column of pixels. If the number of rows of unread pixels is less than the preset number of rows, the unread pixels will be sequentially stored in the memory as at least one column of pixels. The situation where there are unread pixels in the original image can be handled by determining the number of rows of pixels, and these unread pixels can be effectively stored by merging and rearranging the pixels for subsequent processing and analysis.
[0101] In the above embodiment of the present application, the unread pixels are stored in the memory in sequence as at least one column of pixels, including: using a load instruction to read the unread pixels from the original image in sequence; using a stride storage instruction to store the unread pixels in sequence to the memory to obtain at least one column of pixels.
[0102] For pixels that do not meet the preset number of rows, the load instruction can be used to read the unread pixels from the original image in sequence, and the pixels are loaded into the processor for further processing. The stride storage instruction can store the loaded pixels into the memory according to the angle of the original image to be rotated, and can be stored in columns to obtain at least one column of pixels. By using the load instruction and the stride storage instruction, large-scale image data can be effectively processed, and the efficiency and speed of data processing can be improved. The use of these instructions can help optimize image processing algorithms and improve the performance and response speed of computer systems.
[0103] In the above embodiments of the present application, the processor adopts a reduced instruction set architecture.
[0104] The Reduced Instruction Set Computing (RISC) mentioned above is a computer processor design architecture, which is characterized by a simple instruction set, fast instruction execution speed, low power consumption and high performance. The instruction set of a RISC processor usually contains a small number of basic instructions, and each instruction takes a short time to execute and can be completed within one clock cycle. Compared with the complex instruction set architecture (CISC), RISC processors pay more attention to simple and efficient instruction design to increase instruction execution speed and reduce power consumption. RISC processors are widely used in mobile devices, embedded systems, network equipment and other fields.
[0105] Figure 5 is a flowchart of an image rotation according to an embodiment of the present application, such as Figure 5 As shown, the method includes:
[0106] Step S501, obtaining the memory access bit width of the processor.
[0107] Step S502, determining a preset number of rows according to the memory access bit width.
[0108] The above-mentioned preset number of rows can be recorded as a variable K.
[0109] Step S503, determining whether the line width of the original image is aligned with the preset number of lines, if so, executing step S506, if not, executing step S504.
[0110] Step S504, using a load instruction to obtain pixel points of non-aligned rows from the image memory multiple times.
[0111] Step S505, using a stride store instruction to store the pixels of the non-aligned rows into the memory, and executing step S506.
[0112] Step S506: Use the load instruction to read a preset number of rows of pixels from the original image multiple times.
[0113] Step S507: Use a merge instruction to merge the pixels of a preset number of rows to obtain a single row of pixels.
[0114] Step S508, using a stride storage instruction to store a single row of pixel points into a memory to obtain a single column of pixel points.
[0115] Step S509, determining whether there are unread pixels in the original image, if so, executing step S510, if not, executing step S506.
[0116] Step S510, obtaining a rotated image corresponding to the original image according to the multiple columns of pixel points stored in the memory.
[0117] By loading multiple rows of pixels at the same time and using the characteristics of the instruction set to perform displacement and transposition, the utilization rate of the processor's memory access bandwidth can be improved, while reducing the number of storage times, thereby increasing the speed of image rotation. The solution provided by this application can speed up the image rotation by 2.6 times when rotating 90 degrees and 270 degrees. It can effectively improve the competitiveness of the processor in the field of graphics processing.
[0118] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0119] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0120] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0121] According to an embodiment of the present application, an image processing device for implementing the above-mentioned image processing method is also provided. Figure 6 is a schematic diagram of an image processing device according to an embodiment of the present application, such as Figure 6 As shown, the device 600 includes: a reading module 602 , an operating module 604 , a storage module 606 , and an acquisition module 608 .
[0122] Among them, the reading module is used to read a preset number of rows of pixels from the original image, wherein the preset number of rows matches the processor; the operation module is used to merge the preset number of rows of pixels to obtain a single row of pixels; the storage module is used to store the single row of pixels as a single column of pixels in the memory; the acquisition module is used to acquire multiple columns of pixels stored in the memory to obtain a rotated image corresponding to the original image.
[0123] It should be noted here that the above-mentioned reading module 602, operation module 604, storage module 606, and acquisition module 608 correspond to steps S302 to S308 in Example 1, and the four modules are the same as the instances and application scenarios implemented by the corresponding steps, but are not limited to the contents disclosed in the above-mentioned Example 1. It should be noted that the above-mentioned modules or units may be hardware components or software components stored in a memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n), and the above-mentioned modules may also be part of the device and may be run in the RISC-V system 100 provided in Example 1.
[0124] In the above embodiment of the present application, the reading module is used to determine the loading instruction from the instruction set corresponding to the processor; and use the loading instruction to read a row of pixels from the original image in sequence to obtain a preset number of rows of pixels.
[0125] In the above embodiment of the present application, the operation module is used to determine a merge operation instruction from the instruction set corresponding to the processor; the merge operation instruction is used to sequentially merge the pixel points at the same position in a preset number of rows of pixel points to obtain a single row of pixel points.
[0126] In the above embodiments of the present application, the storage module is used to determine the stride storage instruction from the instruction set corresponding to the processor; and use the stride storage instruction to store a single row of pixel points into the memory to obtain a single column of pixel points.
[0127] In the above embodiments of the present application, the storage module is used to determine the rotation angle of the original image; based on the rotation angle, the target storage direction is determined; and a single row of pixels is stored in the memory according to the target storage direction using a stride storage instruction to obtain a single column of pixels.
[0128] In the above embodiments of the present application, the device further includes: a determination module.
[0129] The acquisition module is used to acquire the memory access bit width of the processor; and the determination module is used to determine the preset number of rows based on the memory access bit width.
[0130] In the above embodiment of the present application, the determination module is also used to determine whether there are unread pixels in the original image; the acquisition module is also used to acquire multiple columns of pixel points stored in the memory to obtain a rotated image when there are no unread pixels in the original image; the reading module is also used to repeatedly execute the steps of reading a preset number of rows of pixel points from the original image, merging the preset number of rows of pixel points, and storing a single row of pixel points as a single column of pixel points in the memory when there are unread pixels in the original image.
[0131] In the above embodiment of the present application, the determination module is also used to determine the number of rows of unread pixel points in the original image; the reading module is used to, when the number of rows of unread pixel points in the original image is greater than or equal to the preset number of rows, repeatedly execute the steps of reading a preset number of rows of pixel points from the original image, merging the preset number of rows of pixel points, and storing a single row of pixel points as a single column of pixel points in the memory; the storage module is used to, when the number of rows of unread pixel points is less than the preset number of rows, sequentially store the unread pixel points in the memory as at least one column of pixel points.
[0132] In the above embodiment of the present application, the storage module is also used to use the load instruction to read the unread pixel points from the original image in sequence; and use the stride storage instruction to store the unread pixel points in sequence to the memory to obtain at least one column of pixel points.
[0133] In the above embodiments of the present application, the processor adopts a reduced instruction set architecture.
[0134] According to an embodiment of the present application, a processor is also provided. Figure 7 is a schematic diagram of a processor according to an embodiment of the present application, such as Figure 7 As shown, the processor 700 includes: a memory 7002 and a processing unit 7004.
[0135] Among them, the memory is used to store pixel points in the original image; the processing unit is connected to the memory, and is used to read a preset number of rows of pixel points from the original image, merge the preset number of rows of pixel points to obtain a single row of pixel points, store the single row of pixel points as a single column of pixel points in the memory, obtain multiple columns of pixel points stored in the memory, and obtain a rotated image corresponding to the original image, wherein the preset number of rows matches the processor.
[0136] According to an embodiment of the present application, a system on chip is also provided. Figure 8 is a schematic diagram of a system on chip according to an embodiment of the present application, such as Figure 8 As shown, the system on chip 800 includes: a storage device 8002 and a processor 8004.
[0137] Among them, the storage device is used to store pixel points in the original image; the processor is connected to the storage device, and is used to read a preset number of rows of pixel points from the original image, merge the preset number of rows of pixel points to obtain a single row of pixel points, store the single row of pixel points as a single column of pixel points in the storage device, obtain multiple columns of pixel points stored in the storage device, and obtain a rotated image corresponding to the original image, wherein the preset number of rows matches the processor.
[0138] It should be noted that the preferred implementation scheme involved in the above embodiments of the present application is the same as the scheme provided in Example 1, as well as the application scenario and implementation process, but is not limited to the scheme provided in Example 1.
[0139] The embodiment of the present application may provide an electronic device, which may be any electronic device in a group of electronic devices. Optionally, in this embodiment, the electronic device may also be replaced by a terminal device such as a mobile terminal.
[0140] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0141] In this embodiment, the electronic device can execute the program code in the method.
[0142] Optionally, Fig. 9 is a structural block diagram of an electronic device according to an embodiment of the present application. Fig. 9 As shown, the electronic device A may include: one or more (only one is shown in the figure) processors 102, a memory 104, a storage controller, and a peripheral interface, wherein the peripheral interface is connected to a radio frequency module, an audio module, and a display.
[0143] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implementing the methods in the above embodiments. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal A via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0144] The processor can call the information and application stored in the memory through the transmission device to execute the following steps: read a preset number of rows of pixels from the original image, where the preset number of rows matches the processor; merge the preset number of rows of pixels to obtain a single row of pixels; store the single row of pixels as a single column of pixels in the memory; obtain multiple columns of pixels stored in the memory to obtain a rotated image corresponding to the original image.
[0145] Optionally, the processor may also execute the following program code: determine a loading instruction from an instruction set corresponding to the processor; and use the loading instruction to sequentially read a row of pixels from the original image to obtain a preset number of rows of pixels.
[0146] Optionally, the processor may also execute the following program code: determine a merge operation instruction from an instruction set corresponding to the processor; and use the merge operation instruction to sequentially merge pixel points at the same position in a preset number of rows of pixel points to obtain a single row of pixel points.
[0147] Optionally, the processor may also execute program code of the following steps: determining a stride storage instruction from an instruction set corresponding to the processor; and storing a single row of pixel points into a memory using the stride storage instruction to obtain a single column of pixel points.
[0148] Optionally, the processor may also execute the following program code: determining the rotation angle of the original image; determining the target storage direction based on the rotation angle; and storing a single row of pixels into the memory according to the target storage direction using a stride storage instruction to obtain a single column of pixels.
[0149] Optionally, the processor may also execute program codes of the following steps: obtaining a memory access bit width of the processor; and determining a preset number of rows based on the memory access bit width.
[0150] Optionally, the processor may also execute the program code of the following steps: determining whether there are unread pixels in the original image; if there are no unread pixels in the original image, obtaining multiple columns of pixels stored in the memory to obtain a rotated image; if there are unread pixels in the original image, repeatedly reading a preset number of rows of pixels from the original image, merging the preset number of rows of pixels, and storing a single row of pixels as a single column of pixels in the memory.
[0151] Optionally, the processor may also execute the program code of the following steps: determining the number of rows of unread pixels in the original image; when the number of rows of unread pixels in the original image is greater than or equal to a preset number of rows, repeatedly executing the steps of reading a preset number of rows of pixels from the original image, merging the preset number of rows of pixels, and storing a single row of pixels in a memory as a single column of pixels; when the number of rows of unread pixels is less than a preset number of rows, sequentially storing the unread pixels in the memory as at least one column of pixels.
[0152] Optionally, the processor may also execute program code of the following steps: using a load instruction to sequentially read unread pixel points from the original image; using a stride storage instruction to sequentially store the unread pixel points into the memory to obtain at least one column of pixel points.
[0153] Optionally, the processor may also execute program code of the following steps: the processor adopts a reduced instruction set architecture.
[0154] By adopting the embodiment of the present application, a preset number of rows of pixels can be read from the original image, wherein the preset number of rows matches the processor, and the pixel points of the preset number of rows are merged to obtain a single row of pixels, and the single row of pixels is stored in the memory as a single column of pixels, and the multiple columns of pixels stored in the memory are obtained to obtain a rotated image corresponding to the original image, thereby improving the processing efficiency of image rotation. It is easy to notice that by loading the pixel points of the preset number of rows at the same time, the efficiency of reading pixels can be improved, and the pixel points of the preset number of rows read are merged, which widens the bit width when writing, and fully utilizes the memory access bit width of the processor, thereby reducing the write operation, and improving the speed of image rotation, thereby solving the technical problem of low processing efficiency of image rotation.
[0155] Those skilled in the art will understand that Fig. 9 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Fig. 9 It does not limit the structure of the above electronic device. For example, the electronic device A may also include Fig. 9 The present invention may include more or fewer components (such as a network interface, a display device, etc.) shown in the figure, or may have a different configuration than that shown in the figure.
[0156] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0157] The embodiment of the present application further provides a computer-readable storage medium. Optionally, in this embodiment, the computer-readable storage medium can be used to store the program code executed by the method provided in the above embodiment.
[0158] Optionally, in this embodiment, the above storage medium may be located in any electronic device in a group of electronic devices in a computer network, or in any mobile terminal in a group of mobile terminals.
[0159] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for executing the following steps: reading a preset number of rows of pixels from the original image, wherein the preset number of rows matches the processor; performing a merging operation on the preset number of rows of pixels to obtain a single row of pixels; storing the single row of pixels as a single column of pixels in a memory; and obtaining multiple columns of pixels stored in the memory to obtain a rotated image corresponding to the original image.
[0160] Optionally, the computer-readable storage medium is also configured to store program code for executing the following steps: determining a loading instruction from an instruction set corresponding to the processor; using the loading instruction to sequentially read a row of pixels from the original image to obtain a preset number of rows of pixels.
[0161] Optionally, the computer-readable storage medium is also configured to store program code for executing the following steps: determining a merge operation instruction from an instruction set corresponding to the processor; using the merge operation instruction to sequentially merge pixel points at the same position in a preset number of rows of pixel points to obtain a single row of pixel points.
[0162] Optionally, the computer-readable storage medium is also configured to store program code for executing the following steps: determining a stride storage instruction from an instruction set corresponding to the processor; and using the stride storage instruction to store a single row of pixel points into a memory to obtain a single column of pixel points.
[0163] Optionally, the computer-readable storage medium is also configured to store program codes for performing the following steps: determining the rotation angle of the original image; determining a target storage direction based on the rotation angle; and storing a single row of pixels into a memory according to the target storage direction using a stride storage instruction to obtain a single column of pixels.
[0164] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: obtaining a memory access bit width of a processor; and determining a preset number of rows based on the memory access bit width.
[0165] Optionally, the computer-readable storage medium is also configured to store program code for performing the following steps: determining whether there are unread pixels in the original image; if there are no unread pixels in the original image, obtaining multiple columns of pixels stored in the memory to obtain a rotated image; if there are unread pixels in the original image, repeatedly performing the steps of reading a preset number of rows of pixels from the original image, merging the preset number of rows of pixels, and storing a single row of pixels as a single column of pixels in the memory.
[0166] Optionally, the computer-readable storage medium is also configured to store program code for performing the following steps: determining the number of rows of unread pixel points in the original image; when the number of rows of unread pixel points in the original image is greater than or equal to a preset number of rows, repeatedly performing the steps of reading a preset number of rows of pixel points from the original image, merging the preset number of rows of pixel points, and storing a single row of pixel points as a single column of pixel points in a memory; when the number of rows of unread pixel points is less than a preset number of rows, sequentially storing the unread pixel points in the memory as at least one column of pixel points.
[0167] Optionally, the computer-readable storage medium is also configured to store program code for executing the following steps: using a load instruction to sequentially read unread pixel points from the original image; using a stride storage instruction to sequentially store the unread pixel points into the memory to obtain at least one column of pixel points.
[0168] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: the processor adopts a reduced instruction set architecture.
[0169] By adopting the embodiment of the present application, a preset number of rows of pixels can be read from the original image, wherein the preset number of rows matches the processor, and the pixel points of the preset number of rows are merged to obtain a single row of pixels, and the single row of pixels is stored in the memory as a single column of pixels, and the multiple columns of pixels stored in the memory are obtained to obtain a rotated image corresponding to the original image, thereby improving the processing efficiency of image rotation. It is easy to notice that by loading the pixel points of the preset number of rows at the same time, the efficiency of reading pixels can be improved, and the pixel points of the preset number of rows read are merged, which widens the bit width when writing, and fully utilizes the memory access bit width of the processor, thereby reducing the write operation, and improving the speed of image rotation, thereby solving the technical problem of low processing efficiency of image rotation.
[0170] The embodiment of the present application further provides a computer program product. Optionally, in this embodiment, the computer program product may include a computer program, and the computer program implements the method provided in the embodiment when executed by a processor.
[0171] The embodiments of the present application also provide a computer program product. Optionally, the computer program product may include a non-volatile computer-readable storage medium, which may be used to store a computer program, and when the computer program is executed by a processor, the method provided in the embodiments is implemented.
[0172] The embodiment of the present application further provides a computer program. Optionally, in this embodiment, when the computer program is executed by a processor, the method provided in the above embodiment is implemented.
[0173] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0174] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0175] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, 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 through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0176] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0177] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0178] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0179] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. An image processing method, It is characterized in that Applicable to processors, including: Reading a preset number of rows of pixels from the original image, wherein the preset number of rows matches the processor; Performing a merging operation on the preset number of rows of pixel points to obtain a single row of pixel points; Storing the single row of pixels as a single column of pixels in a memory; A plurality of columns of pixel points stored in the memory are obtained to obtain a rotated image corresponding to the original image.
2. The method according to claim 1, It is characterized in that The step of reading a preset number of rows of pixels from the original image comprises: Determine a load instruction from an instruction set corresponding to the processor; The loading instruction is used to sequentially read a row of pixel points from the original image to obtain the preset number of pixel points in the row.
3. The method according to claim 1, It is characterized in that The step of merging the preset number of rows of pixels to obtain a single row of pixels includes: Determine a merge operation instruction from an instruction set corresponding to the processor; The pixel points at the same position in the preset number of rows of pixel points are sequentially merged using the merge operation instruction to obtain the single row of pixel points.
4. The method according to claim 1, It is characterized in that The storing the single row of pixel points into a single column of pixel points in the memory includes: Determining a stride store instruction from an instruction set corresponding to the processor; The single row of pixels is stored in the memory using the stride storage instruction to obtain the single column of pixels.
5. The method according to claim 4, It is characterized in that The step of storing the single row of pixel points into the memory using the stride storage instruction to obtain the single column of pixel points includes: Determining a rotation angle of the original image; Based on the rotation angle, determining a target storage direction; The single row of pixel points is stored in the memory according to the target storage direction using the stride storage instruction to obtain the single column of pixel points.
6. The method according to claim 1, It is characterized in that Before reading a preset number of rows of pixels from the original image, the method further includes: Obtaining a memory access bit width of the processor; The preset number of rows is determined based on the memory access bit width.
7. The method according to claim 1, It is characterized in that After storing the single row of pixels as a single column of pixels in the memory, the method further includes: Determine whether there are any unread pixels in the original image; In the case that the unread pixel points do not exist in the original image, acquiring the multiple columns of pixel points stored in the memory to obtain the rotated image; In the case where the unread pixels exist in the original image, the steps of reading the preset number of rows of pixels from the original image, merging the preset number of rows of pixels, and storing the single row of pixels in the memory as the single column of pixels are repeatedly performed.
8. The method according to claim 7, It is characterized in that In the case where the unread pixel points exist in the original image, the method further includes: Determine the number of rows of the unread pixels in the original image; When the number of rows of the unread pixel points in the original image is greater than or equal to the preset number of rows, repeatedly performing the steps of reading the preset number of rows of pixel points from the original image, merging the preset number of rows of pixel points, and storing the single row of pixel points as the single column of pixel points in the memory; When the number of rows of the unread pixel points is less than the preset number of rows, the unread pixel points are sequentially stored in the memory as at least one column of pixel points.
9. The method according to claim 8, It is characterized in that The step of sequentially storing the unread pixels in the memory into at least one column of pixels includes: Using a load instruction, sequentially read the unread pixels from the original image; The unread pixel points are sequentially stored in the memory using a stride storage instruction to obtain at least one column of pixel points.
10. The method according to any one of claims 1 to 9, It is characterized in that The processor adopts a reduced instruction set architecture.
11. A processor, It is characterized in that include: Memory, used to store pixels in the original image; A processing unit is connected to the memory, and is used to read a preset number of rows of pixels from the original image, merge the preset number of rows of pixels to obtain a single row of pixels, store the single row of pixels as a single column of pixels in the memory, obtain multiple columns of pixels stored in the memory, and obtain a rotated image corresponding to the original image, wherein the preset number of rows matches the processor.
12. A system on a chip, It is characterized in that include: A storage device, used for storing pixels in the original image; A processor is connected to the storage device and is used to read a preset number of rows of pixels from the original image, merge the preset number of rows of pixels to obtain a single row of pixels, store the single row of pixels as a single column of pixels in the storage device, obtain multiple columns of pixels stored in the storage device, and obtain a rotated image corresponding to the original image, wherein the preset number of rows matches the processor.
13. An electronic device, It is characterized in that include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 10 when running.
14. A computer-readable storage medium, It is characterized in that The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 10.
15. A computer program product, It is characterized in that It comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 10.
Citation Information
Cited By
Image warping processing system and method, image display device, and storage medium
WO2026145686A1
