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

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

Info

Publication number
CN112511765B
CN112511765B CN202011090113.7A CN202011090113A CN112511765B CN 112511765 B CN112511765 B CN 112511765B CN 202011090113 A CN202011090113 A CN 202011090113A CN 112511765 B CN112511765 B CN 112511765B
Authority
CN
China
Prior art keywords
image
rotation
data
initial
preset
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.)
Active
Application number
CN202011090113.7A
Other languages
Chinese (zh)
Other versions
CN112511765A (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: 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 image is rotated by carrying out vector calculation operations such as transposition, mapping and the like on the image data in the DSP, the vector calculation advantage of the DSP is fully utilized, the operation time consumed by carrying out rotation operation on 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, frame clamping and the like are avoided.

Description

Image rotation method and device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an image rotation method, an image rotation device, a storage medium, and an electronic device.
Background
At present, functions of terminal equipment are more and more perfect, the situation of processing images by using a mobile phone is also very common, and image rotation is one of the applications of image processing. At present, matrix rotation operation involved in image rotation of terminal equipment is mainly completed on a CPU (central processing unit) by a C language traversal method, and the image rotation is performed by the method, so that the number of times of program circulation is large, the calculated amount is large, the efficiency is low, and the results of frame dropping, frame clamping and the like affecting the user experience can be possibly 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 image rotation can be completed by carrying out vector calculation operations such as transposition, mapping and the like on image data in a DSP, the vector calculation advantage of the DSP is fully utilized, and the operation time is short, the power consumption is low and the efficiency is high. The technical scheme is as follows:
in a first aspect, an embodiment of the present application provides an image rotation method, including:
acquiring an initial image;
performing transposition processing on the image data of the initial image to obtain a preprocessed image;
and mapping the image data of the preprocessed image into a memory according to the rotation mapping relation, and generating a rotation image corresponding to the initial image.
In a second aspect, embodiments of the present application provide an image rotation apparatus, including:
the image acquisition module is used for acquiring an initial image;
the preprocessing module is used for performing transposition processing on 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 the memory according to the rotation mapping relation and generating 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-described method steps.
In a fourth aspect, embodiments of the present application provide 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 technical scheme provided by some embodiments of the present application has the beneficial effects that at least includes:
in one or more embodiments of the present application, an initial image is obtained, and 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 rotation image corresponding to the initial image can be generated. The image is rotated by carrying out vector calculation operations such as transposition, mapping and the like on the image data in the DSP, the vector calculation advantages of the DSP are fully utilized, 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, frame clamping and the like 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 that are required in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of an image rotation method according to an embodiment of the present application;
FIG. 2a is an exemplary schematic diagram of an image input interface provided by an embodiment of the present application;
FIG. 2b is an exemplary schematic diagram of a user interface provided in an embodiment of the present application;
FIG. 3 is a flowchart of another image rotation method according to an embodiment of the present disclosure;
FIG. 4a is an exemplary schematic diagram of an image block grouping provided in an embodiment of the present application;
FIG. 4b is an exemplary schematic diagram of a transpose process provided in accordance with embodiments of the present application;
FIG. 4c is an exemplary diagram of mapping according to a counterclockwise mapping table provided in an embodiment of the present application;
FIG. 4d is an exemplary diagram of a mapping according to a clockwise mapping table provided by embodiments of the present application;
fig. 5 is a schematic structural view of an image rotation device according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a preprocessing module according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a mapping module according to an embodiment of the present application;
fig. 8 is a schematic structural view of another image rotating apparatus according to 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 following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
In the description of the present application, it should 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 to be understood that the terms "comprise" and "have," and any variations thereof, are intended to cover non-exclusive inclusions, unless otherwise specifically defined and defined. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. The specific meaning of the terms in this application will be understood by those of ordinary skill in the art in a specific context. Furthermore, in the description of the present application, unless otherwise indicated, "a plurality" means two or more. "and/or", describes an association relationship of an association object, and indicates that there may be three relationships, for example, a and/or B, and may indicate: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship.
The present application is described in detail with reference to specific examples.
In one embodiment, as shown in fig. 1, a method of image rotation is proposed, which may be implemented in dependence on a computer program, and may be run on an image rotation device based on von neumann system. The computer program may be integrated in the application or may run as a stand-alone tool class application. The computer program may be integrated in the application or may run as a stand-alone tool class application. The image rotation apparatus in the embodiment of the present application may be a terminal device, including but not limited to: personal computers, tablet computers, handheld devices, vehicle mounted devices, wearable devices, computing devices, or other processing devices connected to a wireless modem, and the like. Terminal devices in different networks may be called different names, for example: a user equipment, an access terminal, a subscriber unit, a subscriber station, a mobile station, a remote terminal, a mobile device, a user terminal, a wireless communication device, a user agent or user equipment, a cellular telephone, a cordless telephone, a terminal device in a 5G network or a future evolution network, etc.
Specifically, the image rotation method includes:
s101, acquiring an initial image.
The initial image acquisition means that the terminal equipment acquires an image to be rotated. The initial image, which may be a digital image, is a bitmap made up of a matrix of pixels, produced by capturing the actual picture by an input device such as a scanner, camera, etc. Wherein the digital image describes the pixel points, intensities and colors numerically. The initial image may be input by the user at the terminal device, or may be read by the terminal device in a gallery or obtained by the terminal device from a network, etc.
Methods for the user to input the initial image include, but are not limited to, the following:
the method comprises the following steps: the user takes a photo by using a camera of the terminal device, and takes the photo as an initial image.
The second method is as follows: an image stored in the terminal device is added to the image processing interface as an initial image, and the image addition can be realized by clicking, selecting, dragging, or voice command, and the like, which is not limited herein. For example, as shown in fig. 2a, an interface diagram for adding an initial image is shown, 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 confirm the image as the initial image.
And a third method: and the user names the images, and the terminal equipment confirms the images with the corresponding names in the voice instruction as initial images through the voice instruction.
S102, performing transposition processing on the image data of the initial image to obtain a preprocessed image.
The transpose process is a process of calculating the transpose matrix of the initial image data on a digital signal processor (Digital Signal Processor, DSP) of the terminal device. Among them, DSP is efficient in operation and low in power consumption, and is 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 each group of read image line data;
when the last group of image line data is read, the preprocessing image is generated based on the transpose processing result of each group of image line data.
The preset line number can be set when the terminal equipment leaves the factory, or can be set on the terminal equipment by related technicians. The preset number of lines may be related to the number of bytes per line address, e.g., the preset number of lines may be divided by the number of bytes per line address.
And S103, 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.
The rotation mapping relation refers to a corresponding relation between an address in the preprocessed image and an address in the memory, so that the terminal equipment stores data in the preprocessed image address into the corresponding memory address. The mapping relationship 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 is a local memory Vector Tightly Coupled Memory (VTCM) supported by Hexagon Vector eXension (HVX), HVX is a processor in a high-pass computer DSP chip, and vector operation is supported, so that the data processing efficiency can be improved.
Optionally, the image data stored in the memory are sequentially read and stored, so that a rotation image corresponding to the initial image can be obtained and displayed.
Optionally, the user may select a direction and an angle of rotation processing on a picture editing interface corresponding to the terminal device, where 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, a schematic diagram of a user operation interface is shown, where if the user selects the second button below, the user selects to rotate the initial image by 90 ° counterclockwise, the terminal device selects to map the preprocessed image with a rotation mapping relationship rotated by 90 ° counterclockwise, and similarly, if the user selects the third button below, the terminal device selects to map the preprocessed image with a rotation mapping relationship rotated by 90 ° clockwise. The image may also be cropped if the user selects the first button.
In the embodiment of the application, an initial image is acquired, 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 relation, so that a rotation image corresponding to the initial image can be generated. The image is rotated by carrying out vector calculation operations such as transposition, mapping and the like on the image data in the DSP, the vector calculation advantages of the DSP are fully utilized, 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, frame clamping and the like are avoided.
Referring to fig. 3, fig. 3 is a flowchart illustrating another embodiment of an image rotation method according to the present application. Specific:
s201, acquiring an initial image.
See S101 for details, and are not described here again.
S202, judging whether the addresses of the initial images are aligned according to preset bytes.
The alignment according to the preset byte 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 integer multiple of the preset byte length, and the preset length can be set when the terminal device leaves the factory. Byte alignment can facilitate terminal equipment to access the data of the initial image aiming at the address of the initial image, and improves the access efficiency.
For example, the address of the initial image is 256 bytes, the preset byte is 128 bytes, 256 is an integer multiple of 128, and the address of the initial image is aligned according to the preset byte.
If the address of the initial image is not aligned according to the preset byte, executing S203; if the addresses of the initial images are aligned according to the preset bytes, S204 is executed.
And S203, 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 initial image into the aligned address.
The alignment process, that is, the terminal device changes the address of the initial image into a format aligned according to a preset byte, may be implemented by generating an address aligned according to a preset byte and storing the initial image in the address.
Optionally, the alignment processing may also be implemented by using padding bytes, so that the address of the initial image is aligned according to a preset byte.
S204, generating a rotation mapping relation based on the preset bytes.
The generating the rotation mapping relation based on the preset byte refers to generating the rotation mapping relation which is the same as the preset byte or is an integer multiple of the size of the preset byte according to the size of the preset byte.
For example, one possible rotation mapping relation is to generate a mapping table, where the preset bytes set in the terminal device are known to be 128 bytes, and the mapping table with the size of 128 bytes can be generated, that is, the mapping table can map data with the size of 128 bytes into the memory once, and multiplexing of the mapping table is realized by a method of moving the start pointer, so that repeated generation of the mapping table is not needed, and operation time is saved.
When the image needs to be rotated 90 ° counterclockwise, the mapping table may be:
Tbl[i]=(63-i)*w
when the image needs to be rotated 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 to be processed, i is an integer within the range of 0.ltoreq.i.ltoreq.63, w=128 is the size of a storage unit in the memory, 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 value, performing blocking processing on the initial image according to the preset image size to obtain at least one image block.
The preset threshold value is a preset critical value of the terminal device for judging whether to perform block processing on the initial image, if the storage space occupied by the initial image is larger than the preset threshold value, the terminal device performs block processing on the initial image, and if the storage space occupied by the initial image is smaller than or equal to the preset threshold value, the terminal device does not perform block 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 equipment for carrying out blocking processing, the terminal equipment blocks the initial image according to a format corresponding to the preset image size and divides the initial image 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 taken as an image block.
The preset threshold and the preset image size can be set when the terminal equipment leaves the factory, and also can be set on the terminal equipment by related technicians, the preset image size can also be set based on the preset threshold, and the image size corresponding to the preset image size can be the same as the preset threshold.
For example, the preset threshold set in the terminal device is 8KB, and the preset image size is set to be 64 bytes by 128 bytes based on the preset threshold, i.e. if the initial image is larger than 8KB, the terminal device will divide the preset image into several image blocks with a size of 64 bytes by 128 bytes.
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 the preset line number.
S206 refers to processing of dividing the image data of each image block into a plurality of sets of image line data according to a preset line number. The dividing the image line data into a plurality of groups according to the preset line number refers to that the terminal equipment uses the image data stored in the address of the preset line number in the initial image as one group of image line data according to the preset line number, and the preset line number can be set when the terminal equipment leaves the factory or can be set on the terminal equipment by related technicians.
For example, if the preset number of lines set in the terminal device is two, the terminal device uses the image data stored in each two line addresses as a set of image line data, the preset bytes are 128 bytes, as shown in fig. 4a, which is an image block, the blocks marked with A0, A1, etc. represent the image data stored in the addresses of one byte, one line is 128 bytes, and two lines A, B in the figure are the set of image line data confirmed by the terminal address.
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 transposed result in the next row.
The step of transposing the read target image line data column by column refers to transposing each column of the currently processed group of image line data, arranging the transposed columns according to the original sequence and filling 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 the image block after the image block in fig. 4a is transposed, the terminal device uses the bytes of two rows of A, B with the same reference numerals as a column and transposes them, for example, A0 and B0 are changed from the same column to the same row, the first row is filled with data of A0, B1, a..times., a63 and B63, and 128 bytes in total, and the preset byte set in the terminal device is 128, so that a64, B64, a..times., a127 and B127 are filled in the second row, and the rest of image line data of the image block is transposed according to the first set of image line data.
And S208, combining the image data of the image blocks after the transposition processing to obtain a preprocessed image.
And combining the transposed image blocks to generate an image, and confirming the image as a preprocessed image by the terminal equipment.
Alternatively, methods of obtaining the pre-processed image include, but are not limited to, the following:
the method comprises the following steps: and combining the transposed image blocks, confirming the combined image as a preprocessed image by the terminal equipment, and then carrying out subsequent processing on the preprocessed image.
The second method is as follows: the terminal equipment respectively confirms each image block as a preprocessing image and performs operations of S209 and S210, maps each transposed image block into a memory, combines the image blocks mapped into the memory and confirms the image block as an image, and the image is a rotating image corresponding to an initial image after being read, so that the aim of combining each transposed image block to obtain the preprocessing image is fulfilled.
And a third method: the terminal equipment respectively confirms each image block as a preprocessing image and performs subsequent processing, combines the image blocks subjected to the rotating operation in the steps of S209, S210, S211 and the like, generates a rotating image corresponding to the initial image, and achieves the aim of combining the image blocks after the transposition processing to obtain the preprocessing image.
S209, dividing the read target image row data into a plurality of groups of image column data according to a preset column number, sequentially reading each group of image column data, and mapping the image column data into a memory line by line according to a rotation mapping relation.
The preset column number is the same as the preset line number, and represents that a plurality of bytes exist in a segment after the image data segment is divided into a plurality of columns. The sequential reading refers to sequentially reading and mapping the sequence of each group of image column data according to byte sequence, and one feasible sequential reading method is as follows:
the terminal device moves the initial pointer corresponding to the mapping table row by row, as shown in fig. 4B, the initial pointer points to A0 and B0 in the first mapping, maps the image onto the memory according to the mapping table, and after the mapping is completed, points to the next row, namely a64 and B64, and moves in sequence until the last row.
For example, as shown in fig. 4c, which is a schematic diagram of mapping the image in fig. 4B to the memory, the preset column number set in the terminal device is 2, so there are two bytes in each set of image column data, the two bytes with the same symbol A, B in the figure are one segment, the rotation mapping relationship is a mapping table rotated by 90 ° counterclockwise in S204, the start pointer points to A0, B0, the 64 sets of images in the first row in fig. 4B are mapped to the corresponding positions as shown in fig. 4c according to the mapping table, then the start pointer is moved and points to a64, B64, and the image in the second row in fig. 4B is mapped to the corresponding positions as shown in fig. 4c, and the other bytes are mapped sequentially according to the above procedure until the last row.
Similarly, as shown in fig. 4d, the image in fig. 4b is mapped into the memory according to the mapping table of 90 ° clockwise in S204.
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.
When the read image data is the image line data of the last line, that is, all the images are mapped into the memory, the terminal equipment confirms the image mapped into the memory as a rotation image corresponding to the initial image.
S211, reading and storing the rotation image from the memory.
The terminal device reads and stores the rotation image once from the memory, the rotation image can be displayed on the terminal device, and a user can store the rotation image.
Optionally, the user may further save, forward or edit the rotated image through a terminal device.
Alternatively, if the user needs to perform an operation of rotating the initial image by 180 °, the terminal device automatically performs the above steps, and performs another 90 ° rotation operation in the same direction, thereby rotating the image by 180 °.
In the embodiment of the application, the initial image is acquired, the address of the initial image is aligned according to the preset byte, the access efficiency of the terminal equipment can be improved, the image larger than the preset threshold value is subjected to block processing, the complexity of operation can be reduced, the operation efficiency is improved, the block images are subjected to transposition processing and combination to obtain the preprocessed image, the preprocessed image is mapped into the memory according to the rotation mapping relation, the rotation image corresponding to the initial image can be generated, the rotation mapping relation is represented by the mapping table, the multiplexing of the mapping table is realized by moving the initial pointer without repeated generation, the time and the power consumption of the terminal equipment for processing the rotation operation are saved, the rotation of the image is completed by carrying out vector calculation operations such as transposition and mapping on the image data in the DSP, the vector calculation advantage of the DSP is fully utilized, the operation time consumed by carrying out the rotation operation on 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 blocking are avoided.
The following are device embodiments of the present application, which may be used to perform method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
Referring to fig. 5, a schematic structural diagram of an image rotation 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 by software, hardware or a combination of both. The apparatus 1 comprises an image acquisition module 11, a preprocessing module 12 and a mapping module 13.
An image acquisition module 11 for acquiring an initial image;
a preprocessing module 12, configured to transpose image data of the initial image to obtain a preprocessed image;
and the mapping module 13 is used for mapping the image data of the preprocessed image into the memory according to the rotation mapping relation, and generating a rotation image corresponding to the initial image.
Optionally, the apparatus 1 further includes:
the mapping relation generating module 14 is configured to generate a rotation mapping relation based on a preset byte if the addresses of the initial images are 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 into the aligned address;
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 transpose unit 122, configured to sequentially read each set of image line data, and transpose each set of read image line data;
a first image generation unit 123 for generating the preprocessed image based on the transpose processing result of each set of image line data when the last set of image line data is read.
Optionally, the transpose 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;
when the transposed data length reaches the preset byte, the target image line data is transposed column by column, and the transposed result is stored in the next line.
Optionally, as shown in fig. 7, the mapping module 13 includes:
a progressive mapping unit 131, configured to read the image line data of the preprocessed image line by line, and map the read target image line data into the memory according to the rotation mapping relationship;
the second image generating unit 132 is configured to generate, when image line data of a last line is read, a rotation image corresponding to the initial image based on a rotation mapping result of each of the image line data.
Optionally, the progressive mapping unit 131 is specifically configured to:
dividing the read target image row data into a plurality of groups of image row data according to a preset column number;
and sequentially reading each group of image column data, and mapping the image column data into the memory line by line according to the rotation mapping relation.
Optionally, the apparatus 1 further includes:
and the image blocking module 16 is configured to block the initial image according to a preset image size if the image size of the initial image is greater than a preset threshold value, so as to obtain at least one image block.
Optionally, the preprocessing module 12 includes:
a combining unit 121 configured to transpose image data of each of the at least one image block;
and combining the image data of each transposed image block to obtain a preprocessed image.
Optionally, the apparatus 1 further includes:
and the reading module 17 is used for reading and storing the rotation image from the memory.
As shown in fig. 8, another image rotating apparatus is schematically constructed.
In this embodiment, in one or more embodiments of the present application, an initial image is acquired, image data of the initial image is transposed to obtain a preprocessed image, and then image data of the preprocessed image is mapped into a memory according to a rotation mapping relationship, so that a rotation image corresponding to the initial image can be generated. The image is rotated by carrying out vector calculation operations such as transposition, mapping and the like on the image data in the DSP, the vector calculation advantages of the DSP are fully utilized, 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, frame clamping and the like are avoided.
It should be noted that, in the image rotation apparatus provided in the foregoing embodiment, when the image rotation method is executed, only the division of the foregoing functional modules is used as an example, in practical application, the foregoing functional allocation may be performed 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 functions described above. In addition, the image rotation apparatus provided in the above embodiment and the image rotation method embodiment belong to the same concept, which embody the implementation process in detail with respect to the method embodiment, and are not repeated here.
The foregoing embodiment numbers of the present application are merely for describing, and do not represent advantages or disadvantages of the embodiments.
The embodiment of the present application further provides a computer storage medium, where the computer storage medium may store a plurality of instructions, where the instructions are adapted to be loaded by a processor and execute the image rotation method according to the embodiment shown in fig. 1 to fig. 4d, and the specific execution process may refer to the specific description of the embodiment shown in fig. 1 to fig. 4d, which is not repeated herein.
The application further provides a computer program product, where at least one instruction is stored, where the at least one instruction is loaded by the processor and executed by the processor, where the specific execution process may refer to the specific description of the embodiment shown in fig. 1 to 4d, and details are not repeated herein.
Referring to fig. 9, a schematic structural diagram of an electronic device is provided in 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, a memory 1005, at least one communication bus 1002.
Wherein the communication bus 1002 is used to enable connected 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 further 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.
Wherein the processor 1001 may include one or more processing cores. The processor 1001 connects various parts within the entire 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 (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), programmable logic array (Programmable Logic Array, PLA). The processor 1001 may integrate one or a combination of several of a central processing unit (Central Processing Unit, CPU), an image processor (Graphics Processing Unit, GPU), and a modem, etc. 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 will be appreciated that the modem may not be integrated into the processor 1001 and may be implemented by a single chip.
The Memory 1005 may include a random access Memory (Random Access Memory, RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 1005 includes a non-transitory computer readable medium (non-transitory computer-readable storage medium). The memory 1005 may be used to store instructions, programs, code, sets of codes, or sets 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 above-described respective method embodiments, etc.; the storage data area may store data or the like referred to in the above respective method embodiments. The memory 1005 may also optionally be at least one storage device located remotely from the processor 1001. As shown in fig. 9, an operating system, a network communication module, a user interface module, and an image rotation application program may be included in the memory 1005, which is one type of computer storage medium.
In the electronic device 1000 shown in fig. 9, the user interface 1003 is mainly used for providing an input interface for a user, and acquiring data input by the user; and the processor 1001 may be configured to call an image rotation application program stored in the memory 1005, and specifically perform the following operations:
acquiring an initial image;
performing transposition processing on the image data of the initial image to obtain a preprocessed image;
and mapping the image data of the preprocessed image into a memory according to the rotation mapping relation, and generating a rotation image corresponding to the initial image.
In one embodiment, before performing the transpose process on the image data of the initial image, the processor 1001 further performs the following operations:
and if the addresses of the initial images are aligned according to preset bytes, generating a rotation mapping relation based on the preset bytes.
In one embodiment, before performing the transpose process on the image data of the initial 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 aligned address;
and generating a rotation mapping relation based on the preset bytes.
In one embodiment, the processor 1001 performs the following operations when performing the transpose process on the initial image to obtain a preprocessed image:
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 each group of read image line data;
when the last group of image line data is read, the preprocessing image is generated based on the transpose processing result of each group of image line data.
In one embodiment, the processor 1001, when executing the sequential reading of each set of image line data and performing the transpose processing on each set of read image line data, specifically executes the following operations:
sequentially reading each group of image line data, and transposing the read target image line data column by column;
when the transposed data length reaches the preset byte, the target image line data is transposed column by column, and the transposed result is stored in the next line.
In one embodiment, when the processor 1001 maps 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 processor specifically performs the following operations:
reading the 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 relation;
and 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.
In one embodiment, when the processor 1001 performs the line-by-line reading of the image line data of the preprocessed image, and maps the read target image line data into the memory according to the rotation mapping relationship, the following operations are specifically performed:
dividing the read target image row data into a plurality of groups of image row data according to a preset column number;
and sequentially reading each group of image column data, and mapping the image column data into the memory line by line according to the rotation mapping relation.
In one embodiment, before performing the transpose process on the image data of the initial image, the processor 1001 further performs the following operations:
and if the image size of the initial image is larger than a preset threshold value, performing block processing on the initial image according to the preset image size to obtain at least one image block.
In one embodiment, the processor 1001 performs the following operations when performing the transpose process on the image data of the initial image to obtain a preprocessed image:
transpose image data for each of the at least one image block;
and combining the image data of each transposed image block to obtain a preprocessed image.
In one embodiment, after executing the mapping of the image data of the preprocessed image into the memory according to the rotation mapping relationship, the processor 1001 further executes the following operations after generating the rotation image corresponding to the initial image:
and reading and storing the rotation 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 rotation image corresponding to the initial image can be generated. The image is rotated by carrying out vector calculation operations such as transposition, mapping and the like on the image data in the DSP, the vector calculation advantages of the DSP are fully utilized, 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, frame clamping and the like are avoided.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored on a computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory, a random access memory, or the like.
The foregoing disclosure is only illustrative of the preferred embodiments of the present application and is not intended to limit the scope of the claims herein, as the equivalent of the claims herein shall be construed to fall within the scope of the claims herein.

Claims (11)

1. A method of image rotation, the method comprising:
acquiring an initial image;
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 aligned address, or performing padding on the address, so that the address is aligned according to the preset byte;
generating a rotation mapping relation based on the preset bytes;
performing transposition processing on the 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 to generate a rotation image corresponding to the initial image;
the generating a rotation mapping relation based on the preset byte comprises the following steps:
based on the rotation angle and the rotation direction, a mapping table with the same size as the preset bytes or the same size as the preset bytes is generated, and the mapping table is multiplexed based on the movement of the initial pointer.
2. The method of claim 1, wherein the transpose of the image data of the initial image to obtain a preprocessed image further comprises:
and if the addresses of the initial images are aligned according to preset bytes, generating a rotation mapping relation based on the preset bytes.
3. The method of claim 1, wherein the transpose of 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 each group of read image line data;
when the last group of image line data is read, the preprocessing image is generated based on the transpose processing result of each group of image line data.
4. A method according to claim 3, wherein sequentially reading each set of image line data and transposing each set of read image line data comprises:
sequentially reading each group of image line data, and transposing the read target image line data column by column;
when the transposed data length reaches the preset byte, the target image line data is transposed column by column, and the transposed result is stored in the next line.
5. The method according to claim 1, wherein the mapping 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, includes:
reading the 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 relation;
and 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.
6. The method of claim 5, wherein the reading the image line data of the preprocessed image line by line, and mapping the read target image line data into the memory according to the rotation mapping relationship, comprises:
dividing the read target image row data into a plurality of groups of image row data according to a preset column number;
and sequentially reading each group of image column data, and mapping the image column data into the memory line by line according to the rotation mapping relation.
7. The method of claim 1, wherein the transpose of the image data of the initial image to obtain a preprocessed image further comprises:
if the image size of the initial image is larger than a preset threshold value, performing block processing on the initial image according to the preset image size to obtain at least one image block;
the step of performing transpose processing on the image data of the initial image to obtain a preprocessed image includes:
transpose image data for each of the at least one image block;
and combining the image data of each transposed image block to obtain a preprocessed image.
8. The method according to claim 1, wherein the mapping the image data of the preprocessed image to the memory according to the rotation mapping relationship, after generating the rotation image corresponding to the initial image, further comprises:
and reading and storing the rotation image from the memory.
9. An image rotation apparatus, the apparatus comprising:
the image acquisition module is used for acquiring an initial image;
the address alignment module is used for performing alignment processing on the address based on the preset byte if the address of the initial image is not aligned according to the preset byte, and storing the initial image into the aligned address or performing padding byte on the address so that the address is aligned according to the preset byte;
generating a rotation mapping relation based on the preset bytes;
the preprocessing module is used for performing transposition processing on the image data of the initial image to obtain a preprocessed image;
the mapping module is used for mapping the image data of the preprocessed image into a memory according to a rotation mapping relation to generate a rotation image corresponding to the initial image;
the generating a rotation mapping relation based on the preset byte comprises the following steps:
based on the rotation angle and the rotation direction, a mapping table with the same size as the preset bytes or the same size as the preset bytes is generated, and the mapping table is multiplexed based on the movement of the initial pointer.
10. A computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the method steps of any one of claims 1 to 8.
11. 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-8.
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 CN112511765A (en) 2021-03-16
CN112511765B true 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 (3)

* 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
CN107610047A (en) * 2017-08-02 2018-01-19 深圳市易成自动驾驶技术有限公司 Fragmental image processing method, apparatus and computer-readable recording medium
CN110874809A (en) * 2018-08-29 2020-03-10 上海商汤智能科技有限公司 Image processing method and device, electronic equipment and storage medium

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2411976B (en) * 2003-12-09 2006-07-19 Advanced Risc Mach Ltd A data processing apparatus and method for moving data between registers and memory
CN102555550B (en) * 2011-12-30 2014-04-16 浙江大学 High-speed image data rotation processing system and method for printing machine based on multi-core processor
RU2640298C1 (en) * 2015-10-12 2017-12-27 Общество С Ограниченной Ответственностью "Яндекс" Method for processing and storing images
CN107230183B (en) * 2016-03-24 2020-09-04 北大方正集团有限公司 Image rasterization processing method and device
CN108492243B (en) * 2018-04-13 2021-08-27 福州新迪微电子有限公司 Image rotation device, system and method based on block processing
CN110244933B (en) * 2019-06-17 2021-06-01 湘潭大学 Matrix transposition method based on CUDA
CN110415163A (en) * 2019-06-28 2019-11-05 中国科学院电子学研究所 Data matrix transposition method and device for SAR imaging

Patent Citations (3)

* 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
CN107610047A (en) * 2017-08-02 2018-01-19 深圳市易成自动驾驶技术有限公司 Fragmental image processing method, apparatus and computer-readable recording medium
CN110874809A (en) * 2018-08-29 2020-03-10 上海商汤智能科技有限公司 Image processing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN112511765A (en) 2021-03-16

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
CN110750664B (en) Picture display method and device
EP3163423A1 (en) Method and device for setting background of ui control and terminal
CN113469883B (en) Rendering method and device of dynamic resolution, electronic equipment and readable storage medium
CN108364324B (en) Image data processing method and device and electronic terminal
CN116128983A (en) Picture processing method and device and picture rendering method and device
CN113705156A (en) Character processing method and device
CN112991170B (en) Method, device, terminal and storage medium for reconstructing super-resolution image
EP4231243A1 (en) Data storage management method, object rendering method, and device
CN112511765B (en) Image rotation method and device, storage medium and electronic equipment
CN107564084B (en) Method and device for synthesizing motion picture and storage equipment
CN111476858B (en) WebGL-based 2d engine rendering method, device and equipment
CN107977923B (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN112634444B (en) Human body posture migration method and device based on three-dimensional information, storage medium and terminal
CN111325816B (en) Feature map processing method and device, storage medium and terminal
CN114693894A (en) Method, system and device for converting pictures into building blocks in virtual world
CN114697555A (en) Image processing method, device, equipment and storage medium
CN111489418A (en) Image processing method, device, equipment and computer readable storage medium
JP5842029B2 (en) Information processing support apparatus, information processing apparatus, and information processing support program for caching image data
CN111161135A (en) Picture conversion method and related product
CN114004195B (en) PDF file generation method and device, electronic equipment and computer storage medium
CN112087636B (en) Image coding processing method and device, storage medium and terminal
CN111754409B (en) Image processing method, device, equipment and storage 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