CN117853495A - DMA-based arbitrary resolution image clipping method - Google Patents
DMA-based arbitrary resolution image clipping method Download PDFInfo
- Publication number
- CN117853495A CN117853495A CN202311743063.1A CN202311743063A CN117853495A CN 117853495 A CN117853495 A CN 117853495A CN 202311743063 A CN202311743063 A CN 202311743063A CN 117853495 A CN117853495 A CN 117853495A
- Authority
- CN
- China
- Prior art keywords
- image
- dma
- coordinate
- clipping
- starting
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 27
- 238000010586 diagram Methods 0.000 description 2
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/14—Handling requests for interconnection or transfer
- G06F13/20—Handling requests for interconnection or transfer for access to input/output bus
- G06F13/28—Handling requests for interconnection or transfer for access to input/output bus using burst mode transfer, e.g. direct memory access DMA, cycle steal
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20112—Image segmentation details
- G06T2207/20132—Image cropping
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Image Input (AREA)
Abstract
The invention relates to a method for clipping an image with any resolution based on DMA. The invention comprises the following steps: 1) Reading resolution information of the whole image; the method comprises the steps of the size of the whole image, the image clipping starting x coordinate, the image clipping starting y coordinate, the image clipping stopping x coordinate, the image clipping stopping y coordinate, a DMA source address and a destination address; 2) Calculating the size of the row occupation storage of the original image according to the image format configured by the register; calculating the data length of each line of the DMA, the next DMA starting address and how many lines of data are required to be carried by the DMA according to the values of the image cutting starting x coordinate, the image cutting starting y coordinate, the image cutting stopping x coordinate and the image cutting stopping y coordinate; 3) Calculating the starting address of each line of the cut image according to the starting coordinate and the stopping coordinate of the cut image; 4) A DMA transfer operation is initiated once per line, and the operation is cycled until all lines are transferred. The invention cuts the large-resolution image by using the DMA technology, effectively improves the performance of the processor, reduces the power consumption, and can improve the bandwidth utilization rate of the bus and the external memory.
Description
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a random resolution image clipping method based on DMA.
Background
For a large image, conventional image cropping is performed by a processor or other means, and then transferred to a corresponding storage space by a DMA (direct memory access) method or the like, so that the working efficiency is low.
Disclosure of Invention
The invention aims to solve the technical problems in the background art, and provides a method for clipping an image with any resolution based on DMA, which can release a processor to a certain extent and reduce time expenditure.
The technical scheme of the invention is as follows: the image clipping method based on DMA with arbitrary resolution is characterized in that: the method comprises the following steps:
1) Reading resolution information of the whole image; the method comprises the steps of the size of the whole image, the image clipping starting x coordinate, the image clipping starting y coordinate, the image clipping stopping x coordinate, the image clipping stopping y coordinate, a DMA source address and a destination address;
2) Calculating the size of the row occupation storage of the original image according to the image format configured by the register;
calculating the data length of each line of the DMA, the next DMA starting address and how many lines of data are required to be carried by the DMA according to the values of the image cutting starting x coordinate, the image cutting starting y coordinate, the image cutting stopping x coordinate and the image cutting stopping y coordinate;
3) Calculating the starting address of each line of the cut image according to the starting coordinate and the stopping coordinate of the cut image;
4) A DMA transfer operation is initiated once per line, and the operation is cycled until all lines are transferred.
Further, in step 1), when the resolution of the current image is greater than the image requirement, clipping is performed.
Further, the image format in step 2) includes a width W of a pixel, a channel number C of each pixel, and a bit width P of each pixel channel.
Further, the specific steps of the step 2) are as follows:
2.1 The source address register configuration value of the DMA is the image clipping starting x coordinate, and the destination address register configuration value of the DMA is the expected memory address, namely the local memory address;
2.2 The data length of each DMA is calculated by the values of the image clipping start x coordinate and the image clipping stop x coordinate.
Further, the specific steps of the step 3) are as follows:
3.1 Calculating the source address of the next DMA according to the image clipping starting x coordinate and the value of the data length of each time of DMA movement, and storing the value of the source address into a DMA source address register;
3.2 Calculating the destination address of the next DMA according to the value in the destination address register of the DMA and the value of the data length of each movement of the DMA, and storing the value of the destination address into the destination address register of the DMA.
Further, in the step 3), the x coordinate and the y coordinate of the image clipping start coordinate and the x coordinate and the y coordinate of the image clipping stop coordinate are smaller than or equal to the row resolution and the column resolution of the whole image; and the image cropping start coordinates should be less than or equal to the stop coordinates.
Further, the specific steps of the step 4) are as follows:
4.1 Reading the value of the DMA interrupt state register to judge whether the current DMA is completed or not, and starting the next DMA if the current DMA is completed;
4.2 And executing the steps circularly until the image cutting start y coordinate value is greater than the image cutting stop y coordinate value, and finishing all cutting image data by the DMA.
Furthermore, in step 4), only one line of data of the clipping image is operated by DMA each time, and the transportation of all clipping data is realized by starting DMA for multiple times.
Further, step 4) is followed by step 5) DMA completing clipping of the image and storing the data of the clipped image in a local memory, and finally processing by a processor.
The invention has the advantages that: according to the random resolution image clipping method based on the DMA, the clipping process and the transmission process are simultaneously carried out by the DMA, the CPU is not required to carry out clipping operation, and the working efficiency is greatly improved.
Drawings
FIG. 1 is a schematic diagram of an image cropping method of the present invention;
FIG. 2 is a flow chart of the present invention;
fig. 3 is a structural diagram of the present invention.
Detailed Description
The technical scheme of the invention is further described in detail below with reference to the attached drawings and specific embodiments.
Referring to FIG. 1, the invention is embodied in a method for clipping an image of arbitrary resolution based on DMA, which is characterized in that the method comprises
1) Reading resolution information of the whole image;
2) Calculating the size of one line occupation storage of an original image according to the image format (the width W of pixels, the channel number C of each pixel and the bit width P of each pixel channel) configured by the register;
3) Calculating the starting address of each line of the cut image according to the starting coordinate and the stopping coordinate of the cut image;
4) A DMA transfer operation is initiated once per line, and the operation is cycled until all lines are transferred.
Referring to fig. 2 and 3, the steps of a specific embodiment of the method for clipping an image with arbitrary resolution based on DMA provided by the invention are as follows:
1) The images are continuously stored in a remote memory and are stored in a pixel storage mode;
2) The DMA reads the data of the whole image from the memory, wherein the data comprises a base address, an image clipping starting x coordinate, an image clipping starting y coordinate, an image clipping stopping x coordinate and an image clipping stopping y coordinate which are stored in the memory.
3) The source address register configuration value of the DMA is the image clipping starting x coordinate, and the destination address register configuration value of the DMA is the expected memory address, namely the local memory address;
4) Calculating the data length of each moving of the DMA according to the values of the image cutting start x coordinate and the image cutting stop x coordinate;
5) Calculating the source address of the next DMA according to the image clipping starting x coordinate and the value of the data length of each DMA movement, and storing the value of the source address into a DMA source address register;
6) Calculating the destination address of the next DMA according to the value in the destination address register of the DMA and the value of the data length of each time of the DMA, and storing the value of the destination address into the destination address register of the DMA;
7) Reading the value of the DMA interrupt state register to judge whether the current DMA is completed or not, and starting the next DMA if the current DMA is completed;
8) Circularly executing the steps until the image cutting start y coordinate value is greater than the image cutting stop y coordinate value, and finishing all cutting image data by the DMA;
9) And finishing cutting the image by the DMA, storing the data of the cut image into a local memory, and finally processing by a processor.
The technical matters not specifically described in the foregoing embodiments are the same as those in the prior art.
The above is only a specific embodiment disclosed in the present invention, but the scope of the present invention is not limited thereto, and the scope of the present invention should be defined by the claims.
Claims (9)
1. A method for clipping an image with any resolution based on DMA is characterized in that: the method comprises the following steps:
1) Reading resolution information of the whole image; the method comprises the steps of the size of the whole image, the image clipping starting x coordinate, the image clipping starting y coordinate, the image clipping stopping x coordinate, the image clipping stopping y coordinate, a DMA source address and a destination address;
2) Calculating the size of the row occupation storage of the original image according to the image format configured by the register;
calculating the data length of each line of the DMA, the next DMA starting address and how many lines of data are required to be carried by the DMA according to the values of the image cutting starting x coordinate, the image cutting starting y coordinate, the image cutting stopping x coordinate and the image cutting stopping y coordinate;
3) Calculating the starting address of each line of the cut image according to the starting coordinate and the stopping coordinate of the cut image;
4) A DMA transfer operation is initiated once per line, and the operation is cycled until all lines are transferred.
2. The DMA-based arbitrary resolution image cropping method according to claim 1, wherein: and when the resolution of the current image in the step 1) is greater than the image requirement, cutting is carried out.
3. The DMA-based arbitrary resolution image cropping method according to claim 2, wherein: the image format in step 2) includes a width W of a pixel, a channel number C of each pixel, and a bit width P of each pixel channel.
4. A DMA-based arbitrary resolution image cropping method according to claim 3, characterized in that: the specific steps of the step 2) are as follows:
2.1 The source address register configuration value of the DMA is the image clipping starting x coordinate, and the destination address register configuration value of the DMA is the expected memory address, namely the local memory address;
2.2 The data length of each DMA is calculated by the values of the image clipping start x coordinate and the image clipping stop x coordinate.
5. The DMA-based arbitrary resolution image cropping method according to claim 4, wherein: the specific steps of the step 3) are as follows:
3.1 Calculating the source address of the next DMA according to the image clipping starting x coordinate and the value of the data length of each time of DMA movement, and storing the value of the source address into a DMA source address register;
3.2 Calculating the destination address of the next DMA according to the value in the destination address register of the DMA and the value of the data length of each movement of the DMA, and storing the value of the destination address into the destination address register of the DMA.
6. The DMA-based arbitrary resolution image cropping method according to claim 1, wherein: the x coordinate and the y coordinate of the image clipping start coordinate and the x coordinate and the y coordinate of the image clipping stop coordinate in the step 3) are smaller than or equal to the row resolution and the column resolution of the whole image; and the image cropping start coordinates should be less than or equal to the stop coordinates.
7. The DMA-based arbitrary resolution image cropping method according to claim 5, wherein: the specific steps of the step 4) are as follows:
4.1 Reading the value of the DMA interrupt state register to judge whether the current DMA is completed or not, and starting the next DMA if the current DMA is completed;
4.2 And executing the steps circularly until the image cutting start y coordinate value is greater than the image cutting stop y coordinate value, and finishing all cutting image data by the DMA.
8. The DMA-based arbitrary resolution image cropping method according to claim 1, wherein: and 4) performing DMA operation on only one line of data of the clipping image each time, and carrying all clipping data by starting the DMA for multiple times.
9. The DMA-based arbitrary resolution image cropping method according to any one of claims 1 to 8, wherein: and step 5) finishing the clipping of the image by DMA, placing the data of the clipped image in a local memory, and finally processing by a processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311743063.1A CN117853495A (en) | 2023-12-18 | 2023-12-18 | DMA-based arbitrary resolution image clipping method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311743063.1A CN117853495A (en) | 2023-12-18 | 2023-12-18 | DMA-based arbitrary resolution image clipping method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117853495A true CN117853495A (en) | 2024-04-09 |
Family
ID=90542808
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311743063.1A Pending CN117853495A (en) | 2023-12-18 | 2023-12-18 | DMA-based arbitrary resolution image clipping method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117853495A (en) |
-
2023
- 2023-12-18 CN CN202311743063.1A patent/CN117853495A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11593594B2 (en) | Data processing method and apparatus for convolutional neural network | |
CN108520489B (en) | Device and method for realizing command analysis and vertex acquisition parallel in GPU | |
CN108171662B (en) | Method for reading image compression data and anti-distortion method comprising same | |
US20080049045A1 (en) | Image scaling system capable of saving memory | |
CN101794566A (en) | Method and related device for determining font data of character to be displayed in mobile terminal | |
CN113573072B (en) | Image processing method and device and related components | |
CN108563519B (en) | Realization of 2D desktop block copy filling operation based on GPGPU | |
CN117217274B (en) | Vector processor, neural network accelerator, chip and electronic equipment | |
CN101211416B (en) | Boundary creation method, system and production method during vector graph grating | |
CN117853495A (en) | DMA-based arbitrary resolution image clipping method | |
US6771271B2 (en) | Apparatus and method of processing image data | |
CN110322388B (en) | Pooling method and apparatus, pooling system, and computer-readable storage medium | |
CN116166185A (en) | Caching method, image transmission method, electronic device and storage medium | |
US11055903B2 (en) | Anti-aliasing graphic processing method, system, storage medium and apparatus | |
CN116958375A (en) | Graphics processor, system, apparatus, device, and method | |
CN107610035B (en) | Method and system for processing image | |
US20090174722A1 (en) | Method for assisting in data calculation by using display card | |
CN100585632C (en) | Pattern engine device and data processing method thereof | |
CN111311471A (en) | Batch picture segmentation, scheduling, processing and synthesizing system and method based on FPGA (field programmable Gate array) calculation | |
CN111028140B (en) | Method for realizing rectangular scaling and overturning of GPU pixels | |
CN115936101A (en) | Sparse data compression device and method for neural network tensor processor | |
CN102682419B (en) | Method and device for generating dynamic segment comparison table for vector graphics | |
CN111243038B (en) | Graphic comparison method and device based on color characteristics and computer storage medium | |
CN116187385A (en) | Sparse data computing device and method for neural network tensor processor | |
CN118052688A (en) | Image data processing method and related device |
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 |