CN112511765A - Image rotation method, image rotation device, storage medium and electronic equipment - Google Patents

Image rotation method, image rotation device, storage medium and electronic equipment Download PDF

Info

Publication number
CN112511765A
CN112511765A CN202011090113.7A CN202011090113A CN112511765A CN 112511765 A CN112511765 A CN 112511765A CN 202011090113 A CN202011090113 A CN 202011090113A CN 112511765 A CN112511765 A CN 112511765A
Authority
CN
China
Prior art keywords
image
data
initial
rotation
mapping
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011090113.7A
Other languages
Chinese (zh)
Other versions
CN112511765B (en
Inventor
范辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Oppo Chongqing Intelligent Technology Co Ltd
Original Assignee
Oppo Chongqing Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo Chongqing Intelligent Technology Co Ltd filed Critical Oppo Chongqing Intelligent Technology Co Ltd
Priority to CN202011090113.7A priority Critical patent/CN112511765B/en
Publication of CN112511765A publication Critical patent/CN112511765A/en
Application granted granted Critical
Publication of CN112511765B publication Critical patent/CN112511765B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/222Studio circuitry; Studio devices; Studio equipment
    • H04N5/262Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
    • H04N5/2628Alteration of picture size, shape, position or orientation, e.g. zooming, rotation, rolling, perspective, translation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Editing Of Facsimile Originals (AREA)

Abstract

The embodiment of the application discloses an image rotation method, an image rotation device, a storage medium and electronic equipment, wherein the method comprises the following steps: the method comprises the steps of obtaining an initial image, performing transposition processing on image data of the initial image to obtain a preprocessed image, mapping the image data of the preprocessed image into a memory according to a rotation mapping relation, and generating a rotation image corresponding to the initial image. By adopting the embodiment of the application, the rotation of the image is completed by performing vector calculation operations such as transposition and mapping on the image data in the DSP, and the vector calculation advantages of the DSP are fully utilized, so that the operation time consumed by the rotation operation of the image is short, the power consumption is low, the efficiency is high, the use experience of a user is improved, and the situations such as frame dropping and frame clamping are avoided.

Description

Image rotation method, image rotation device, storage medium and electronic equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to an image rotation method and apparatus, a storage medium, and an electronic device.
Background
At present, the functions of terminal equipment are more and more perfect, the situation that images are processed by using a mobile phone is very common, and image rotation is an application of image processing. At present, matrix rotation operation involved in image rotation of terminal equipment is mainly completed on a CPU through a C language traversal method, image rotation is performed by the method, the number of program cycles is large, the calculation amount is large, the efficiency is low, and frame dropping, frame blocking and other results which influence user experience can be caused.
Disclosure of Invention
The embodiment of the application provides an image rotation method, an image rotation device, a storage medium and electronic equipment, wherein the image rotation can be completed by performing vector calculation operations such as transposition and mapping on image data in a DSP (digital signal processor), the vector calculation advantages of the DSP are fully utilized, and the image rotation method is short in operation time, low in power consumption and high in efficiency. The technical scheme is as follows:
in a first aspect, an embodiment of the present application provides an image rotation method, where the method includes:
acquiring an initial image;
transposing the image data of the initial image to obtain a preprocessed image;
and mapping the image data of the preprocessed image into an internal memory according to a rotation mapping relation to generate a rotation image corresponding to the initial image.
In a second aspect, an embodiment of the present application provides an image rotating apparatus, including:
the image acquisition module is used for acquiring an initial image;
the preprocessing module is used for transposing the image data of the initial image to obtain a preprocessed image;
and the mapping module is used for mapping the image data of the preprocessed image into an internal memory according to a rotation mapping relation to generate a rotation image corresponding to the initial image.
In a third aspect, embodiments of the present application provide a computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the above-mentioned method steps.
In a fourth aspect, an embodiment of the present application provides an electronic device, which may include: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the above-mentioned method steps.
The beneficial effects brought by the technical scheme provided by some embodiments of the application at least comprise:
in one or more embodiments of the present application, an initial image is obtained, the initial image is transposed to obtain a preprocessed image, and then the preprocessed image is mapped into a memory according to a rotation mapping relationship, so that a rotated image corresponding to the initial image can be generated. The image is rotated by performing vector calculation operations such as transposition and mapping on the image data in the DSP, and the vector calculation advantages of the DSP are fully utilized, so that the image rotation operation consumes short operation time, low power consumption and high efficiency, the use experience of a user is improved, and the situations such as frame dropping and frame clamping are avoided.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of an image rotation method provided in an embodiment of the present application;
FIG. 2a is a schematic diagram illustrating an example of an image input interface provided in an embodiment of the present application;
FIG. 2b is a schematic diagram illustrating an example of a user interface provided in an embodiment of the present application;
FIG. 3 is a schematic flowchart of another image rotation method provided in an embodiment of the present application;
FIG. 4a is a schematic diagram illustrating an example of grouping image blocks according to an embodiment of the present application;
fig. 4b is an exemplary diagram of a transpose process provided in an embodiment of the present application;
fig. 4c is an exemplary diagram of mapping according to a counterclockwise mapping table according to an embodiment of the present application;
fig. 4d is an exemplary diagram illustrating mapping according to a clockwise mapping table according to an embodiment of the present application;
FIG. 5 is a schematic structural diagram of an image rotating apparatus according to an embodiment of the present disclosure;
FIG. 6 is a schematic structural diagram of a preprocessing module provided in an embodiment of the present application;
fig. 7 is a schematic structural diagram of a mapping module according to an embodiment of the present disclosure;
FIG. 8 is a schematic structural diagram of another image rotating apparatus provided in an embodiment of the present application;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the description of the present application, it is to be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. In the description of the present application, it is noted that, unless explicitly stated or limited otherwise, "including" and "having" and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus. The specific meaning of the above terms in the present application can be understood in a specific case by those of ordinary skill in the art. Further, in the description of the present application, "a plurality" means two or more unless otherwise specified. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
The present application will be described in detail with reference to specific examples.
In one embodiment, as shown in fig. 1, an image rotation method is proposed, which can be implemented by means of a computer program and can be run on an image rotation device based on the von neumann architecture. The computer program may be integrated into the application or may run as a separate tool-like application. The computer program may be integrated into the application or may run as a separate tool-like application. The image rotating apparatus in the embodiment of the present application may be a terminal device, including but not limited to: personal computers, tablet computers, handheld devices, in-vehicle devices, wearable devices, computing devices or other processing devices connected to a wireless modem, and the like. The terminal devices in different networks may be called different names, for example: user equipment, access terminal, subscriber unit, subscriber station, mobile station, remote terminal, mobile device, user terminal, wireless communication device, user agent or user equipment, cellular telephone, cordless telephone, terminal equipment in a 5G network or future evolution network, and the like.
Specifically, the image rotation method includes:
s101, acquiring an initial image.
The acquiring of the initial image refers to acquiring of an image to be rotated by the terminal device. The initial image, which may be a digital image, is an image generated by capturing an actual picture with an input device such as a scanner, camera, etc., and is a bitmap composed of a matrix of pixels. Wherein the digital image numerically describes the pixel points, intensities and colors. The initial image may be input by the user on the terminal device, or may be read by the terminal device in a gallery or obtained by the terminal device from a network.
The method for inputting the initial image by the user includes, but is not limited to, the following methods:
the method comprises the following steps: the user takes a photo by using a camera of the terminal equipment, and the photo is used as an initial image.
The second method comprises the following steps: adding an image stored in the terminal device as an initial image in the image processing interface, where the adding of the image may be realized by clicking, selecting, dragging, or a voice instruction, and the like, which is not limited herein. For example, as shown in fig. 2a, it is an interface diagram for adding an initial image, and a user may select an image in an album of a terminal device, select and drag the image to an area where the image is added, and the terminal device may identify the image as the initial image.
The third method comprises the following steps: and naming the images by the user, and enabling the terminal equipment to determine the images with the corresponding names in the voice instructions as initial images through the voice instructions.
S102, transposing the image data of the initial image to obtain a preprocessed image.
The transpose process is a process of calculating the initial image data transpose matrix on a Digital Signal Processor (DSP) of the terminal device. The DSP has high operation efficiency and low power consumption, and is more advantageous in processing vector data.
One possible transpose process is:
dividing the image data of the initial image into a plurality of groups of image line data according to a preset line number;
sequentially reading each group of image line data, and performing transposition processing on the read image line data;
and when the last group of image line data is read, generating the preprocessed image based on the transposition processing result of each group of image line data.
The preset number of lines may be already set when the terminal device leaves the factory, or may be set on the terminal device by a related technician. The predetermined number of rows may be related to the number of bytes per row address, e.g., the predetermined number of rows may be evenly divided by the number of bytes per row address.
S103, mapping the image data of the preprocessed image to an internal memory according to a rotation mapping relation, and generating a rotation image corresponding to the initial image.
The rotation mapping relationship refers to a corresponding relationship between an address in the preprocessed image and an address in a memory, so that the terminal device can store data in the address of the preprocessed image in the corresponding memory address. The mapping relation may be a mapping table, and the data in the address corresponding to the pointer is stored in the address calculated according to the mapping table.
The Memory refers to a local Memory Vector rightly Coupled Memory (VTCM) supported by Hexagon Vector eXension (HVX), HVX is a processor in a high-pass computer DSP chip, and supports Vector operation, so that the data processing efficiency can be improved.
Optionally, the image data stored in the memory is sequentially read and stored, and a rotated image corresponding to the initial image may be obtained and displayed.
Optionally, the user may select a direction and an angle of the rotation processing on a picture editing interface corresponding to the terminal device, and the terminal device may select a corresponding rotation mapping relationship according to different processing schemes selected by the user to map the preprocessed image, so as to obtain different rotated pictures. For example, as shown in fig. 2b, it is a schematic diagram of a user operation interface, if the user selects the second button below, which represents that the user selects to rotate the initial image by 90 ° counterclockwise, the terminal device will select the rotational mapping relationship rotated by 90 ° counterclockwise to map the preprocessed image, and likewise, if the user selects the third button below, the terminal device will select the rotational mapping relationship rotated by 90 ° clockwise to map the preprocessed image. The image may also be cropped if the user selects the first button.
In the embodiment of the present application, an initial image is obtained, image data of the initial image is transposed to obtain a preprocessed image, and then the image data of the preprocessed image is mapped into a memory according to a rotation mapping relationship, so that a rotated image corresponding to the initial image can be generated. The image is rotated by performing vector calculation operations such as transposition and mapping on the image data in the DSP, and the vector calculation advantages of the DSP are fully utilized, so that the image rotation operation consumes short operation time, low power consumption and high efficiency, the use experience of a user is improved, and the situations such as frame dropping and frame clamping are avoided.
Referring to fig. 3, fig. 3 is a schematic flowchart of another embodiment of an image rotation method according to the present application. Specifically, the method comprises the following steps:
s201, acquiring an initial image.
See S101 for details, which are not described herein.
S202, judging whether the address of the initial image is aligned according to preset bytes.
The aligning according to the preset bytes means whether the address length of the initial image can be divided by the preset byte length or whether the address length of the initial image is an integral multiple of the preset byte length, and the preset length can be set when the terminal device leaves a factory. Byte alignment can facilitate the terminal equipment to access the data of the initial image aiming at the address of the initial image, and the access efficiency is improved.
For example, if the address of the initial image is 256 bytes, the predetermined byte is 128 bytes, and 256 is an integer multiple of 128, the address of the initial image is aligned according to the predetermined byte.
If the address of the initial image is not aligned according to the preset byte, executing S203; if the address of the initial image is aligned according to the preset byte, S204 is executed.
S203, if the address of the initial image is not aligned according to the preset byte, the address is aligned based on the preset byte, and the initial image is stored in the aligned address.
The alignment processing means that the terminal device changes the address of the initial image into a format aligned according to a preset byte, and the alignment processing can be realized by generating an address aligned according to a preset byte and storing the initial image in the address.
Optionally, the alignment processing may also adopt a way of padding bytes, etc., so that the address of the initial image is aligned according to a preset byte.
And S204, generating a rotation mapping relation based on the preset bytes.
The step of generating the rotation mapping relationship based on the preset bytes refers to generating the rotation mapping relationship which is the same as the preset bytes or is integral multiple of the size of the preset bytes according to the size of the preset bytes.
For example, a possible rotational mapping relationship is to generate a mapping table, and knowing that a preset byte set in the terminal device is 128 bytes, a mapping table with a size of 128 bytes can be generated, that is, the mapping table can map data with a size of 128 bytes into a memory by one-time mapping, and the multiplexing of the mapping table is realized by moving a start pointer, and the mapping table does not need to be repeatedly generated, thereby saving the operation time.
When the image needs to be processed by rotating 90 ° counterclockwise, the mapping table may be:
Tbl[i]=(63-i)*w
when the image needs to be processed by rotating 90 ° counterclockwise, the mapping table may be:
Tbl[]=(i+1)*w-1
at this time, the value range of i is related to the preset byte and the preset line number, the corresponding preset byte value in the above formula is 128, the preset line number value is 2, the image is divided into 64 image segments for processing, i is an integer within the range of i being not less than 0 and not more than 63, w is 128, which is the size of a storage unit in the memory, and Tbl [ i ] is the corresponding storage address of the data in the ith image segment in the memory.
S205, if the image size of the initial image is larger than a preset threshold, blocking the initial image according to the preset image size to obtain at least one image block.
The preset threshold is a preset critical value used by the terminal device for judging whether to perform blocking processing on the initial image, if the storage space occupied by the initial image is larger than the preset threshold, the terminal device performs blocking processing on the initial image, and if the storage space occupied by the initial image is smaller than or equal to the preset threshold, the terminal device does not perform blocking processing on the initial image and can directly perform transposition processing on the image.
The preset image size refers to an image reference size used by the terminal device for blocking, the terminal device blocks the initial image according to a format corresponding to the preset image size, the initial image is divided into image blocks with the preset image size, and if the remaining part of the initial image is smaller than the preset image size, the remaining part is used as an image block.
The preset threshold value and the preset image size can be set when the terminal equipment leaves a factory, or can be set on the terminal equipment by related technical personnel, the preset image size can also be set based on the preset threshold value, and the image size corresponding to the preset image size can be the same as the preset threshold value.
For example, the preset threshold set in the terminal device is 8KB, and the preset image size is set to 64 bytes by 128 bytes based on the preset threshold, that is, if the initial image is larger than 8KB, the terminal device will divide the preset image into a number of image blocks with a size of 64 bytes by 128 bytes.
And S206, dividing the image data of each image block in the at least one image block into a plurality of groups of image line data according to a preset line number.
S206 is to divide the image data of each image block into a plurality of groups of image line data according to a preset number of lines. The dividing into a plurality of groups of image line data according to the preset line number means that the terminal device uses the image data stored in the address of the preset line number in the initial image as a group of image line data according to the preset line number, and the preset line number can be set when the terminal device leaves a factory or can be set on the terminal device by a related technician.
For example, if the preset number of lines set in the terminal device is two, the terminal device uses the image data stored in every two lines of addresses as a group of image line data, the preset byte is 128 bytes, as shown in fig. 4a, the preset byte is an image block, the blocks labeled as a0, a1, etc. represent the image data stored in one byte of address, and one line is 128 bytes, where A, B lines in the figure are the group of image line data confirmed by the terminal address.
And S207, sequentially reading each group of image line data, transposing the read target image line data column by column, transposing the target image line data column by column when the transposed data length reaches the preset byte, and storing the result obtained by the transposition into the next row.
The step of transposing the read target image line data column by column refers to transposing each column of a group of image line data currently processed, arranging the transposed columns according to the original sequence and filling the transposed columns into the same row, and when the length of one row reaches a preset byte, continuously filling the transposed columns into the next row according to the original sequence. For example, as shown in fig. 4B, for an image block after the image block in fig. 4a is transposed, the terminal device transposes A, B bytes of two rows with the same reference number as one column, for example, a0 and B0 change from the same column to the same row, the first row is filled with a0, B1, a.., a63, and B63, and a total of 128 bytes of data, the preset byte set in the terminal device is 128, and then a64, B64, a.., a127, and B127 are filled in the second row, and the remaining sets of image line data of the image block are transposed according to the first set of image line data.
And S208, combining the image data of each image block after the transposition processing to obtain a preprocessed image.
And combining the image blocks after the transposition processing to generate an image, and determining the image as a pre-processing image by the terminal equipment.
Optionally, the method of obtaining the pre-processed image includes, but is not limited to, the following methods:
the method comprises the following steps: and combining the image blocks after the conversion, determining the combined image as a preprocessed image by the terminal equipment, and then carrying out subsequent processing on the preprocessed image.
The second method comprises the following steps: the terminal equipment respectively confirms each image block as a preprocessed image, performs operations of S209 and S210, maps each image block after transposition into a memory, combines the image blocks mapped into the memory to confirm an image, and reads the image to obtain a rotating image corresponding to the initial image, so that the aim of combining each image block after transposition to obtain the preprocessed image is fulfilled.
The third method comprises the following steps: the terminal equipment respectively determines each image block as a preprocessed image and carries out subsequent processing, combines the image blocks which are subjected to the rotation operation in the steps of S209, S210, S211 and the like to generate a rotation image corresponding to the initial image, and achieves the purpose of combining the image blocks after the transposition processing to obtain the preprocessed image.
S209, dividing the read target image line data into a plurality of groups of image line data according to the preset number of lines, sequentially reading each group of image line data, and mapping the image line data to the memory line by line according to the rotary mapping relation.
The preset number of columns is the same as the preset number of rows, and represents that several bytes exist in a segment after the segment is divided into a plurality of column image data segments. The sequential reading means reading and mapping the sequence of each group of image column data in sequence according to the byte sequence, and a feasible sequential reading method is as follows:
the terminal device moves the start pointer corresponding to the mapping table line by line, as shown in fig. 4B, the start pointer points to a0 and B0 during the first mapping, the image is mapped to the memory according to the mapping table, and after the mapping is completed for one time, the start pointer points to the next line, i.e., a64 and B64, and the start pointer is moved to the last line in sequence.
For example, as shown in fig. 4c, which is a schematic diagram of mapping the image in fig. 4B into the memory, the preset number of columns set in the terminal device is 2, so that each group of image column data has two bytes, where A, B bytes with the same number in the diagram are a segment, the rotation mapping relationship is a mapping table in S204 rotated by 90 ° counterclockwise, the start pointer points to a0 and B0, 64 groups of images in the first row in fig. 4B are mapped to corresponding positions as shown in fig. 4c according to the mapping table, then the start pointer is moved and points to a64 and B64, the image in the second row in fig. 4B is mapped to corresponding positions as shown in fig. 4c, and other bytes are sequentially mapped according to the above process until the last row.
Similarly, as shown in fig. 4d, the result of mapping the image in fig. 4b into the memory according to the 90 ° clockwise mapping table in S204 is shown.
S210, when the image line data of the last line are read, generating a rotation image corresponding to the initial image based on the rotation mapping result of each image line data.
And when the read image data is the image line data of the last line, namely all the images are mapped into the memory, the terminal equipment determines the images mapped into the memory as the rotating images corresponding to the initial images.
And S211, reading and storing the rotating image from the memory.
The terminal device reads and stores the rotation image from the memory once, and the rotation image can be displayed on the terminal device and can be stored by a user.
Optionally, the user may also perform operations such as saving, forwarding, or editing again on the rotated image through the terminal device.
Optionally, if the user needs to perform an operation of rotating the initial image by 180 °, the terminal device may automatically perform the above steps to complete another 90 ° rotation operation in the same direction, so as to rotate the image by 180 °.
In the embodiment of the application, an initial image is obtained, the address of the initial image is aligned according to a preset byte, the access efficiency of the terminal device can be improved, the image which is larger than a preset threshold value is subjected to blocking processing, the complexity of operation can be reduced by the blocking processing of the image, the operation efficiency is improved, each blocking image is subjected to transposition processing and combination to obtain a preprocessed image, then the preprocessed image is mapped into a memory according to a rotation mapping relation, a rotation image corresponding to the initial image can be generated, the rotation mapping relation is represented by a mapping table, an initial pointer is moved to realize multiplexing of the mapping table without repeated generation, the time and power consumption of the terminal device for processing the rotation operation are saved, the rotation of the image is completed by vector calculation operations such as transposition and mapping on image data in a DSP, and the vector calculation advantages of the DSP are fully utilized, the image rotation method has the advantages that the calculation time consumed by image rotation operation is short, the power consumption is low, the efficiency is high, the use experience of a user is improved, and the situations of frame dropping, frame clamping and the like are avoided.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Referring to fig. 5, a schematic structural diagram of an image rotating apparatus according to an exemplary embodiment of the present application is shown. The image rotation means may be implemented as all or part of the apparatus in software, hardware or a combination of both. The apparatus 1 comprises an image acquisition module 11, a pre-processing module 12 and a mapping module 13.
An image acquisition module 11, configured to acquire an initial image;
a preprocessing module 12, configured to perform transposition processing on image data of the initial image to obtain a preprocessed image;
and the mapping module 13 is configured to map the image data of the preprocessed image into an internal memory according to a rotation mapping relationship, and generate a rotation image corresponding to the initial image.
Optionally, the apparatus 1 further includes:
and a mapping relationship generating module 14, configured to generate a rotation mapping relationship based on a preset byte if the address of the initial image is aligned according to the preset byte.
Optionally, the apparatus 1 further includes:
an address alignment module 15, configured to, if the address of the initial image is not aligned according to a preset byte, perform alignment processing on the address based on the preset byte, and store the initial image in the address after the alignment processing;
and generating a rotation mapping relation based on the preset bytes.
Optionally, as shown in fig. 6, the preprocessing module 12 includes:
a grouping unit 121, configured to divide the image data of the initial image into a plurality of groups of image line data according to a preset number of lines;
a transposing unit 122, configured to sequentially read each group of image line data, and perform transposing processing on the read groups of image line data;
a first image generating unit 123 configured to generate the preprocessed image based on the result of the transpose processing of each set of image line data when the last set of image line data is read.
Optionally, the transposing unit 122 is specifically configured to:
sequentially reading each group of image line data, and transposing the read target image line data column by column;
and when the data length after transposition reaches the preset byte, transposing the target image line data column by column, and storing the result obtained by transposition into the next line.
Optionally, as shown in fig. 7, the mapping module 13 includes:
a line-by-line mapping unit 131, configured to read image line data of the preprocessed image line by line, and map the read target image line data into an internal memory according to a rotational mapping relationship;
a second image generating unit 132, configured to generate a rotated image corresponding to the initial image based on a rotation mapping result of each image line data when the image line data of the last line is read.
Optionally, the progressive mapping unit 131 is specifically configured to:
dividing the read target image line data into a plurality of groups of image line data according to the preset number of lines;
and sequentially reading each group of image line data, and mapping the image line data to the memory line by line according to the rotary mapping relation.
Optionally, the apparatus 1 further includes:
and the image blocking module 16 is configured to, if the image size of the initial image is larger than a preset threshold, perform blocking processing on the initial image according to the preset image size to obtain at least one image block.
Optionally, the preprocessing module 12 includes:
a combining unit 121 configured to perform a transposition process on image data of each of the at least one image block;
and combining the image data of each image block after the transposition processing to obtain a preprocessed image.
Optionally, the apparatus 1 further includes:
and the reading module 17 is configured to read and store the rotated image from the memory.
Fig. 8 is a schematic view showing another structure of the image rotating apparatus.
In this embodiment, in one or more embodiments of the present application, an initial image is obtained, image data of the initial image is transposed to obtain a pre-processed image, and then the image data of the pre-processed image is mapped into a memory according to a rotation mapping relationship, so that a rotated image corresponding to the initial image can be generated. The image is rotated by performing vector calculation operations such as transposition and mapping on the image data in the DSP, and the vector calculation advantages of the DSP are fully utilized, so that the image rotation operation consumes short operation time, low power consumption and high efficiency, the use experience of a user is improved, and the situations such as frame dropping and frame clamping are avoided.
It should be noted that, when the image rotation apparatus provided in the foregoing embodiment executes the image rotation method, only the division of the above functional modules is taken as an example, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the above described functions. In addition, the image rotation apparatus and the image rotation method provided by the above embodiments belong to the same concept, and details of implementation processes thereof are referred to in the method embodiments and are not described herein again.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
An embodiment of the present application further provides a computer storage medium, where the computer storage medium may store a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the image rotation method according to the embodiment shown in fig. 1 to 4d, and a specific execution process may refer to specific descriptions of the embodiment shown in fig. 1 to 4d, which is not described herein again.
The present application further provides a computer program product, where at least one instruction is stored, and the at least one instruction is loaded by the processor and executes the image rotation method according to the embodiment shown in fig. 1 to 4d, where a specific execution process may refer to specific descriptions of the embodiment shown in fig. 1 to 4d, and is not described herein again.
Fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 9, the electronic device 1000 may include: at least one processor 1001, at least one network interface 1004, a user interface 1003, memory 1005, at least one communication bus 1002.
Wherein a communication bus 1002 is used to enable connective communication between these components.
The user interface 1003 may include a Display screen (Display) and a Camera (Camera), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), among others.
Processor 1001 may include one or more processing cores, among other things. The processor 1001 connects various parts throughout the server 1000 using various interfaces and lines, and performs various functions of the server 1000 and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 1005, and calling data stored in the memory 1005. Alternatively, the processor 1001 may be implemented in at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 1001 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the display screen; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 1001, but may be implemented by a single chip.
The Memory 1005 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 1005 includes a non-transitory computer-readable medium. The memory 1005 may be used to store an instruction, a program, code, a set of codes, or a set of instructions. The memory 1005 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, and the like; the storage data area may store data and the like referred to in the above respective method embodiments. The memory 1005 may optionally be at least one memory device located remotely from the processor 1001. As shown in fig. 9, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and an image rotation application program.
In the electronic device 1000 shown in fig. 9, the user interface 1003 is mainly used as an interface for providing input for a user, and acquiring data input by the user; and the processor 1001 may be configured to invoke an image rotation application stored in the memory 1005 and specifically perform the following operations:
acquiring an initial image;
transposing the image data of the initial image to obtain a preprocessed image;
and mapping the image data of the preprocessed image into an internal memory according to a rotation mapping relation to generate a rotation image corresponding to the initial image.
In one embodiment, before performing the transpose process on the image data of the initial image to obtain the pre-processed image, the processor 1001 further performs the following operations:
and if the address of the initial image is aligned according to a preset byte, generating a rotation mapping relation based on the preset byte.
In one embodiment, before performing the transpose process on the image data of the initial image to obtain the pre-processed image, the processor 1001 further performs the following operations:
if the address of the initial image is not aligned according to the preset byte, performing alignment processing on the address based on the preset byte, and storing the image data of the initial image into the address after the alignment processing;
and generating a rotation mapping relation based on the preset bytes.
In an embodiment, when performing the transpose processing on the initial image to obtain the pre-processed image, the processor 1001 specifically performs the following operations:
dividing the image data of the initial image into a plurality of groups of image line data according to a preset line number;
sequentially reading each group of image line data, and performing transposition processing on the read image line data;
and when the last group of image line data is read, generating the preprocessed image based on the transposition processing result of each group of image line data.
In one embodiment, when the processor 1001 sequentially reads each set of image line data and performs a transpose process on the read sets of image line data, the following operations are specifically performed:
sequentially reading each group of image line data, and transposing the read target image line data column by column;
and when the data length after transposition reaches the preset byte, transposing the target image line data column by column, and storing the result obtained by transposition into the next line.
In an embodiment, when the processor 1001 performs the mapping of the image data of the preprocessed image to the memory according to the rotation mapping relationship to generate the rotated image corresponding to the initial image, the following operations are specifically performed:
reading image line data of the preprocessed image line by line, and mapping the read target image line data to an internal memory according to a rotation mapping relation;
and when the image line data of the last line are read, generating a rotating image corresponding to the initial image based on the rotation mapping result of each image line data.
In an embodiment, when the processor 1001 executes reading image line data of the preprocessed image line by line and maps the read target image line data into the memory according to the rotation mapping relationship, the following operations are specifically executed:
dividing the read target image line data into a plurality of groups of image line data according to the preset number of lines;
and sequentially reading each group of image line data, and mapping the image line data to the memory line by line according to the rotary mapping relation.
In one embodiment, before performing the transpose process on the image data of the initial image to obtain the pre-processed image, the processor 1001 further performs the following operations:
and if the image size of the initial image is larger than a preset threshold, performing blocking processing on the initial image according to the preset image size to obtain at least one image block.
In an embodiment, when performing the transpose process on the image data of the initial image to obtain the pre-processed image, the processor 1001 specifically performs the following operations:
transposing image data of each image block of the at least one image block;
and combining the image data of each image block after the transposition processing to obtain a preprocessed image.
In an embodiment, after the processor 1001 performs mapping of the image data of the preprocessed image to the memory according to the rotation mapping relationship, and generates a rotated image corresponding to the initial image, the following operations are further performed:
and reading and storing the rotating image from the memory.
In this embodiment, an initial image is obtained, image data of the initial image is transposed to obtain a preprocessed image, and then the image data of the preprocessed image is mapped into a memory according to a rotation mapping relationship, so that a rotated image corresponding to the initial image can be generated. The image is rotated by performing vector calculation operations such as transposition and mapping on the image data in the DSP, and the vector calculation advantages of the DSP are fully utilized, so that the image rotation operation consumes short operation time, low power consumption and high efficiency, the use experience of a user is improved, and the situations such as frame dropping and frame clamping are avoided.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory or a random access memory.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present application and is not to be construed as limiting the scope of the present application, so that the present application is not limited thereto, and all equivalent variations and modifications can be made to the present application.

Claims (12)

1. An image rotation method, characterized in that the method comprises:
acquiring an initial image;
transposing the image data of the initial image to obtain a preprocessed image;
and mapping the image data of the preprocessed image into an internal memory according to a rotation mapping relation to generate a rotation image corresponding to the initial image.
2. The method according to claim 1, wherein before transposing the image data of the initial image to obtain the pre-processed image, the method further comprises:
and if the address of the initial image is aligned according to a preset byte, generating a rotation mapping relation based on the preset byte.
3. The method according to claim 1, wherein before transposing the image data of the initial image to obtain the pre-processed image, the method further comprises:
if the address of the initial image is not aligned according to the preset byte, performing alignment processing on the address based on the preset byte, and storing the image data of the initial image into the address after the alignment processing;
and generating a rotation mapping relation based on the preset bytes.
4. The method according to claim 1, wherein the transposing the image data of the initial image to obtain a preprocessed image comprises:
dividing the image data of the initial image into a plurality of groups of image line data according to a preset line number;
sequentially reading each group of image line data, and performing transposition processing on the read image line data;
and when the last group of image line data is read, generating the preprocessed image based on the transposition processing result of each group of image line data.
5. The method according to claim 4, wherein the sequentially reading each set of image line data and transposing the read sets of image line data comprises:
sequentially reading each group of image line data, and transposing the read target image line data column by column;
and when the data length after transposition reaches the preset byte, transposing the target image line data column by column, and storing the result obtained by transposition into the next line.
6. The method according to claim 1, wherein the mapping the image data of the preprocessed image into the memory according to the rotation mapping relationship to generate a rotated image corresponding to the initial image comprises:
reading image line data of the preprocessed image line by line, and mapping the read target image line data to an internal memory according to a rotation mapping relation;
and when the image line data of the last line are read, generating a rotating image corresponding to the initial image based on the rotation mapping result of each image line data.
7. The method according to claim 6, wherein the reading image line data of the preprocessed image line by line, and mapping the read target image line data into a memory according to a rotation mapping relationship comprises:
dividing the read target image line data into a plurality of groups of image line data according to the preset number of lines;
and sequentially reading each group of image line data, and mapping the image line data to the memory line by line according to the rotary mapping relation.
8. The method according to claim 1, wherein before transposing the image data of the initial image to obtain the pre-processed image, the method further comprises:
if the image size of the initial image is larger than a preset threshold, performing blocking processing on the initial image according to the preset image size to obtain at least one image block;
the transposing the image data of the initial image to obtain a preprocessed image includes:
transposing image data of each image block of the at least one image block;
and combining the image data of each image block after the transposition processing to obtain a preprocessed image.
9. The method according to claim 1, wherein after the mapping the image data of the preprocessed image to the memory according to the rotation mapping relationship and generating the rotated image corresponding to the initial image, further comprising:
and reading and storing the rotating image from the memory.
10. An image rotation apparatus, characterized in that the apparatus comprises:
the image acquisition module is used for acquiring an initial image;
the preprocessing module is used for transposing the image data of the initial image to obtain a preprocessed image;
and the mapping module is used for mapping the image data of the preprocessed image into an internal memory according to a rotation mapping relation to generate a rotation image corresponding to the initial image.
11. A computer storage medium, characterized in that it stores a plurality of instructions adapted to be loaded by a processor and to carry out the method steps according to any one of claims 1 to 9.
12. An electronic device, comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the method steps of any of claims 1 to 9.
CN202011090113.7A 2020-10-13 2020-10-13 Image rotation method and device, storage medium and electronic equipment Active CN112511765B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011090113.7A CN112511765B (en) 2020-10-13 2020-10-13 Image rotation method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011090113.7A CN112511765B (en) 2020-10-13 2020-10-13 Image rotation method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN112511765A true CN112511765A (en) 2021-03-16
CN112511765B CN112511765B (en) 2023-06-09

Family

ID=74953713

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011090113.7A Active CN112511765B (en) 2020-10-13 2020-10-13 Image rotation method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN112511765B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6075886A (en) * 1998-03-09 2000-06-13 Xerox Corporation Method and apparatus for reducing the complexity of color correction using subsampling
US20050125624A1 (en) * 2003-12-09 2005-06-09 Arm Limited Data processing apparatus and method for moving data between registers and memory
CN102555550A (en) * 2011-12-30 2012-07-11 浙江大学 High-speed image data rotation processing system and method for printing machine based on multi-core processor
US20170103286A1 (en) * 2015-10-12 2017-04-13 Yandex Europe Ag Method of processing and storing images
CN107230183A (en) * 2016-03-24 2017-10-03 北大方正集团有限公司 Image rasterization processing method and processing device
CN107610047A (en) * 2017-08-02 2018-01-19 深圳市易成自动驾驶技术有限公司 Fragmental image processing method, apparatus and computer-readable recording medium
CN108492243A (en) * 2018-04-13 2018-09-04 福州新迪微电子有限公司 It is a kind of based on block processing picture orbiting facility, system and method
CN110244933A (en) * 2019-06-17 2019-09-17 湘潭大学 A kind of matrix transposition method based on CUDA
CN110415163A (en) * 2019-06-28 2019-11-05 中国科学院电子学研究所 Data matrix transposition method and device for SAR imaging
CN110874809A (en) * 2018-08-29 2020-03-10 上海商汤智能科技有限公司 Image processing method and device, electronic equipment and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6075886A (en) * 1998-03-09 2000-06-13 Xerox Corporation Method and apparatus for reducing the complexity of color correction using subsampling
US20050125624A1 (en) * 2003-12-09 2005-06-09 Arm Limited Data processing apparatus and method for moving data between registers and memory
CN102555550A (en) * 2011-12-30 2012-07-11 浙江大学 High-speed image data rotation processing system and method for printing machine based on multi-core processor
US20170103286A1 (en) * 2015-10-12 2017-04-13 Yandex Europe Ag Method of processing and storing images
CN107230183A (en) * 2016-03-24 2017-10-03 北大方正集团有限公司 Image rasterization processing method and processing device
CN107610047A (en) * 2017-08-02 2018-01-19 深圳市易成自动驾驶技术有限公司 Fragmental image processing method, apparatus and computer-readable recording medium
CN108492243A (en) * 2018-04-13 2018-09-04 福州新迪微电子有限公司 It is a kind of based on block processing picture orbiting facility, system and method
CN110874809A (en) * 2018-08-29 2020-03-10 上海商汤智能科技有限公司 Image processing method and device, electronic equipment and storage medium
CN110244933A (en) * 2019-06-17 2019-09-17 湘潭大学 A kind of matrix transposition method based on CUDA
CN110415163A (en) * 2019-06-28 2019-11-05 中国科学院电子学研究所 Data matrix transposition method and device for SAR imaging

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
沈煌辉等: "面向图像转置和分块处理的一种高效内存访问策略", 《计算机研究与发展》 *
沈煌辉等: "面向图像转置和分块处理的一种高效内存访问策略", 《计算机研究与发展》, vol. 50, no. 1, 15 January 2013 (2013-01-15) *
王春明: "Delphi下图像快速转置算法的研究", 《包钢科技》 *
王春明: "Delphi下图像快速转置算法的研究", 《包钢科技》, no. 02, 25 April 2015 (2015-04-25) *

Also Published As

Publication number Publication date
CN112511765B (en) 2023-06-09

Similar Documents

Publication Publication Date Title
CN112102437B (en) Canvas-based radar map generation method and device, storage medium and terminal
CN110908762B (en) Dynamic wallpaper implementation method and device
CN111950056B (en) BIM display method and related equipment for building informatization model
EP3163423A1 (en) Method and device for setting background of ui control and terminal
JP2002328881A (en) Image processor, image processing method and portable video equipment
CN111984189B (en) Neural network computing device, data reading method, data storage method and related equipment
CN108495043A (en) Image processing method and relevant apparatus
CN110232665B (en) Maximum pooling method and device, computer equipment and storage medium
CN111476718A (en) Image amplification method and device, storage medium and terminal equipment
CN116128983A (en) Picture processing method and device and picture rendering method and device
CN113469883B (en) Rendering method and device of dynamic resolution, electronic equipment and readable storage medium
CN111476858B (en) WebGL-based 2d engine rendering method, device and equipment
CN112511765B (en) Image rotation method and device, storage medium and electronic equipment
CN108198125A (en) A kind of image processing method and device
CN112184538A (en) Image acceleration method, related device, equipment and storage medium
CN107977923B (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN114697555B (en) Image processing method, device, equipment and storage medium
EP4231243A1 (en) Data storage management method, object rendering method, and device
CN111325816B (en) Feature map processing method and device, storage medium and terminal
CN115129278A (en) Image display control method, system, readable storage medium and electronic device
CN112991170A (en) Method, device, terminal and storage medium for image super-resolution reconstruction
CN111161135B (en) Picture conversion method and related product
CN111722823A (en) Method and device for self-adapting screen resolution, storage medium and electronic equipment
CN108230229A (en) Image processing apparatus and image processing method
CN117573917B (en) Map picture intercepting method, system, electronic equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant