WO2022016927A1 - Image processing method and apparatus, terminal device, and storage medium - Google Patents

Image processing method and apparatus, terminal device, and storage medium Download PDF

Info

Publication number
WO2022016927A1
WO2022016927A1 PCT/CN2021/088428 CN2021088428W WO2022016927A1 WO 2022016927 A1 WO2022016927 A1 WO 2022016927A1 CN 2021088428 W CN2021088428 W CN 2021088428W WO 2022016927 A1 WO2022016927 A1 WO 2022016927A1
Authority
WO
WIPO (PCT)
Prior art keywords
source
pixel
target
image
target source
Prior art date
Application number
PCT/CN2021/088428
Other languages
French (fr)
Chinese (zh)
Inventor
蒋文
Original Assignee
深圳云天励飞技术股份有限公司
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 深圳云天励飞技术股份有限公司 filed Critical 深圳云天励飞技术股份有限公司
Publication of WO2022016927A1 publication Critical patent/WO2022016927A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/70Determining position or orientation of objects or cameras
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4007Scaling of whole images or parts thereof, e.g. expanding or contracting based on interpolation, e.g. bilinear interpolation

Definitions

  • the present application belongs to the field of computer technology, and in particular, relates to an image processing method, apparatus, terminal device and storage medium.
  • the pixel data of a plurality of source pixel points need to be read multiple times in order to determine the pixel data of one pixel point of the target image.
  • this way of reading pixel data is inefficient, thereby reducing the efficiency of image processing.
  • the embodiments of the present application provide an image processing method, an apparatus, a terminal device, and a storage medium, so as to solve the problem of how to improve the image processing efficiency in the prior art.
  • a first aspect of the embodiments of the present application provides an image processing method, including:
  • the pixel data of each target source pixel is obtained from different preset memories, wherein each of the preset memories stores a The source pixel point of the position type, the position type is determined according to the position information of the source pixel point in the source image;
  • An interpolation operation is performed according to the pixel data of each of the target source pixel points, and the target pixel data of the to-be-generated pixel point is determined.
  • a second aspect of the embodiments of the present application provides an image processing apparatus, including:
  • a target source pixel point determination unit configured to determine at least two adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image, where the target source pixel points are the source pixel points in the source image;
  • a pixel data acquisition unit configured to acquire pixel data of each of the target source pixels from different preset memories according to the position information of each of the target source pixels in the source image, wherein each of the target source pixels
  • the preset memories respectively store source pixels of a position type, and the position type is determined according to the position information of the source pixels in the source image;
  • the target pixel data determination unit is configured to perform interpolation operation according to the pixel data of each of the target source pixel points, and determine the target pixel data of the to-be-generated pixel point.
  • a third aspect of the embodiments of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, when the processor executes the computer program At the time, the terminal device is made to implement the steps of the image processing method.
  • a fourth aspect of the embodiments of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, enables a terminal device to perform image processing as described above steps of the method.
  • a fifth aspect of the embodiments of the present application provides a computer program product that, when the computer program product runs on a terminal device, causes the terminal device to execute the steps of the image processing method described in the first aspect.
  • the beneficial effects of the embodiments of the present application compared with the prior art are: in the embodiments of the present application, when the target pixel data of the pixels to be generated needs to be determined, the corresponding data can be obtained from different preset memories at one time.
  • the pixel data of multiple target source pixel points corresponding to the current pixel to be generated perform interpolation operation according to the read pixel data of the target source pixel to obtain the target pixel data of the pixel to be generated, that is, it can be read at one time.
  • the pixel data of multiple target source pixel points required for the interpolation operation without waiting to read the pixel data multiple times, so the reading efficiency of the pixel data can be improved, and the target pixel data of the pixel to be generated can be determined efficiently, Further, the image processing efficiency based on interpolation operation is improved.
  • FIG. 1 is a schematic diagram of an implementation flowchart of a first image processing method provided by an embodiment of the present application
  • FIG. 2 is a schematic diagram of a to-be-generated pixel point and two corresponding adjacent target source pixel points provided by an embodiment of the present application;
  • FIG. 3 is a schematic diagram of a to-be-generated pixel point and corresponding four adjacent target source pixel points provided by an embodiment of the present application;
  • FIG. 4 is a schematic diagram of an implementation flowchart of a second image processing method provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a storage process flow of pixel data of a source pixel point provided by an embodiment of the present application
  • FIG. 6 is a hardware architecture diagram of a bus control interface module provided by an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a bus data alignment provided by an embodiment of the present application.
  • FIG. 8 is a schematic diagram of a storage flow of pixel data of another source pixel point provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of a hardware architecture of an image processing apparatus provided by an embodiment of the present application.
  • FIG. 10 is a schematic diagram of an implementation flowchart of a third image processing method provided by an embodiment of the present application.
  • FIG. 11 is a schematic diagram of the architecture of an STN provided by an embodiment of the present application.
  • FIG. 12 is a schematic diagram of an image processing apparatus provided by an embodiment of the present application.
  • FIG. 13 is a schematic diagram of a terminal device provided by an embodiment of the present application.
  • the image processing methods in the embodiments of the present application are applied to application scenarios such as image transformation (such as image zoom-in transformation, image translation transformation, and image rotation transformation), image correction (that is, obtaining a target image according to distorted image correction).
  • image transformation such as image zoom-in transformation, image translation transformation, and image rotation transformation
  • image correction that is, obtaining a target image according to distorted image correction.
  • the target image to be generated image to be generated
  • the determined image processing method of the pixel data of each pixel to be generated is the key link.
  • the image processing method in the embodiment of the present application determines at least two adjacent source pixels corresponding to the pixels to be generated in the image to be generated, and then simultaneously obtains each source pixel from different preset memories at one time After the pixel data is generated, interpolation operation is performed to determine the target pixel data of the pixel points to be generated, which improves the image processing efficiency.
  • FIG. 1 shows a schematic flowchart of a first image processing method provided by an embodiment of the present application, and details are as follows:
  • At least two adjacent target source pixels corresponding to to-be-generated pixels in the to-be-generated image are determined, where the target source pixels are source pixels in the source image.
  • the pixels of the source image are called source pixels; the image to be generated has a certain mapping relationship with the source image, and according to the mapping relationship, the source corresponding to the pixels to be generated can be determined from the source image.
  • Pixel point, the source pixel point corresponding to the pixel point to be generated is called the target source pixel point.
  • the pixel data of the pixel to be generated is specifically determined according to the pixel data of at least two adjacent target source pixels in the source image.
  • the corresponding mapping coordinates of the pixel point to be generated in the source image are calculated; according to the mapping coordinates, two or more near the mapping coordinates are determined.
  • the adjacent source pixel points of are used as the target source pixel points corresponding to the pixel points to be generated.
  • the mapping relationship two adjacent target source pixel points, a target source pixel point A and a target source pixel point B corresponding to the pixel point A' to be generated, are determined.
  • the number of target source pixels corresponding to the to-be-generated pixels may be more than two.
  • the target source pixels corresponding to the to-be-generated pixels A′ include the source pixel A , B, C, D, the four target source pixels.
  • the pixel data may specifically be data used to express image content, such as grayscale values, RGB values, etc.
  • the pixel data of each source pixel of the source image is pre-stored in its corresponding preset memory.
  • each source pixel in the source image is divided into different position types, and each preset memory stores source pixels of one position type respectively.
  • the parity of the row position in which the position type is located and/or the parity of the column position in which the position type is located is determined.
  • step S101 determine the position type corresponding to each target source pixel corresponding to the pixel to be generated respectively; then, according to each target source pixel Determine the preset memory corresponding to each target source pixel; then, obtain the pixel data of each target source pixel from the corresponding preset memory according to the position information of each target source pixel. Since the pixel data of each target source pixel is stored in different preset memories, it can be acquired at one time and at the same time in the same clock cycle. That is, since the pixel data of the target source pixel is not stored in the same memory, there is no need to wait for the pixel data to be read one by one, but each preset memory can be read at one time to quickly acquire each target pixel data.
  • the preset memory includes an even-numbered column memory and an odd-numbered column memory, the even-numbered column memory is specially used to store the pixel data of the source pixel point of the even-numbered column type, and the odd-numbered column memory is specially used to store the pixel data of the source pixel point of the odd-numbered column type.
  • the position type corresponding to the target source pixel point A is an odd column position Type
  • the position type corresponding to the target source pixel point B is the even-numbered column position type.
  • the pixel data of the target source pixel point A is obtained from the odd-numbered column memory and the pixel of the target source pixel point B is obtained from the even-numbered column memory at the same time. data.
  • an interpolation operation is performed according to the pixel data of each of the target source pixel points, and the target pixel data of the to-be-generated pixel point is determined.
  • An interpolation operation is performed according to the pixel data of each target source pixel obtained at one time in step S102 to determine the target pixel data of the pixel to be generated.
  • the source pixel corresponding to the pixel A' to be generated includes the target source pixel A and the target source pixel B, then the target source After the pixel data of the pixel point A and the target source pixel point B, a one-dimensional interpolation operation (such as a unilinear interpolation operation) is performed to obtain the pixel data of the pixel point A' to be generated.
  • a one-dimensional interpolation operation such as a unilinear interpolation operation
  • the target source pixel corresponding to the pixel point A' to be generated includes four target source pixels A, B, C, and D, then specifically when the target source pixel is obtained.
  • a two-dimensional interpolation operation (for example, a bilinear interpolation operation) is performed to obtain the pixel data of the pixel point A' to be generated.
  • the target pixel data can be filled into the corresponding position in the image to be generated or buffered in the buffer, and then the current pixel to be generated can be used as the current target pixel data.
  • the adjacent next pixel (for example, a pixel located to the right of the pixel A' to be generated) is used as the next pixel to be generated, and returns to execute the steps S101 to S103 until each pixel in the image to be generated.
  • the corresponding pixel data has been determined for each point, that is, the data of the to-be-generated image has been generated, and a complete target image has been obtained.
  • step S101 further includes:
  • the pixel data of each source pixel in the source image is stored in a preset memory corresponding to the position type.
  • step S101 before step S101, it also includes a preprocessing step of acquiring a source image to store the pixel data of each source pixel in the source image in a preset memory, which is described in detail as follows:
  • each source pixel in the source image contains its own pixel data, that is, the source image contains complete image information, which can be used to express specific image content (such as portraits, landscapes, etc.) ).
  • the source image can be an image captured by a camera, or an image created by drawing software.
  • the pixel data of each source pixel is stored in each preset memory. Specifically, the position type of each source pixel is determined according to the position information of each source pixel, specifically determined according to the parity of the row position and/or the column position of the source pixel in the source image.
  • the position type includes an even row position type and an odd row position type
  • the corresponding preset memory includes an even row storage and an odd row storage; if the position type corresponding to the source pixel point is an even row position type (that is, the source pixel If the row number corresponding to the row position of the point is an even number), the pixel data of the source pixel point is stored in the even row memory; if the position type corresponding to the source pixel point is an odd row position type (that is, the source pixel point is located in The row sequence number corresponding to the row position is an odd number), the pixel data of the source pixel point is stored in the odd-numbered row memory.
  • the position type includes an even column position type and an odd column position type
  • the corresponding preset memory includes an even column memory and an odd column memory; if the position type corresponding to the source pixel point is an even column position type (that is, the source pixel If the column number corresponding to the column position of the point is an even number), the pixel data of the source pixel point is stored in the even column memory; if the position type corresponding to the source pixel point is an odd column position type (that is, the source pixel point is located in The column serial number corresponding to the column position is an odd number), then the pixel data of the source pixel point is stored in the odd-numbered column memory.
  • the source image is obtained first, and the pixel data of each source pixel is accurately stored in the location type of each source pixel.
  • the pixel data of each target source pixel point corresponding to the to-be-generated pixel point can be acquired from each preset memory at one time and accurately, thereby ensuring the accuracy of the target pixel data.
  • the pixel data of multiple target source pixels corresponding to the current pixel to be generated can be obtained from different preset memories at one time.
  • perform interpolation operation according to the read pixel data of the target source pixel to obtain the target pixel data of the pixel to be generated that is, the pixel data of multiple target source pixels required for the interpolation operation can be read at one time , without waiting for reading pixel data multiple times, so the reading efficiency of pixel data can be improved, the target pixel data of the pixel point to be generated can be efficiently determined, and the image processing efficiency based on interpolation operation can be improved.
  • FIG. 4 shows a schematic flowchart of a second image processing method provided by an embodiment of the present application, and details are as follows:
  • the image data of the pixels to be generated in the image to be generated is specifically determined according to the four target source pixels in the source image. Since the corresponding mapping coordinates of the pixels to be generated in the source image are generally non-integer, such as (1.6, 1.4), and in the source image, the source pixel whose coordinates are integers is the smallest unit, so the non-integer mapping coordinates Four surrounding source pixels (up, down, left, and right directions adjacent to each other) are determined as four adjacent target source pixels corresponding to the pixels to be generated. Exemplarily, if the mapping coordinates corresponding to the pixels to be generated are (1.6, 1.4), then the corresponding four adjacent target source pixels have coordinates (1, 1) and (1, 2) in the source image, respectively. ), (2,1), (2,2) of the four source pixels, such as the four target source pixels of A, B, C, and D shown in FIG. 3 .
  • the first preset memory, the second preset memory, the third preset memory and the fourth preset acquires the pixel data of each of the target source pixel points; wherein, the first preset memory is used to store the pixel data of the source pixel points whose row position serial numbers are even and column position serial numbers are even in the source image, so The second preset memory is used to store the pixel data of the source pixels whose row position serial numbers are even and the column position serial numbers are odd in the source image, and the third preset memory is used to store the row positions in the source image. The pixel data of the source pixels whose serial numbers are odd and the column position serial numbers are even, the fourth preset memory is used to store the pixel data of the source pixels whose row position serial numbers are odd and the column position serial numbers are odd in the source image .
  • the parity of the row position and the column position of the four adjacent target source pixels corresponding to the pixels to be generated are alternate, and each of the four adjacent target source pixels corresponds to a position.
  • Type the position type where the row position number and the column position number are even numbers (such as the target source pixel D shown in Figure 3), the position type where the row position number is even and the column position number is odd (such as the one shown in Figure 3)
  • the target source pixel point C) the position type whose row position number is odd and the column position number is even (for example, the target source pixel point B shown in Figure 3), and the position type whose row position number and column position number are odd (such as The target source pixel point A) shown in Figure 3.
  • the preset memory includes four memories: the first preset memory, the second preset memory, the third preset memory and the fourth preset memory, according to the position information of the four target source pixels in the source image.
  • the pixel data of the four target source pixels can be read from the four memories at one time.
  • the first preset memory is used to store pixel data of source pixels whose row position serial numbers are even and column position serial numbers are even in the source image
  • the second preset memory is used to store the even row position serial numbers and column position serial numbers in the source image.
  • the third preset memory is used to store the pixel data of the source pixel whose row position number is odd and the column position number is even in the source image
  • the fourth preset memory is used to store The pixel data of the source pixel points with odd row position numbers and odd column position numbers in the source image.
  • interpolation operation is performed according to the pixel data of each of the target source pixel points to determine the target pixel data of the to-be-generated pixel points
  • step S401 it also includes:
  • S4001 Acquire a source image, where each source pixel in the source image includes respective pixel data;
  • a source image is obtained, the pixel data of the source pixels in the source image are read line by line, and parity line selection is performed first (that is, according to the parity of the row position serial numbers corresponding to each source pixel point) Storage selection), divide the pixel data of the source pixel point into even-numbered row pixel data (that is, the pixel data whose row position serial number is an even number, such as row0 and row2 in Figure 5) and odd-numbered row pixel data (that is, the pixel data whose row position serial number is an odd number) , such as row1, row3 in Figure 5).
  • even-numbered row pixel data that is, the pixel data whose row position serial number is an even number, such as row0 and row2 in Figure 5
  • odd-numbered row pixel data that is, the pixel data whose row position serial number is an odd number
  • the even-numbered rows of pixel data are selected for parity columns (that is, the storage selection is performed according to the parity of the column position serial numbers corresponding to each source pixel point), and the even-numbered columns of pixel data in the even-numbered rows are obtained.
  • odd-numbered rows of pixel data are selected for odd-even columns (that is, storage selection is performed according to the parity of the column position serial numbers corresponding to each source pixel point), and the odd-numbered rows are obtained.
  • the pixel data of the even-numbered columns and the pixel data of the odd-numbered columns in the odd-numbered rows are correspondingly stored in the third preset memory and the fourth preset memory.
  • steps S4001-S4004 are performed through a bus control interface module, and the architecture of the bus control interface module is shown in FIG. 6 , and the details are as follows:
  • the bus control interface module obtains the source image from the external memory, the pixel data of the source pixel of the source image is inputted row by row, and is transmitted from the bus into the bus control interface module in the form of serial bus data.
  • the data amount of the bus data transmitted in one clock cycle is determined according to the bus bit width. For example, if the bit width of the bus is 128 bits (binary digit, bit), that is, 16 bytes, then 16 words are transmitted in one clock cycle. section bus data.
  • the length of pixel data of each source pixel point is one byte.
  • the bus data passed in from the external memory may be unaligned.
  • the bus data register and the splicing unit are used to realize the splicing and alignment of the pixel data.
  • the misalignment of bus data means that the pixel data of the source pixel input from the external memory does not start with the 0th bit (0x00) of the bus data, resulting in that the bus data read in one clock cycle is not necessarily the source Pixel data for the pixel.
  • the read source pixel data starts at 0x02, and 0x00 , 0x01, these two bytes of data may be other data information (such as identification bit information), then the bus data (16 bytes of data in the previous clock cycle, that is, the label in Figure 6) cached in the bus data register is converted by the splicing unit.
  • the source pixel data that is, the 14-byte data labeled 2 to 15 in Figure 6) in the 16-byte data of 0 to 15
  • the current bus data specifically, the labels of this clock cycle are 16 and 17).
  • the two bytes of data are spliced to obtain aligned 16-byte bus data.
  • the aligned bus data starts from the start address 0x00, and each byte is the source pixel data of a source pixel.
  • the flag bit of the parity line identifier register is switched according to the line width information of the source image acquired in advance, so as to judge the parity of the line position serial number of the source pixel point corresponding to each pixel data transmitted in sequence, so as to convert each source pixel
  • the pixel data of the point is divided into two lines of pixel data of even-numbered lines and pixel data of odd-numbered lines and transmitted backwards.
  • the line width information in the source image be 32 pixels (that is, each line in the source image includes 32 source pixels), and the line position serial number of the initial line in the source image is an even number (for example, the serial number of the initial line is 0). ), then the odd-even row identifier register is initially an even row identification bit, and the bus data output from the splicing unit is then determined to be the even row pixel data transmitted backward through the first line in turn; when the odd row identifier register detects that the transmission After the bus data reaches 32 bytes, the identification bit of the odd-even row data register is switched to the odd row identification bit, and then the bus data output from the splicing unit is sequentially determined as odd-numbered row pixel data through the second line to transmit backward through the second line; By analogy, by cyclically switching the identification bits of the odd-even row identification register, the pixel data of each source pixel is correspondingly divided into even row pixel data or odd row pixel data, and is transmitted backward through two different lines,
  • the even-numbered rows of pixel data are transmitted backwards, and the identification bits of the odd-even column identification registers are switched alternately, so that the even-numbered rows of pixel data whose column position sequence numbers are even and whose column position sequence numbers are odd are transferred to the buffer by branching in the first even-numbered column register, the first odd-numbered column register, and finally stored in the first preset memory and the second preset memory.
  • the even-numbered row data registers and the splicing unit in FIG. 6 are used for splicing the even-numbered row pixel data to a length equal to the bit width of the preset memory and then transmitting backwards. Exemplarily, as shown in FIG.
  • row 0 in the source image contains a total of 32 bytes of pixel data with column position numbers ranging from 0 to 31 (each byte corresponds to the pixel data of one source pixel) , assuming that the bit width of the bus is 16 bytes, and the bit width of each preset memory is 8 bytes, then in the first clock cycle, the 16 pixel data whose column position serial numbers are 0 to 15 are sorted by column The parity of the position serial number is cached in the first even-numbered column register and the first odd-numbered column register, respectively, and then transferred to the address 0 of the first preset memory and the address 0 of the second preset memory for storage; in the second In each clock cycle, the 16 pixel data whose column position serial numbers are 16 to 31 are respectively cached in the first even-numbered column register and the first odd-numbered column register according to the parity of the column position serial numbers, and then transferred to the first preset register respectively. It is stored in the address 1 of the memory and the address 1 of the second prese
  • step S4004 the odd-numbered row pixel data is transmitted backwards, and the identification bits of the odd-even column identification register are alternately switched, so that the odd-numbered row pixel data whose column position serial number is an even number and whose column position serial number is an odd-numbered pixel data is transmitted and buffered in the second even-numbered column register, the second odd-numbered column register, and finally stored in the third preset memory and the fourth preset memory respectively.
  • step S4003 Its specific execution logic is similar to that of step S4003, which is not repeated here.
  • step S401 the pixel data of each source pixel in the source image is accurately stored in the first preset memory, the second preset memory, and the third preset memory through steps S4001 to S4004, respectively.
  • step S402 the pixel data of the four adjacent source pixel points can be accurately obtained from the four preset memories, thereby ensuring the accuracy of the target pixel data determined later. accuracy.
  • FIG. 9 shows a schematic diagram of a hardware architecture of an image processing apparatus provided by an embodiment of the present application, where the hardware architecture includes a system control module, an external memory, a bus control interface module, a calculation unit (calculated by a coordinate calculation unit, an address The calculation unit and the pixel calculation unit are composed of), a register, a first preset memory, a second preset memory, a third preset memory and a fourth preset memory.
  • the data transmission process of the hardware architecture is as follows: (1) The bus control interface module obtains the pixel data of the source image from the external memory through the bus data transmission in advance, and stores them in the first preset memory and the second preset memory respectively.
  • the system control module instructs the calculation unit and the bus control interface module to cooperate with each other, and the coordinate calculation unit in the calculation unit determines the current four corresponding pixels to be generated.
  • the pixel data of the four adjacent target source pixels are determined by the address calculation unit to correspond to the address information in the preset memory, and then the calculation unit transmits the address information to the bus control interface module;
  • the bus control interface module obtains the four adjacent preset memories from the first preset memory, the second preset memory, the third preset memory and the fourth preset memory respectively within the same clock cycle according to the address information The pixel data of the target source pixel point; (4) the bus control interface module transmits the acquired pixel data of the four adjacent target source pixel points to the calculation unit, and calculates the interpolation operation through the pixel calculation unit therein to obtain the current The target pixel data of the pixel to be generated; (5) transfer the target pixel data to the buffer for buffering; (6) return to perform steps (2)
  • the mapping coordinates corresponding to the pixels to be generated in the source image are usually coordinates whose horizontal and vertical coordinates are non-integers
  • the corresponding pixels to be generated are corresponding to the source pixels in the source image.
  • the required pixel data of the four source pixel points is read, the reading efficiency of the pixel data is improved, the target pixel data of the pixel point to be generated is efficiently determined, and the image processing efficiency based on the interpolation operation is improved.
  • acquiring the pixel data of each target source pixel from different preset memories including:
  • A1 Determine the preset memory and offset corresponding to each of the target source pixels according to the position information of each of the target source pixels in the source image;
  • A2 According to each of the offsets, respectively determine the address information of the pixel data of each of the target source pixel points in the corresponding preset memory;
  • A3 According to each of the address information, acquire pixel data of each of the corresponding target source pixels from each of the preset memories.
  • the position type corresponding to each target source pixel is determined according to the position information of each target source pixel in the source image, and the corresponding preset memory is determined according to the position type.
  • the offset of the target source pixel in the corresponding preset memory is determined according to the position information of each target source pixel.
  • the position information of the target source pixel A it is determined that it is the source pixel of the third position type odd-numbered column position type in the source image, and the offset is 3.
  • each target source pixel is based on its corresponding offset and the bit width of the preset memory (in units of bytes) to obtain the pixel data of the target source pixel in its corresponding preset memory.
  • the address information includes the storage address of the pixel data in the preset memory and the byte offset information in the storage address. Specifically, offset is used to represent the offset corresponding to the target source pixel, W represents the bit width of the preset memory, Address represents the storage address, and byte_offset represents the byte offset information, then:
  • “>>” represents the right shift operator
  • “%” represents the remainder operator. Specifically, taking the obtained logarithm of the bit width W of the preset memory with the base 2 as the target right shift number, the offset represented by binary is shifted to the right by the target right shift number to obtain the storage address Address ; Specifically, the remainder obtained by dividing the offset offset by the bit width W of the preset memory is used as the byte offset information byte_offset.
  • the pixel data of the corresponding target source pixel is obtained from each preset storage respectively.
  • the storage address obtained by the target source pixel point A in step A2 as shown in FIG. 2 is address 0 and the byte offset is 3, then the corresponding memory address in the memory with the odd-numbered column memory address number 0 is 0.
  • the third byte sums the acquired pixel data of the target source pixel point A; at the same time, the pixel data of the target source pixel point B is also acquired in the even-numbered column memory according to its corresponding address information.
  • the embodiment of the present application can accurately determine the preset memory, offset and address information corresponding to each target source pixel according to the position information of each target source pixel in the source image, it can ensure that the pixel of the target source pixel is The accuracy of data reading, thereby ensuring the accuracy of target pixel data calculation.
  • the position information includes the coordinate information of each of the target source pixels
  • determining each of the target sources according to the position information of each of the target source pixels in the source image including:
  • B1 Determine the position type corresponding to each of the target source pixels according to the coordinate information of each of the target source pixels in the source image;
  • B2 Determine the preset memory corresponding to each of the target source pixels and the corresponding first offset calculation formula according to the position type of each of the target source pixels in the source image;
  • B3 Determine the offset of each of the target source pixels in the corresponding preset memory according to the coordinate information of each of the target source pixels and the first offset calculation formula.
  • each target source pixel is determined according to its coordinate information in the source image to determine the position type corresponding to the target source pixel.
  • the coordinates (1, 1) of the target source pixel A it is determined to be an odd row and odd column position type
  • the coordinates (2, 1) of the target source pixel B it is determined It is the position type of odd-numbered rows and even-numbered columns
  • the coordinates (1, 2) of the target source pixel point C it is determined to be the position type of even-numbered rows and odd-numbered columns
  • the coordinates (2, 2) of the target source pixel point D it is determined to be an even number Row even column position type.
  • a preset memory corresponding to each target source pixel and a corresponding first offset calculation formula for calculating the offset are determined according to the position type of each target source pixel in the source image.
  • the preset memory corresponding to the target source pixel point A is the above-mentioned fourth preset memory
  • the preset memory corresponding to the target source pixel point B is the above-mentioned third preset memory
  • the target source pixel point B is the above-mentioned third preset memory.
  • the preset memory corresponding to point C is the aforementioned second preset memory
  • the preset memory corresponding to the target source pixel point D is the aforementioned first preset memory.
  • the target source pixel point of the odd-numbered row and odd-numbered column position type and the target source pixel of the even-numbered row and odd-numbered column type corresponds to
  • the first offset calculation formula is:
  • the first offset corresponding to the position type of odd-numbered rows and even-numbered columns in the source pixel point and the target source pixel point of the even-numbered row and even-numbered column type (that is, the source pixel point whose x-axis coordinate is an even number, as shown in B and D in Figure 3)
  • the calculation formula is:
  • offset represents the offset
  • width represents the width of the source image
  • >> represents the right shift operator
  • * represents the multiplication sign
  • x represents the abscissa (ie column coordinate) of the target source pixel
  • y represents the target source pixel.
  • Vertical coordinate (ie row coordinate) is 0 when width is odd, and 1 when width is even.
  • the offset of each target source pixel in the corresponding preset memory is determined according to the coordinate information of each target source pixel and the determined first offset calculation formula.
  • the target source pixel point A(1,1) and the target source pixel point C(1,2) as shown in FIG. 3 are respectively substituted into the corresponding first offset calculation determined in step B2.
  • the formula offset (width>>1)*(y>>1)+(x>>1), respectively obtain the offset corresponding to the target source pixel A in the fourth preset memory and the target source pixel C Corresponding to the offset in the second preset memory; substitute the target source pixel point B(2,1) and the target source pixel point D(2,2) into the corresponding first offset determined in step B2 respectively.
  • the offset calculation formula offset ((width>>1)+width[0])*(y>>1)+(x>>1), respectively obtain the target source pixel point B corresponding to the third preset memory and the target source pixel point D corresponds to the offset in the first preset memory.
  • the position information includes the The coordinate information of the first target source pixel point and the relative position information of the second target source pixel point relative to the first target source pixel point, then according to each target source pixel point in the source image
  • the position information of determine the preset memory and offset corresponding to each of the target source pixels, including:
  • C1 Determine the position type corresponding to each target source pixel according to the coordinate information of the first target source pixel and the relative position information of the second target source pixel relative to the first target source pixel and the corresponding second offset calculation formula;
  • C2 Determine the offset of each target source pixel in the corresponding preset memory according to the coordinate information of the first target source pixel and each of the second offset calculation formulas.
  • the source pixel with a smaller coordinate value may be selected as the first target source pixel among the at least two adjacent target source pixels determined, and the other target source pixels as the second target source pixel point.
  • the at least two adjacent target source pixels specifically include four adjacent target source pixels, then the source pixel located in the upper left corner is specifically used as the first target source pixel, and the other three target The source pixel is used as the second target source pixel; according to the coordinate information of the first target source pixel and the relative position of the second target source pixel and the first target source pixel, the corresponding position type and the second offset are determined.
  • the displacement calculation formula then, according to the coordinates of the first target source pixel point and the determined four second offset calculation formulas corresponding to the four target source pixel points, it is determined that the four target source pixel points correspond to the respective The offset in the preset memory for .
  • the second offset calculation formula is determined as follows:
  • offset represents the offset
  • width represents the width of the source image
  • >> represents the right shift operator
  • * represents the multiplication sign
  • sx represents the abscissa (ie the column coordinate) of the first target source pixel
  • sy represents the first target
  • the ordinate (ie row coordinate) of the source pixel, width[0] is 0 when width is odd, and 1 when width is even.
  • the target source pixel A is the first target source pixel, and its coordinates are (1, 1), and the target source pixels B, C, and D are the second target source pixels.
  • the position type of point C is the position type of even row and odd column and the corresponding
  • the offset corresponding to each target source pixel is specifically determined by the coordinate information of each target source pixel and the first offset calculation formula, or, specifically by the determined target source pixel in the The coordinate information of the first target source pixel, the relative positions of other target source pixels and the first target source pixel, and the determined second offset calculation formula to determine the offset corresponding to each target source pixel , to ensure the accuracy of reading the pixel data of the source pixel point, and then to ensure the accuracy of the calculation of the target pixel data.
  • FIG. 10 shows a schematic flowchart of a third image processing method provided by an embodiment of the present application.
  • the image processing method is applied to a Spatial Transformer Network (STN), and an architecture diagram of the STN is shown in FIG. 11 .
  • the source data in Figure 11 is the source image data, including the pixel data of each source pixel in the source image, and the target data is the image data obtained by generating the target pixel data one by one in the image to be generated, which is called target image data.
  • Each pixel in the target image data is filled with a corresponding target pixel data.
  • the image processing method shown in Figure 10 is detailed as follows:
  • the target parameters of the STN are determined through parameter prediction.
  • the coordinates (x, y) of the image to be generated and their corresponding mapping coordinates (x', y') in the source image have the following coordinate mapping relationship:
  • a, b, c, d, e, and f are six target parameters, which can reflect the transformation relationship between the image to be generated and the source image, such as translation, scaling, and rotation.
  • parameter prediction can be achieved by training several consecutive neural network layers (including convolutional layers and connection layers) in the STN through training samples, and the target parameters a, b, c, d, e, and f of the STN can be obtained.
  • mapping coordinates of the source image corresponding to the to-be-generated pixel points in the to-be-generated image are determined.
  • the four adjacent target source pixels are determined according to the mapping coordinates.
  • mapping coordinates (x', y') In the determined mapping coordinates (x', y'), x' and y' are decimals, and in the source image, there is only the pixel data of the source pixels whose horizontal and vertical coordinates are integers. Map the four adjacent target source pixels with the closest coordinates. Exemplarily, as shown in FIG. 3 , if the mapping coordinates corresponding to the pixel point A' to be generated in the source image are (1.6, 1.4), then the corresponding four adjacent target source pixel points in the source image are A. (1,1), B(2,1), C(1,2), D(2,2).
  • the first preset memory, the second preset memory, the third preset memory and the fourth preset memory are respectively obtained.
  • the memory acquires the pixel data of each of the target source pixel points; wherein, the first preset memory is used to store the pixel data of the source pixel points whose row position serial numbers are even and column position serial numbers are even in the source image, so
  • the second preset memory is used to store the pixel data of the source pixels whose row position serial numbers are even and the column position serial numbers are odd in the source image
  • the third preset memory is used to store the row positions in the source image.
  • the fourth preset memory is used to store the pixel data of the source pixels whose row position serial numbers are odd and the column position serial numbers are odd in the source image .
  • Step S1004 in this embodiment of the present application is the same as the above-mentioned step S402.
  • Step S402 please refer to the above-mentioned related description of the step S402, which will not be repeated here.
  • a bilinear interpolation operation is performed according to the pixel data of the four adjacent target source pixel points, and the target pixel data of the to-be-generated pixel point is determined.
  • the pixel point A' to be generated corresponds to the four adjacent target source pixel points in the source image as A(1,1), B(2,1), C(1, 2), D(2,2), suppose its corresponding pixel data are represented by dataA, dataB, dataC, dataD respectively, then the calculation formula of the target pixel data data_A' of the pixel point A' to be generated is as follows:
  • the image processing method is specifically applied to the STN.
  • the amount of image data to be processed by the STN is generally relatively large, and the target pixel data of each pixel to be generated needs to be based on four adjacent target source pixels.
  • the pixel data is determined by interpolation. Because through the method of the embodiment of the present application, the pixel data of the four adjacent source pixel points corresponding to the pixel points to be generated can be simultaneously acquired from different preset memories at one time, so that the target pixel data can be quickly determined, so it is possible to Greatly improve the processing efficiency of STN.
  • Embodiment 2 is a diagrammatic representation of Embodiment 1:
  • FIG. 12 shows a schematic structural diagram of an image processing apparatus provided by an embodiment of the present application. For the convenience of description, only parts related to the embodiment of the present application are shown:
  • the image processing apparatus includes: a target source pixel point determination unit 121 , a pixel data acquisition unit 122 , and a target pixel data determination unit 123 . in:
  • the target source pixel point determination unit 121 is configured to determine at least two adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image, where the target source pixel points are the source pixel points in the source image.
  • the pixel data obtaining unit 122 is configured to obtain the pixel data of each target source pixel from different preset memories according to the position information of each target source pixel in the source image, wherein each target source pixel is
  • the preset memory respectively stores source pixels of one type of location, and the location type is determined according to the location information of the source pixels in the source image.
  • the target pixel data determination unit 123 is configured to perform an interpolation operation according to the pixel data of each of the target source pixel points, and determine the target pixel data of the to-be-generated pixel point.
  • the image processing apparatus further includes:
  • a first acquiring unit configured to acquire a source image, where each source pixel in the source image contains respective pixel data
  • a first storage unit configured to store the pixel data of each source pixel in the source image in a preset memory corresponding to the location type according to the location type corresponding to each source pixel in the source image .
  • the source pixel point determination unit 121 is specifically configured to determine four adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image;
  • the pixel data acquisition unit 122 is specifically configured to obtain information from the first preset memory, the second preset memory, the The third preset memory and the fourth preset memory acquire the pixel data of each of the target source pixels; wherein, the first preset memory is used for storing the row position serial number is even and the column position serial number is even in the source image
  • the first preset memory is used for storing the row position serial number is even and the column position serial number is even in the source image
  • the second preset memory is used to store the pixel data of the source pixels whose row position serial numbers are even and the column position serial numbers are odd in the source image
  • the third preset memory for storing pixel data of source pixels whose row position serial numbers are odd and column position serial numbers are even in the source image
  • the fourth preset memory is used for storing odd row position serial numbers and column positions in the source image
  • the image processing apparatus further includes:
  • a second acquiring unit configured to acquire a source image, where each source pixel in the source image contains respective pixel data
  • the first classification unit is used to correspondingly divide the pixel data of each source pixel in the source image into even-numbered row pixel data and odd-numbered pixel data according to the parity of the row position serial numbers corresponding to each source pixel in the source image. row pixel data;
  • the second storage unit according to the parity of the column position serial number corresponding to each source pixel point in the even-numbered row pixel data, correspondingly selects and stores the even-numbered row pixel data in the first preset memory or the second preset memory;
  • the third storage unit selects and stores the odd row pixel data in the third preset memory or the fourth preset memory according to the parity of the column position serial numbers corresponding to each source pixel in the odd row pixel data.
  • the image processing apparatus further includes:
  • a target parameter determination unit configured to determine the target parameter of the spatial transformation network through parameter prediction
  • the source pixel point determination unit 121 includes a mapping coordinate determination module and a source pixel point determination module:
  • mapping coordinate determination module configured to determine, according to the target parameter, the mapping coordinates of the source image corresponding to the to-be-generated pixels in the to-be-generated image
  • a source pixel point determination module configured to determine the four adjacent target source pixel points according to the mapping coordinates
  • the target pixel data determining unit 123 is specifically configured to perform a bilinear interpolation operation according to the pixel data of the four adjacent target source pixel points, and determine the target pixel data of the to-be-generated pixel point.
  • the pixel data acquisition unit 122 includes an offset determination module, an address information determination module and a pixel data acquisition module:
  • an offset determination module configured to determine a preset memory and an offset corresponding to each of the source pixels according to the position information of each of the target source pixels in the source image
  • the address information determination module is configured to determine, according to each of the offsets, the address information of the pixel data of each of the target source pixel points in the respective corresponding preset memories;
  • a pixel data acquisition module configured to acquire pixel data of each of the corresponding target source pixels from each of the preset memories according to each of the address information.
  • the offset determination module is specifically configured to, according to the coordinate information of each of the target source pixels in the source image, , determine the position type corresponding to each target source pixel point; according to the position type of each target source pixel point in the source image, determine the preset memory corresponding to each target source pixel point and the corresponding first an offset calculation formula; according to the coordinate information of each of the target source pixels and the first offset calculation formula, determine the corresponding position of each target source pixel in the corresponding preset memory.
  • Offset
  • the position information includes the The coordinate information of the first target source pixel point and the relative position information of the second target source pixel point with respect to the first target source pixel point
  • the offset determination module is specifically used for determining the offset according to the first target source pixel point.
  • the coordinate information of the target source pixel point and the relative position information of the second target source pixel point relative to the first target source pixel point determine the position type corresponding to each target source pixel point and the corresponding second offset according to the coordinate information of the first target source pixel and each of the second offset calculation formulas, determine the offset of each of the target source pixels in the corresponding preset memory .
  • FIG. 13 is a schematic diagram of a terminal device provided by an embodiment of the present application.
  • the terminal device 13 in this embodiment includes: a processor 130 , a memory 131 , and a computer program 132 stored in the memory 131 and executable on the processor 130 , such as an image processing program.
  • the processor 130 executes the computer program 132
  • the steps in each of the above image processing method embodiments are implemented, for example, steps S101 to S103 shown in FIG. 1 .
  • the processor 130 executes the computer program 132
  • the functions of the modules/units in each of the foregoing apparatus embodiments for example, the functions of the units 121 to 123 shown in FIG. 12, are implemented.
  • the computer program 132 may be divided into one or more modules/units, and the one or more modules/units are stored in the memory 131 and executed by the processor 130 to complete the this application.
  • the one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program 132 in the terminal device 13 .
  • the computer program 132 can be divided into a target source pixel point determination unit, a pixel data acquisition unit, and a target pixel data determination unit. The specific functions of each unit are as follows:
  • a target source pixel point determination unit configured to determine at least two adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image, where the target source pixel points are the source pixel points in the source image;
  • a pixel data acquisition unit configured to acquire pixel data of each of the target source pixels from different preset memories according to the position information of each of the target source pixels in the source image, wherein each of the target source pixels
  • the preset memories respectively store source pixels of a position type, and the position type is determined according to the position information of the source pixels in the source image;
  • the target pixel data determination unit is configured to perform interpolation operation according to the pixel data of each of the target source pixel points, and determine the target pixel data of the to-be-generated pixel point.
  • the terminal device 13 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the terminal device may include, but is not limited to, the processor 130 and the memory 131 .
  • FIG. 13 is only an example of the terminal device 13, and does not constitute a limitation on the terminal device 13, and may include more or less components than the one shown, or combine some components, or different components
  • the terminal device may further include an input and output device, a network access device, a bus, and the like.
  • the so-called processor 130 may be a central processing unit (Central Processing Unit, CPU), or other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the memory 131 may be an internal storage unit of the terminal device 13 , such as a hard disk or a memory of the terminal device 13 .
  • the memory 131 can also be an external storage device of the terminal device 13, such as a plug-in hard disk equipped on the terminal device 13, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, Flash Card, etc.
  • the memory 131 may also include both an internal storage unit of the terminal device 13 and an external storage device.
  • the memory 131 is used to store the computer program and other programs and data required by the terminal device.
  • the memory 131 may also be used to temporarily store data that has been output or will be output.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Processing (AREA)

Abstract

An image processing method and apparatus, a terminal device, and a storage medium, which are applied in the technical field of computers. The method comprises: determining at least two adjacent target source pixel points corresponding to a pixel point to be generated in an image to be generated, the target source pixel points being source pixel points in a source image (S101); according to location information of each target source pixel point in the source image, respectively acquiring pixel data of each target source pixel point from different preset memories, each preset memory storing a source pixel point of a location type, and the location type being determined according to location information of the source pixel point in the source image (S102); and performing an interpolation operation according to the pixel data of each target source pixel point, so as to determine target pixel data of the pixel point to be generated (S103). In the foregoing method, image processing efficiency can be improved.

Description

图像处理方法、装置、终端设备及存储介质Image processing method, device, terminal device and storage medium
本申请要求于2020年6月4日提交中国专利局,申请号为202010500223.X、发明名称为“图像处理方法、装置、终端设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on June 4, 2020 with the application number 202010500223.X and the invention titled "Image Processing Method, Apparatus, Terminal Equipment and Storage Medium", the entire contents of which are approved by Reference is incorporated in this application.
技术领域technical field
本申请属于计算机技术领域,尤其涉及一种图像处理方法、装置、终端设备及存储介质。The present application belongs to the field of computer technology, and in particular, relates to an image processing method, apparatus, terminal device and storage medium.
背景技术Background technique
在现有的诸如图像对齐、图像变换、图像校正等图像处理技术中,常常存在着需要根据源图像的像素数据确定目标图像的像素数据的处理过程。In the existing image processing technologies such as image alignment, image transformation, image correction, etc., there is often a processing process that needs to determine the pixel data of the target image according to the pixel data of the source image.
这一处理过程通常需要分多次读取多个源像素点的像素数据才能确定目标图像的一个像素点的像素数据。然而,这种像素数据的读取方式效率较低,从而降低了图像处理的效率。In this processing process, the pixel data of a plurality of source pixel points need to be read multiple times in order to determine the pixel data of one pixel point of the target image. However, this way of reading pixel data is inefficient, thereby reducing the efficiency of image processing.
发明内容SUMMARY OF THE INVENTION
有鉴于此,本申请实施例提供了图像处理方法、装置、终端设备及存储介质,以解决现有技术中如何提高图像处理效率的问题。In view of this, the embodiments of the present application provide an image processing method, an apparatus, a terminal device, and a storage medium, so as to solve the problem of how to improve the image processing efficiency in the prior art.
本申请实施例的第一方面提供了一种图像处理方法,包括:A first aspect of the embodiments of the present application provides an image processing method, including:
确定与待生成图像中的待生成像素点对应的至少两个相邻的目标源像素点,所述目标源像素点为源图像中的源像素点;Determine at least two adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image, where the target source pixel points are the source pixel points in the source image;
根据各个所述目标源像素点在所述源图像中的位置信息,分别从不同的预设存储器中获取各个所述目标源像素点的像素数据,其中每个所述预设存储器分别存储一种位置类型的源像素点,所述位置类型根据所述源像素点在源图像中的位置信息确定;According to the position information of each target source pixel in the source image, the pixel data of each target source pixel is obtained from different preset memories, wherein each of the preset memories stores a The source pixel point of the position type, the position type is determined according to the position information of the source pixel point in the source image;
根据各个所述目标源像素点的像素数据进行插值运算,确定所述待生成像素点的目标像素数据。An interpolation operation is performed according to the pixel data of each of the target source pixel points, and the target pixel data of the to-be-generated pixel point is determined.
本申请实施例的第二方面提供了一种图像处理装置,包括:A second aspect of the embodiments of the present application provides an image processing apparatus, including:
目标源像素点确定单元,用于确定与待生成图像中的待生成像素点对应的至少两个相邻的目标源像素点,所述目标源像素点为源图像中的源像素点;a target source pixel point determination unit, configured to determine at least two adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image, where the target source pixel points are the source pixel points in the source image;
像素数据获取单元,用于根据各个所述目标源像素点在所述源图像中的位置信息,分别从不同的预设存储器中获取各个所述目标源像素点的像素数据,其中每个所述预设存储器分别存储一种位置类型的源像素点,所述位置类型根 据所述源像素点在源图像中的位置信息确定;A pixel data acquisition unit, configured to acquire pixel data of each of the target source pixels from different preset memories according to the position information of each of the target source pixels in the source image, wherein each of the target source pixels The preset memories respectively store source pixels of a position type, and the position type is determined according to the position information of the source pixels in the source image;
目标像素数据确定单元,用于根据各个所述目标源像素点的像素数据进行插值运算,确定所述待生成像素点的目标像素数据。The target pixel data determination unit is configured to perform interpolation operation according to the pixel data of each of the target source pixel points, and determine the target pixel data of the to-be-generated pixel point.
本申请实施例的第三方面提供了一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,当所述处理器执行所述计算机程序时,使得终端设备实现如所述图像处理方法的步骤。A third aspect of the embodiments of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, when the processor executes the computer program At the time, the terminal device is made to implement the steps of the image processing method.
本申请实施例的第四方面提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,当所述计算机程序被处理器执行时,使得终端设备实现如所述图像处理方法的步骤。A fourth aspect of the embodiments of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, enables a terminal device to perform image processing as described above steps of the method.
本申请实施例的第五方面提供了一种计算机程序产品,当计算机程序产品在终端设备上运行时,使得终端设备执行如第一方面中所述的图像处理方法的步骤。A fifth aspect of the embodiments of the present application provides a computer program product that, when the computer program product runs on a terminal device, causes the terminal device to execute the steps of the image processing method described in the first aspect.
本申请实施例与现有技术相比存在的有益效果是:本申请实施例中,由于在需要确定待生成像素点的目标像素数据时,能够分别从不同的预设存储器中一次性地获取与当前待生成像素点对应的多个目标源像素点的像素数据,根据读取到的目标源像素点的像素数据进行插值运算,得到待生成像素点的目标像素数据,即一次就可以读取到进行插值运算时所需的多个目标源像素点的像素数据,而无需分多次等待读取像素数据,因此能够提高像素数据的读取效率,高效地确定待生成像素点的目标像素数据,进而提高基于插值运算的图像处理效率。The beneficial effects of the embodiments of the present application compared with the prior art are: in the embodiments of the present application, when the target pixel data of the pixels to be generated needs to be determined, the corresponding data can be obtained from different preset memories at one time. The pixel data of multiple target source pixel points corresponding to the current pixel to be generated, perform interpolation operation according to the read pixel data of the target source pixel to obtain the target pixel data of the pixel to be generated, that is, it can be read at one time. The pixel data of multiple target source pixel points required for the interpolation operation, without waiting to read the pixel data multiple times, so the reading efficiency of the pixel data can be improved, and the target pixel data of the pixel to be generated can be determined efficiently, Further, the image processing efficiency based on interpolation operation is improved.
附图说明Description of drawings
图1是本申请实施例提供的第一种图像处理方法的实现流程示意图;FIG. 1 is a schematic diagram of an implementation flowchart of a first image processing method provided by an embodiment of the present application;
图2是本申请实施例提供的一种待生成像素点及对应的两个相邻目标源像素点的示意图;2 is a schematic diagram of a to-be-generated pixel point and two corresponding adjacent target source pixel points provided by an embodiment of the present application;
图3是本申请实施例提供的一种待生成像素点及对应的四个相邻目标源像素点的示意图;3 is a schematic diagram of a to-be-generated pixel point and corresponding four adjacent target source pixel points provided by an embodiment of the present application;
图4是本申请实施例提供的第二种图像处理方法的实现流程示意图;FIG. 4 is a schematic diagram of an implementation flowchart of a second image processing method provided by an embodiment of the present application;
图5是本申请实施例提供的一种源像素点的像素数据的存储流程示意图;5 is a schematic diagram of a storage process flow of pixel data of a source pixel point provided by an embodiment of the present application;
图6是本申请实施例提供的一种总线控制接口模块的硬件架构图;6 is a hardware architecture diagram of a bus control interface module provided by an embodiment of the present application;
图7是本申请实施例提供的一种总线数据对齐的示意图;7 is a schematic diagram of a bus data alignment provided by an embodiment of the present application;
图8是本申请实施例提供的另一种源像素点的像素数据的存储流程示意图;FIG. 8 is a schematic diagram of a storage flow of pixel data of another source pixel point provided by an embodiment of the present application;
图9是本申请实施例提供的一种图像处理装置的硬件架构示意图;9 is a schematic diagram of a hardware architecture of an image processing apparatus provided by an embodiment of the present application;
图10是本申请实施例提供的第三种图像处理方法的实现流程示意图;FIG. 10 is a schematic diagram of an implementation flowchart of a third image processing method provided by an embodiment of the present application;
图11是本申请实施例提供的一种STN的架构示意图;11 is a schematic diagram of the architecture of an STN provided by an embodiment of the present application;
图12是本申请实施例提供的一种图像处理装置的示意图;12 is a schematic diagram of an image processing apparatus provided by an embodiment of the present application;
图13是本申请实施例提供的终端设备的示意图。FIG. 13 is a schematic diagram of a terminal device provided by an embodiment of the present application.
具体实施方式detailed description
为了说明本申请所述的技术方案,下面通过具体实施例来进行说明。In order to illustrate the technical solutions described in the present application, the following specific embodiments are used for description.
实施例一:Example 1:
本申请实施例中的图像处理方法应用于图像变换(例如图像的放大缩小变换、图像的平移变换、图像的旋转变换)、图像校正(即根据畸变的图像校正得到目标图像)等应用场景中。在这些应用场景中,需要根据源图像(变换前、校正前的图像)的信息生成目标图像(变换后、校正后的图像),这一过程中,待生成的目标图像(即待生成图像)中每个待生成像素点的像素数据的确定的图像处理方法为关键环节。本申请实施例中的图像处理方法通过确定与待生成图像中的待生成像素点对应的至少两个相邻的源像素点,之后同时从各个不同的预设存储器中一次性获取各个源像素点的像素数据后进行插值运算,确定待生成像素点的目标像素数据,提高了图像处理效率高。The image processing methods in the embodiments of the present application are applied to application scenarios such as image transformation (such as image zoom-in transformation, image translation transformation, and image rotation transformation), image correction (that is, obtaining a target image according to distorted image correction). In these application scenarios, it is necessary to generate target images (images after transformation and correction) according to the information of the source images (images before transformation and correction). In this process, the target image to be generated (image to be generated) The determined image processing method of the pixel data of each pixel to be generated is the key link. The image processing method in the embodiment of the present application determines at least two adjacent source pixels corresponding to the pixels to be generated in the image to be generated, and then simultaneously obtains each source pixel from different preset memories at one time After the pixel data is generated, interpolation operation is performed to determine the target pixel data of the pixel points to be generated, which improves the image processing efficiency.
图1示出了本申请实施例提供的第一种图像处理方法的流程示意图,详述如下:FIG. 1 shows a schematic flowchart of a first image processing method provided by an embodiment of the present application, and details are as follows:
在S101中,确定与待生成图像中的待生成像素点对应的至少两个相邻的目标源像素点,所述目标源像素点为源图像中的源像素点。In S101, at least two adjacent target source pixels corresponding to to-be-generated pixels in the to-be-generated image are determined, where the target source pixels are source pixels in the source image.
本申请实施例中,源图像的像素点称为源像素点;待生成图像中与源图像存在一定的映射关系,根据该映射关系,可以从源图像中确定出与待生成像素点对应的源像素点,将该与待生成像素点对应的源像素点称为目标源像素点。本申请实施例的待生成图像中,待生成像素点的像素数据具体根据源图像中的至少两个相邻的目标源像素点的像素数据来确定。具体地,根据待生成像素点的坐标以及预设的映射公式,计算得到该待生成像素点在源图像中对应的映射坐标;根据该映射坐标,确定该映射坐标附近的两个或者两个以上的相邻的源像素点作为与该待生成像素点对应的目标源像素点。In the embodiment of the present application, the pixels of the source image are called source pixels; the image to be generated has a certain mapping relationship with the source image, and according to the mapping relationship, the source corresponding to the pixels to be generated can be determined from the source image. Pixel point, the source pixel point corresponding to the pixel point to be generated is called the target source pixel point. In the image to be generated in the embodiment of the present application, the pixel data of the pixel to be generated is specifically determined according to the pixel data of at least two adjacent target source pixels in the source image. Specifically, according to the coordinates of the pixel point to be generated and the preset mapping formula, the corresponding mapping coordinates of the pixel point to be generated in the source image are calculated; according to the mapping coordinates, two or more near the mapping coordinates are determined. The adjacent source pixel points of are used as the target source pixel points corresponding to the pixel points to be generated.
示例性地,如图2所示,根据映射关系,确定与待生成像素点A'对应的目标源像素点A和目标源像素点B这两个相邻的目标源像素点。本申请实施例中,与待生成像素点对应的目标源像素点的数目还可以为两个以上,如图3所示,与待生成像素点A'对应的目标源像素点包括源像素点A、B、C、D这四个目标源像素点。Exemplarily, as shown in FIG. 2 , according to the mapping relationship, two adjacent target source pixel points, a target source pixel point A and a target source pixel point B corresponding to the pixel point A' to be generated, are determined. In this embodiment of the present application, the number of target source pixels corresponding to the to-be-generated pixels may be more than two. As shown in FIG. 3 , the target source pixels corresponding to the to-be-generated pixels A′ include the source pixel A , B, C, D, the four target source pixels.
在S102中,根据各个所述目标源像素点在所述源图像中的位置信息,分别从不同的预设存储器中获取各个所述目标源像素点的像素数据,其中每个所述预设存储器分别存储一种位置类型的源像素点,所述位置类型根据所述源像素点在源图像中的位置信息确定。In S102, according to the position information of each of the target source pixels in the source image, respectively acquire pixel data of each of the target source pixels from different preset memories, wherein each of the preset memories The source pixel points of one location type are respectively stored, and the location type is determined according to the location information of the source pixel points in the source image.
本申请实施例中,像素数据具体可以为灰度值、RGB值等用于表达图像内容的数据,源图像的每个源像素点的像素数据预先存储于各自对应的预设存储器中。具体地,源图像中的每个源像素点被分为不同的位置类型,每个预设存储器分别存储一种位置类型的源像素点。具体地,该位置类型所处行位置的奇偶性和/或所处列位置的奇偶性确定。In this embodiment of the present application, the pixel data may specifically be data used to express image content, such as grayscale values, RGB values, etc., and the pixel data of each source pixel of the source image is pre-stored in its corresponding preset memory. Specifically, each source pixel in the source image is divided into different position types, and each preset memory stores source pixels of one position type respectively. Specifically, the parity of the row position in which the position type is located and/or the parity of the column position in which the position type is located is determined.
根据步骤S101确定的至少两个相邻的目标源像素点在源图像中的位置信 息,确定与待生成像素点对应的各个目标源像素点分别对应的位置类型;接着,根据各个目标源像素点的位置类型,确定每个目标源像素点分别对应的预设存储器;之后,根据各个目标源像素点的位置信息分别从各自对应的预设存储器中获取各个目标源像素点的像素数据。由于各个目标源像素点的像素数据分别存储于不同的预设存储器,因此可以在同一个时钟周期内一次性同时获取。即,由于目标源像素点的像素数据不是存储于同一个存储器,因此无需依次排列等候逐一读取像素数据,而是可以一次性读取各个预设存储器来快速地获取各个目标像素数据。According to the position information of at least two adjacent target source pixels in the source image determined in step S101, determine the position type corresponding to each target source pixel corresponding to the pixel to be generated respectively; then, according to each target source pixel Determine the preset memory corresponding to each target source pixel; then, obtain the pixel data of each target source pixel from the corresponding preset memory according to the position information of each target source pixel. Since the pixel data of each target source pixel is stored in different preset memories, it can be acquired at one time and at the same time in the same clock cycle. That is, since the pixel data of the target source pixel is not stored in the same memory, there is no need to wait for the pixel data to be read one by one, but each preset memory can be read at one time to quickly acquire each target pixel data.
示例性地,如图2所示,设源图像中的每一列依次被标为0、1、2、3这四个列序号,源图像中的源像素点根据其所在的列的列序号的奇偶性,被分为偶数列位置类型、奇数列位置类型这两种位置类型。对应地,预设存储器包括偶数列存储器和奇数列存储器,偶数列存储器专门用于存储偶数列类型的源像素点的像素数据,奇数列存储器专门用于存储奇数列类型的源像素点的像素数据。在确定与待生成像素点A'对应的目标源像素点A和目标源像素点B后,根据这两个目标源像素点的位置信息,确定目标源像素点A对应的位置类型为奇数列位置类型,目标源像素点B对应的位置类型为偶数列位置类型,此时,分别同时从奇数列存储器中获取目标源像素点A的像素数据以及从偶数列存储器中获取目标源像素点B的像素数据。Exemplarily, as shown in FIG. 2 , suppose that each column in the source image is marked with four column numbers of 0, 1, 2, and 3 in turn, and the source pixels in the source image are based on the column number of the column where they are located. Parity is divided into two position types, an even column position type and an odd column position type. Correspondingly, the preset memory includes an even-numbered column memory and an odd-numbered column memory, the even-numbered column memory is specially used to store the pixel data of the source pixel point of the even-numbered column type, and the odd-numbered column memory is specially used to store the pixel data of the source pixel point of the odd-numbered column type. . After determining the target source pixel point A and the target source pixel point B corresponding to the pixel point A' to be generated, according to the position information of the two target source pixel points, it is determined that the position type corresponding to the target source pixel point A is an odd column position Type, the position type corresponding to the target source pixel point B is the even-numbered column position type. At this time, the pixel data of the target source pixel point A is obtained from the odd-numbered column memory and the pixel of the target source pixel point B is obtained from the even-numbered column memory at the same time. data.
在S103中,根据各个所述目标源像素点的像素数据进行插值运算,确定所述待生成像素点的目标像素数据。In S103, an interpolation operation is performed according to the pixel data of each of the target source pixel points, and the target pixel data of the to-be-generated pixel point is determined.
根据步骤S102中一次性获取到的各个目标源像素点的像素数据进行插值运算,确定待生成像素点的目标像素数据。示例性地,如图2所示,若与待生成像素点A'对应的源像素点包括目标源像素点A和目标源像素点B这两个目标源像素点,则具体在获取到目标源像素点A和目标源像素点B的像素数据后,进行一维插值运算(例如单线性插值运算),得到待生成像素点A'的像素数据。示例性地,如图3所示,若与待生成像素点A'对应的目标源像素点包括目标源像素点A、B、C、D这四个目标源像素点,则具体在获取到这四个目标源像素点的像素数据后,进行二维插值运算(例如双线性插值运算),得到待生成像素点A'的像素数据。An interpolation operation is performed according to the pixel data of each target source pixel obtained at one time in step S102 to determine the target pixel data of the pixel to be generated. Exemplarily, as shown in Figure 2, if the source pixel corresponding to the pixel A' to be generated includes the target source pixel A and the target source pixel B, then the target source After the pixel data of the pixel point A and the target source pixel point B, a one-dimensional interpolation operation (such as a unilinear interpolation operation) is performed to obtain the pixel data of the pixel point A' to be generated. Exemplarily, as shown in FIG. 3 , if the target source pixel corresponding to the pixel point A' to be generated includes four target source pixels A, B, C, and D, then specifically when the target source pixel is obtained. After the pixel data of the four target source pixel points, a two-dimensional interpolation operation (for example, a bilinear interpolation operation) is performed to obtain the pixel data of the pixel point A' to be generated.
可选地,在确定了当前的待生成像素点的目标像素数据后,可以将该目标像素数据填充至待生成图像中的对应位置中或者缓存至缓存器中,之后以当前的待生成像素点相邻的下一该像素点(例如位于待生成像素点A'右边的一个像素点)作为下一个待生成像素点,并返回执行所述步骤S101~S103,直至待生成图像中的每个像素点均已确定了对应的像素数据,即该待生成图像的数据生成完毕,得到了完整的目标图像。Optionally, after determining the current target pixel data of the pixel to be generated, the target pixel data can be filled into the corresponding position in the image to be generated or buffered in the buffer, and then the current pixel to be generated can be used as the current target pixel data. The adjacent next pixel (for example, a pixel located to the right of the pixel A' to be generated) is used as the next pixel to be generated, and returns to execute the steps S101 to S103 until each pixel in the image to be generated The corresponding pixel data has been determined for each point, that is, the data of the to-be-generated image has been generated, and a complete target image has been obtained.
可选地,在所述步骤S101之前,还包括:Optionally, before the step S101, it further includes:
获取源图像,所述源图像中的各个源像素点均包含了各自的像素数据;Acquiring a source image, where each source pixel in the source image contains respective pixel data;
根据所述源图像中的各个源像素点对应的位置类型,将所述源图像中的各个源像素点的像素数据存储于与所述位置类型对应的预设存储器中。According to the position type corresponding to each source pixel in the source image, the pixel data of each source pixel in the source image is stored in a preset memory corresponding to the position type.
本申请实施例中,在步骤S101之前,还包括了获取源图像以将源图像中各个源像素点的像素数据存储于预设存储器中的预处理步骤,详述如下:In the embodiment of the present application, before step S101, it also includes a preprocessing step of acquiring a source image to store the pixel data of each source pixel in the source image in a preset memory, which is described in detail as follows:
获取源图像,该源图像中的每个源像素点均包含了各自的像素数据,即该源图像包含了完整的图像信息,可以用于表达具体的图像内容(例如人像、风景、等图像内容)。该源图像可以为相机拍摄得到的图像,或者通过制图软件制作得到的图像。Obtain a source image, each source pixel in the source image contains its own pixel data, that is, the source image contains complete image information, which can be used to express specific image content (such as portraits, landscapes, etc.) ). The source image can be an image captured by a camera, or an image created by drawing software.
根据源图像中各个源像素点的位置类型,将各个源像素点的像素数据存储于各个预设存储器中。具体地,各个源像素点的位置类型根据各个源像素点位置信息确定,具体根据源像素点在源图像中所处行位置的奇偶性和/或所处列位置的奇偶性确定。示例性地,位置类型包括偶数行位置类型和奇数行位置类型,则对应的预设存储器包括偶数行存储器和奇数行存储器;若源像素点对应的位置类型为偶数行位置类型(即该源像素点所处行位置对应的行序号为偶数),则将该源像素点的像素数据存储至偶数行存储器中;若源像素点对应的位置类型为奇数行位置类型(即该源像素点所处行位置对应的行序号为奇数),则将该源像素点的像素数据存储至奇数行存储器中。示例性地,位置类型包括偶数列位置类型和奇数列位置类型,则对应的预设存储器包括偶数列存储器和奇数列存储器;若源像素点对应的位置类型为偶数列位置类型(即该源像素点所处列位置对应的列序号为偶数),则将该源像素点的像素数据存储至偶数列存储器中;若源像素点对应的位置类型为奇数列位置类型(即该源像素点所处列位置对应的列序号为奇数),则将该源像素点的像素数据存储至奇数列存储器中。According to the position type of each source pixel in the source image, the pixel data of each source pixel is stored in each preset memory. Specifically, the position type of each source pixel is determined according to the position information of each source pixel, specifically determined according to the parity of the row position and/or the column position of the source pixel in the source image. Exemplarily, the position type includes an even row position type and an odd row position type, then the corresponding preset memory includes an even row storage and an odd row storage; if the position type corresponding to the source pixel point is an even row position type (that is, the source pixel If the row number corresponding to the row position of the point is an even number), the pixel data of the source pixel point is stored in the even row memory; if the position type corresponding to the source pixel point is an odd row position type (that is, the source pixel point is located in The row sequence number corresponding to the row position is an odd number), the pixel data of the source pixel point is stored in the odd-numbered row memory. Exemplarily, the position type includes an even column position type and an odd column position type, and the corresponding preset memory includes an even column memory and an odd column memory; if the position type corresponding to the source pixel point is an even column position type (that is, the source pixel If the column number corresponding to the column position of the point is an even number), the pixel data of the source pixel point is stored in the even column memory; if the position type corresponding to the source pixel point is an odd column position type (that is, the source pixel point is located in The column serial number corresponding to the column position is an odd number), then the pixel data of the source pixel point is stored in the odd-numbered column memory.
本申请实施例中,由于在确定待生成图像的待生成像素点的目标像素数据之前,先获取源图像,并根据各个源像素点的位置类型,准确地将各个源像素点的像素数据存储到各个预设存储器中,以使后续能够从各个预设存储器中一次性、准确地获取与待生成像素点对应的各个目标源像素点的像素数据,进而保证目标像素数据的准确性。In the embodiment of the present application, before determining the target pixel data of the pixels to be generated in the image to be generated, the source image is obtained first, and the pixel data of each source pixel is accurately stored in the location type of each source pixel. In each preset memory, the pixel data of each target source pixel point corresponding to the to-be-generated pixel point can be acquired from each preset memory at one time and accurately, thereby ensuring the accuracy of the target pixel data.
本申请实施例中,由于在需要确定待生成像素点的目标像素数据时,能够分别从不同的预设存储器中一次性地获取与当前待生成像素点对应的多个目标源像素点的像素数据,根据读取到的目标源像素点的像素数据进行插值运算,得到待生成像素点的目标像素数据,即一次就可以读取到进行插值运算时所需的多个目标源像素点的像素数据,而无需分多次等待读取像素数据,因此能够提高像素数据的读取效率,高效地确定待生成像素点的目标像素数据,进而提高基于插值运算的图像处理效率。In the embodiment of the present application, when the target pixel data of the pixel to be generated needs to be determined, the pixel data of multiple target source pixels corresponding to the current pixel to be generated can be obtained from different preset memories at one time. , perform interpolation operation according to the read pixel data of the target source pixel to obtain the target pixel data of the pixel to be generated, that is, the pixel data of multiple target source pixels required for the interpolation operation can be read at one time , without waiting for reading pixel data multiple times, so the reading efficiency of pixel data can be improved, the target pixel data of the pixel point to be generated can be efficiently determined, and the image processing efficiency based on interpolation operation can be improved.
图4示出了本申请实施例提供的第二种图像处理方法的流程示意图,详述如下:FIG. 4 shows a schematic flowchart of a second image processing method provided by an embodiment of the present application, and details are as follows:
在S401中,确定与待生成图像中的待生成像素点对应的四个相邻的目标源像素点。In S401, four adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image are determined.
本申请实施例中,待生成图像中的待生成像素点的图像数据具体是根据源图像中的四个目标源像素点来确定的。由于一般待生成像素点在源图像中对应 的映射坐标为非整数,例如(1.6,1.4),而在源图像中是以坐标为整数的源像素点为最小单位,因此将该非整数映射坐标周围(相邻的上、下、左、右四个方向)的四个源像素点确定为待生成像素点对应的四个相邻的目标源像素点。示例性地,若待生成像素点对应的映射坐标为(1.6,1.4),则对应的四个相邻的目标源像素点为在源图像中坐标分别为(1,1)、(1,2)、(2,1)、(2,2)的这四个源像素点,例如图3所示的A、B、C、D这四个目标源像素点。In the embodiment of the present application, the image data of the pixels to be generated in the image to be generated is specifically determined according to the four target source pixels in the source image. Since the corresponding mapping coordinates of the pixels to be generated in the source image are generally non-integer, such as (1.6, 1.4), and in the source image, the source pixel whose coordinates are integers is the smallest unit, so the non-integer mapping coordinates Four surrounding source pixels (up, down, left, and right directions adjacent to each other) are determined as four adjacent target source pixels corresponding to the pixels to be generated. Exemplarily, if the mapping coordinates corresponding to the pixels to be generated are (1.6, 1.4), then the corresponding four adjacent target source pixels have coordinates (1, 1) and (1, 2) in the source image, respectively. ), (2,1), (2,2) of the four source pixels, such as the four target source pixels of A, B, C, and D shown in FIG. 3 .
在S402中,根据所述四个相邻的目标源像素点在所述源图像中的位置信息,分别从第一预设存储器、第二预设存储器、第三预设存储器及第四预设存储器获取各个所述目标源像素点的像素数据;其中,所述第一预设存储器用于存储在所述源图像中行位置序号为偶数且列位置序号为偶数的源像素点的像素数据,所述第二预设存储器用于存储在所述源图像中行位置序号为偶数且列位置序号为奇数的源像素点的像素数据,所述第三预设存储器用于存储在所述源图像中行位置序号为奇数且列位置序号为偶数的源像素点的像素数据,所述第四预设存储器用于存储在所述源图像中行位置序号为奇数且列位置序号为奇数的源像素点的像素数据。In S402, according to the position information of the four adjacent target source pixels in the source image, the first preset memory, the second preset memory, the third preset memory and the fourth preset The memory acquires the pixel data of each of the target source pixel points; wherein, the first preset memory is used to store the pixel data of the source pixel points whose row position serial numbers are even and column position serial numbers are even in the source image, so The second preset memory is used to store the pixel data of the source pixels whose row position serial numbers are even and the column position serial numbers are odd in the source image, and the third preset memory is used to store the row positions in the source image. The pixel data of the source pixels whose serial numbers are odd and the column position serial numbers are even, the fourth preset memory is used to store the pixel data of the source pixels whose row position serial numbers are odd and the column position serial numbers are odd in the source image .
与待生成像素点对应的四个相邻的目标源像素点的所处行位置的奇偶性及所处列位置的奇偶性是相间的,四个相邻的目标源像素点各自对应一种位置类型:行位置序号和列位置序号均为偶数的位置类型(例如图3所示的目标源像素点D)、行位置序号为偶数且列位置序号为奇数的位置类型(例如图3所示的目标源像素点C)、行位置序号为奇数且列位置序号为偶数的位置类型(例如图3所示的目标源像素点B)、行位置序号和列位置序号均为奇数的位置类型(例如图3所示的目标源像素点A)。对应地,预设存储器包括第一预设存储器、第二预设存储器、第三预设存储器及第四预设存储器这四个存储器,根据四个目标源像素点的在源图像中的位置信息,可以一次性从这四个存储器分别读取四个目标源像素点的像素数据。其中,第一预设存储器用于存储在源图像中行位置序号为偶数且列位置序号为偶数的源像素点的像素数据,第二预设存储器用于存储在源图像中行位置序号为偶数且列位置序号为奇数的源像素点的像素数据,第三预设存储器用于存储在源图像中行位置序号为奇数且列位置序号为偶数的源像素点的像素数据,第四预设存储器用于存储在源图像中行位置序号为奇数且列位置序号为奇数的源像素点的像素数据。The parity of the row position and the column position of the four adjacent target source pixels corresponding to the pixels to be generated are alternate, and each of the four adjacent target source pixels corresponds to a position. Type: the position type where the row position number and the column position number are even numbers (such as the target source pixel D shown in Figure 3), the position type where the row position number is even and the column position number is odd (such as the one shown in Figure 3) The target source pixel point C), the position type whose row position number is odd and the column position number is even (for example, the target source pixel point B shown in Figure 3), and the position type whose row position number and column position number are odd (such as The target source pixel point A) shown in Figure 3. Correspondingly, the preset memory includes four memories: the first preset memory, the second preset memory, the third preset memory and the fourth preset memory, according to the position information of the four target source pixels in the source image. , the pixel data of the four target source pixels can be read from the four memories at one time. Wherein, the first preset memory is used to store pixel data of source pixels whose row position serial numbers are even and column position serial numbers are even in the source image, and the second preset memory is used to store the even row position serial numbers and column position serial numbers in the source image. The pixel data of the source pixel whose position number is odd, the third preset memory is used to store the pixel data of the source pixel whose row position number is odd and the column position number is even in the source image, and the fourth preset memory is used to store The pixel data of the source pixel points with odd row position numbers and odd column position numbers in the source image.
在S403中,根据各个所述目标源像素点的像素数据进行插值运算,确定所述待生成像素点的目标像素数据In S403, interpolation operation is performed according to the pixel data of each of the target source pixel points to determine the target pixel data of the to-be-generated pixel points
在一次性获取到四个目标源像素点的像素数据后,根据这四个目标源像素点进行二维插值运算(行方向及列方向的插值计算),得到待生成像素点的目标像素数据。After obtaining the pixel data of the four target source pixel points at one time, perform two-dimensional interpolation operation (interpolation calculation in the row direction and column direction) according to the four target source pixel points to obtain the target pixel data of the pixel to be generated.
可选地,在步骤S401之前,还包括:Optionally, before step S401, it also includes:
S4001:获取源图像,所述源图像中的各个源像素点均包含了各自的像素数据;S4001: Acquire a source image, where each source pixel in the source image includes respective pixel data;
S4002:根据所述源图像中的各个源像素点对应的行位置序号的奇偶性, 对应将所述源图像中的各个源像素点的像素数据分为偶数行像素数据及奇数行像素数据;S4002: According to the parity of the row position serial numbers corresponding to each source pixel in the source image, correspondingly divide the pixel data of each source pixel in the source image into even row pixel data and odd row pixel data;
S4003:根据所述偶数行像素数据中各个源像素点对应的列位置序号的奇偶性,对应将所述偶数行像素数据选择存储于第一预设存储器或者第二预设存储器;S4003: According to the parity of the column position serial numbers corresponding to each source pixel point in the even-numbered row pixel data, correspondingly select and store the even-numbered row pixel data in the first preset memory or the second preset memory;
S4004:根据所述奇数行像素数据中各个源像素点对应的列位置序号的奇偶性,对应将所述奇数行像素数据选择存储于第三预设存储器或者第四预设存储器。S4004: According to the parity of the column position serial numbers corresponding to each source pixel point in the odd-numbered row pixel data, correspondingly select and store the odd-numbered row pixel data in the third preset memory or the fourth preset memory.
具体地,如图5所示,获取源图像,逐行读取源图像中的源像素点的像素数据,并先进行奇偶行选择(即根据各个源像素点对应的行位置序号的奇偶性进行存储选择),将源像素点的像素数据分为偶数行像素数据(即行位置序号为偶数的像素数据,如图5中的row0、row2)和奇数行像素数据(即行位置序号为奇数的像素数据,如图5中的row1、row3)。之后,将偶数行像素数据进行奇偶列选择(即根据各个源像素点对应的列位置序号的奇偶性进行存储选择),得到偶数行中的偶数列像素数据、偶数行中的奇数列像素数据,分别对应存储于第一预设存储器、第二预设存储器中;将奇数行像素数据进行奇偶列选择(即根据各个源像素点对应的列位置序号的奇偶性进行存储选择),得到奇数行中的偶数列像素数据、奇数行中的奇数列像素数据,分别对应存储于第三预设存储器、第四预设存储器中。Specifically, as shown in FIG. 5 , a source image is obtained, the pixel data of the source pixels in the source image are read line by line, and parity line selection is performed first (that is, according to the parity of the row position serial numbers corresponding to each source pixel point) Storage selection), divide the pixel data of the source pixel point into even-numbered row pixel data (that is, the pixel data whose row position serial number is an even number, such as row0 and row2 in Figure 5) and odd-numbered row pixel data (that is, the pixel data whose row position serial number is an odd number) , such as row1, row3 in Figure 5). Afterwards, the even-numbered rows of pixel data are selected for parity columns (that is, the storage selection is performed according to the parity of the column position serial numbers corresponding to each source pixel point), and the even-numbered columns of pixel data in the even-numbered rows are obtained. Correspondingly stored in the first preset memory and the second preset memory; odd-numbered rows of pixel data are selected for odd-even columns (that is, storage selection is performed according to the parity of the column position serial numbers corresponding to each source pixel point), and the odd-numbered rows are obtained. The pixel data of the even-numbered columns and the pixel data of the odd-numbered columns in the odd-numbered rows are correspondingly stored in the third preset memory and the fourth preset memory.
进一步地,本申请实施例中通过总线控制接口模块执行步骤S4001-S4004,该总线控制接口模块的架构如图6所示,详述如下:Further, in the embodiment of the present application, steps S4001-S4004 are performed through a bus control interface module, and the architecture of the bus control interface module is shown in FIG. 6 , and the details are as follows:
在S4001,总线控制接口模块从外部存储器获取源图像,源图像的源像素点的像素数据逐行遍历输入,以串行的总线数据形式从总线传输进入总线控制接口模块。其中,一个时钟周期内传输的总线数据的数据量根据总线位宽决定,例如,若总线的位宽为128比特(binary digit,bit),即16个字节,则一个时钟周期传输16个字节的总线数据。具体地,本申请实施例中每个源像素点的像素数据的长度为一个字节。可选地,从外部存储器传入的总线数据可能是不对齐的,因此本申请实施例中总线数据传入后,通过总线数据寄存器和拼接单元实现像素数据的拼接对齐。其中,总线数据不对齐指的是外部存储器传入的源像素点的像素数据不以总线数据的第0位(0x00)为起始地址,导致一个时钟周期读取的总线数据不一定都是源像素的像素数据。例如,如图6所示,设总线位宽为128bit(16个字节,图6中的每一小格表示一个字节数据),读取的源像素数据以0x02为起始地址,而0x00、0x01这两个字节数据可能为其它数据信息(例如标识位信息),则通过拼接单元将总线数据寄存器中缓存的总线数据(上一个时钟周期的16个字节数据,即图6中标号为0~15的16个字节数据)中的源像素数据(即图6中标号为2~15的14个字节数据)与当前的总线数据(具体与本时钟周期的标号为16和17的这两个字节数据)进行拼接,得到对齐的16个字节的总线数据。In S4001, the bus control interface module obtains the source image from the external memory, the pixel data of the source pixel of the source image is inputted row by row, and is transmitted from the bus into the bus control interface module in the form of serial bus data. Among them, the data amount of the bus data transmitted in one clock cycle is determined according to the bus bit width. For example, if the bit width of the bus is 128 bits (binary digit, bit), that is, 16 bytes, then 16 words are transmitted in one clock cycle. section bus data. Specifically, in the embodiment of the present application, the length of pixel data of each source pixel point is one byte. Optionally, the bus data passed in from the external memory may be unaligned. Therefore, in this embodiment of the present application, after the bus data is passed in, the bus data register and the splicing unit are used to realize the splicing and alignment of the pixel data. Among them, the misalignment of bus data means that the pixel data of the source pixel input from the external memory does not start with the 0th bit (0x00) of the bus data, resulting in that the bus data read in one clock cycle is not necessarily the source Pixel data for the pixel. For example, as shown in Figure 6, set the bus bit width to 128bit (16 bytes, each small cell in Figure 6 represents one byte of data), the read source pixel data starts at 0x02, and 0x00 , 0x01, these two bytes of data may be other data information (such as identification bit information), then the bus data (16 bytes of data in the previous clock cycle, that is, the label in Figure 6) cached in the bus data register is converted by the splicing unit. The source pixel data (that is, the 14-byte data labeled 2 to 15 in Figure 6) in the 16-byte data of 0 to 15) and the current bus data (specifically, the labels of this clock cycle are 16 and 17). The two bytes of data) are spliced to obtain aligned 16-byte bus data.
在S4002中,对齐后的总线数据中从起始地址0x00开始,每一个字节为 一个源像素点的源像素数据。此时,根据预先获取的源图像的行宽信息来切换奇偶行标识符寄存器的标识位,从而判断依次传输的各像素数据对应的源像素点的行位置序号的奇偶性,以将各个源像素点的像素数据分为偶数行像素数据和奇数行像素数据这两路数据向后传输。示例性地,设源图像中的行宽信息为32pixel(即源图像中的每一行包括32个源像素点),源图像中的初始行的行位置序号为偶数(例如初始行的序号为0),则奇偶行标识符寄存器初始为偶行标识位,此时从拼接单元输出的总线数据依次被判定为偶数行像素数据通过第一条线路向后传输;当奇数行标识符寄存器检测到传输的总线数据到达32个字节后,将奇偶行数据寄存器的标识位切换为奇行标识位,之后从拼接单元输出的总线数据依次被判定为奇数行像素数据通过第二条线路向后传输;以此类推,通过循环交替地切换奇偶行标识寄存器的标识位,将各个源像素点的像素数据对应分为偶数行像素数据或奇数行像素数据,并通过两个不同的线路向后传输,从而将源图像中的行位置序号为偶数及行位置序号为奇数的源像素点的像素数据分开处理。In S4002, the aligned bus data starts from the start address 0x00, and each byte is the source pixel data of a source pixel. At this time, the flag bit of the parity line identifier register is switched according to the line width information of the source image acquired in advance, so as to judge the parity of the line position serial number of the source pixel point corresponding to each pixel data transmitted in sequence, so as to convert each source pixel The pixel data of the point is divided into two lines of pixel data of even-numbered lines and pixel data of odd-numbered lines and transmitted backwards. Exemplarily, let the line width information in the source image be 32 pixels (that is, each line in the source image includes 32 source pixels), and the line position serial number of the initial line in the source image is an even number (for example, the serial number of the initial line is 0). ), then the odd-even row identifier register is initially an even row identification bit, and the bus data output from the splicing unit is then determined to be the even row pixel data transmitted backward through the first line in turn; when the odd row identifier register detects that the transmission After the bus data reaches 32 bytes, the identification bit of the odd-even row data register is switched to the odd row identification bit, and then the bus data output from the splicing unit is sequentially determined as odd-numbered row pixel data through the second line to transmit backward through the second line; By analogy, by cyclically switching the identification bits of the odd-even row identification register, the pixel data of each source pixel is correspondingly divided into even row pixel data or odd row pixel data, and is transmitted backward through two different lines, so that the The pixel data of the source pixels whose row position serial numbers are even and those whose row position serial numbers are odd in the source image are processed separately.
在S4003中,将偶数行像素数据向后传输,并交替切换奇偶列标识寄存器的标识位,以将偶数行像素数据中的列位置序号为偶数、列位置序号为奇数的像素数据分路传输缓存于第一偶数列寄存器、第一奇数列寄存器中,并最终存储于第一预设存储器、第二预设存储器中。其中,图6中的偶数行数据寄存器和拼接单元用于将偶数行像素数据拼接至长度等于预设存储器的位宽后再向后传输。示例性地,如图8所示,设源图像中的第0行中包含列位置序号为0~31的共32个字节的像素数据(每个字节对应一个源像素点的像素数据),设总线的位宽为16个字节,每个预设存储器的位宽为8个字节,则在第一个时钟周期中,将列位置序号为0~15的16个像素数据按照列位置序号的奇偶性,分别缓存于第一偶数列寄存器、第一奇数列寄存器中,之后分别传输至第一预设存储器的地址0、第二预设存储器的地址0中进行存储;在第二个时钟周期中,将列位置序号为16~31的16个像素数据按照列位置序号的奇偶性,分别缓存于第一偶数列寄存器、第一奇数列寄存器中,之后分别传输至第一预设存储器的地址1、第二预设存储器的地址1中进行存储;以此类推,直至所有的偶数行像素数据均已分别存储于第一预设存储器、第二预设存储器中。In S4003, the even-numbered rows of pixel data are transmitted backwards, and the identification bits of the odd-even column identification registers are switched alternately, so that the even-numbered rows of pixel data whose column position sequence numbers are even and whose column position sequence numbers are odd are transferred to the buffer by branching in the first even-numbered column register, the first odd-numbered column register, and finally stored in the first preset memory and the second preset memory. Wherein, the even-numbered row data registers and the splicing unit in FIG. 6 are used for splicing the even-numbered row pixel data to a length equal to the bit width of the preset memory and then transmitting backwards. Exemplarily, as shown in FIG. 8 , it is assumed that row 0 in the source image contains a total of 32 bytes of pixel data with column position numbers ranging from 0 to 31 (each byte corresponds to the pixel data of one source pixel) , assuming that the bit width of the bus is 16 bytes, and the bit width of each preset memory is 8 bytes, then in the first clock cycle, the 16 pixel data whose column position serial numbers are 0 to 15 are sorted by column The parity of the position serial number is cached in the first even-numbered column register and the first odd-numbered column register, respectively, and then transferred to the address 0 of the first preset memory and the address 0 of the second preset memory for storage; in the second In each clock cycle, the 16 pixel data whose column position serial numbers are 16 to 31 are respectively cached in the first even-numbered column register and the first odd-numbered column register according to the parity of the column position serial numbers, and then transferred to the first preset register respectively. It is stored in the address 1 of the memory and the address 1 of the second preset memory; and so on, until all the even-numbered rows of pixel data have been stored in the first preset memory and the second preset memory, respectively.
在S4004中,将奇数行像素数据向后传输,并交替切换奇偶列标识寄存器的标识位,以将奇数行像素数据中的列位置序号为偶数、列位置序号为奇数的像素数据分路传输缓存于第二偶数列寄存器、第二奇数列寄存器中,并最终分别存储于第三预设存储器、第四预设存储器中。其具体的执行逻辑与步骤S4003类似,此处不再赘述。In S4004, the odd-numbered row pixel data is transmitted backwards, and the identification bits of the odd-even column identification register are alternately switched, so that the odd-numbered row pixel data whose column position serial number is an even number and whose column position serial number is an odd-numbered pixel data is transmitted and buffered in the second even-numbered column register, the second odd-numbered column register, and finally stored in the third preset memory and the fourth preset memory respectively. Its specific execution logic is similar to that of step S4003, which is not repeated here.
本申请实施例中,由于在步骤S401之前,通过步骤S4001~S4004准确地将源图像中的各个源像素点的像素数据分别存储于第一预设存储器、第二预设存储器、第三预设存储器及第四预设存储器中,使得后续在步骤S402中能够准确地从这四个预设存储器中获取到四个相邻的源像素点的像素数据,进而保证之后确定出的目标像素数据的准确性。In this embodiment of the present application, before step S401, the pixel data of each source pixel in the source image is accurately stored in the first preset memory, the second preset memory, and the third preset memory through steps S4001 to S4004, respectively. In the memory and the fourth preset memory, in step S402, the pixel data of the four adjacent source pixel points can be accurately obtained from the four preset memories, thereby ensuring the accuracy of the target pixel data determined later. accuracy.
示例性地,图9示出了本申请实施例提供的一种图像处理装置的硬件架构示意图,该硬件架构包括系统控制模块、外部存储器、总线控制接口模块、计算单元(由坐标计算单元、地址计算单元及像素计算单元组成)、缓存器、第一预设存储器、第二预设存储器、第三预设存储器及第四预设存储器。具体地,该硬件架构的数据传输流程如下:(1)总线控制接口模块预先通过总线数据传输从外部存储器中获取源图像的像素数据,并分别存储于第一预设存储器、第二预设存储器、第三预设存储器和第四预设存储器中;(2)系统控制模块指示计算单元和总线控制接口模块相互协作,通过计算单元中的坐标计算单元确定当前的待生成像素点对应的四个相邻的目标源像素点,通过地址计算单元确定四个相邻的目标源像素点的像素数据对应在预设存储器中的地址信息,之后计算单元再将该地址信息传送给总线控制接口模块;(3)总线控制接口模块根据地址信息,在同一个时钟周期内分别从第一预设存储器、第二预设存储器、第三预设存储器和第四预设存储器中获取该四个相邻的目标源像素点的像素数据;(4)总线控制接口模块将获取到的四个相邻的目标源像素点的像素数据传送至计算单元中,通过其中的像素计算单元计算插值运算,得到当前的待生成像素点的目标像素数据;(5)将该目标像素数据传送至缓存器中进行缓存;(6)返回执行步骤(2)-(5)以进行下一个待生成像素点的目标像素数据的确定,直至缓存器已存满,将该缓存器中的数据通过总线控制接口模块传输至外部存储器。Exemplarily, FIG. 9 shows a schematic diagram of a hardware architecture of an image processing apparatus provided by an embodiment of the present application, where the hardware architecture includes a system control module, an external memory, a bus control interface module, a calculation unit (calculated by a coordinate calculation unit, an address The calculation unit and the pixel calculation unit are composed of), a register, a first preset memory, a second preset memory, a third preset memory and a fourth preset memory. Specifically, the data transmission process of the hardware architecture is as follows: (1) The bus control interface module obtains the pixel data of the source image from the external memory through the bus data transmission in advance, and stores them in the first preset memory and the second preset memory respectively. , the third preset memory and the fourth preset memory; (2) the system control module instructs the calculation unit and the bus control interface module to cooperate with each other, and the coordinate calculation unit in the calculation unit determines the current four corresponding pixels to be generated. For the adjacent target source pixels, the pixel data of the four adjacent target source pixels are determined by the address calculation unit to correspond to the address information in the preset memory, and then the calculation unit transmits the address information to the bus control interface module; (3) The bus control interface module obtains the four adjacent preset memories from the first preset memory, the second preset memory, the third preset memory and the fourth preset memory respectively within the same clock cycle according to the address information The pixel data of the target source pixel point; (4) the bus control interface module transmits the acquired pixel data of the four adjacent target source pixel points to the calculation unit, and calculates the interpolation operation through the pixel calculation unit therein to obtain the current The target pixel data of the pixel to be generated; (5) transfer the target pixel data to the buffer for buffering; (6) return to perform steps (2)-(5) to perform the next target pixel data of the pixel to be generated is determined until the buffer is full, and the data in the buffer is transmitted to the external memory through the bus control interface module.
本申请实施例中,考虑到待生成像素点在源图像中对应的映射坐标通常是横纵坐标均为非整数的坐标,因此待生成像素点对应在源图像中的源像素点具体为对应的相邻的四个源像素点;由于这四个源像素点分别对应四种位置类型,因此能够一次性地从四个预设存储器中获取对应的四个像素数据,即一个时钟周期内即可读取到所需的四个源像素点的像素数据,提高像素数据的读取效率,高效地确定待生成像素点的目标像素数据,进而提高基于插值运算的图像处理效率。In the embodiment of the present application, considering that the mapping coordinates corresponding to the pixels to be generated in the source image are usually coordinates whose horizontal and vertical coordinates are non-integers, the corresponding pixels to be generated are corresponding to the source pixels in the source image. Four adjacent source pixels; since these four source pixels correspond to four types of positions, the corresponding four pixel data can be obtained from the four preset memories at one time, that is, within one clock cycle The required pixel data of the four source pixel points is read, the reading efficiency of the pixel data is improved, the target pixel data of the pixel point to be generated is efficiently determined, and the image processing efficiency based on the interpolation operation is improved.
可选地,所述根据各个所述目标源像素点在所述源图像中的位置信息,分别从不同的预设存储器中获取各个所述目标源像素点的像素数据,包括:Optionally, according to the position information of each target source pixel in the source image, acquiring the pixel data of each target source pixel from different preset memories, including:
A1:根据各个所述目标源像素点在所述源图像中的所述位置信息,确定各个所述目标源像素点分别对应的预设存储器以及偏移量;A1: Determine the preset memory and offset corresponding to each of the target source pixels according to the position information of each of the target source pixels in the source image;
A2:根据各个所述偏移量,分别确定各个所述目标源像素点的像素数据在各自对应的所述预设存储器中的地址信息;A2: According to each of the offsets, respectively determine the address information of the pixel data of each of the target source pixel points in the corresponding preset memory;
A3:根据各个所述地址信息,分别从各个所述预设存储器中获取对应的各个所述目标源像素点的像素数据。A3: According to each of the address information, acquire pixel data of each of the corresponding target source pixels from each of the preset memories.
在A1中,根据各个目标源像素点在源图像中的位置信息,确定各个目标源像素点对应的位置类型,并根据该位置类型确定对应的预设存储器。之后,再根据各个目标源像素点的位置信息确定该目标源像素点在对应的预设存储器中的偏移量。示例性地,如图2所示,根据目标源像素点A在源图像中所处的位置信息,确定其对应的位置类型为奇数列位置类型,则对应的预设存储器 为奇数列存储器,并根据目标源像素点A的位置信息确定其为源图像中第三个位置类型奇数列位置类型的源像素点,则偏移量为3。In A1, the position type corresponding to each target source pixel is determined according to the position information of each target source pixel in the source image, and the corresponding preset memory is determined according to the position type. After that, the offset of the target source pixel in the corresponding preset memory is determined according to the position information of each target source pixel. Exemplarily, as shown in FIG. 2 , according to the location information of the target source pixel A in the source image, it is determined that its corresponding location type is an odd-numbered column location type, then the corresponding preset memory is an odd-numbered column memory, and According to the position information of the target source pixel A, it is determined that it is the source pixel of the third position type odd-numbered column position type in the source image, and the offset is 3.
在A2中,各个目标源像素点都根据其对应的偏移量以及预设存储器的位宽(以字节位单位),求得该目标源像素点的像素数据在其对应的预设存储器中的地址信息,该地址信息包括该像素数据在预设存储器中的存储地址及在该存储地址中的字节偏移信息。具体地,用offset表示目标源像素点对应的偏移量,W表示预设存储器的位宽,Address表示存储地址,byte_offset表示字节偏移信息,则:In A2, each target source pixel is based on its corresponding offset and the bit width of the preset memory (in units of bytes) to obtain the pixel data of the target source pixel in its corresponding preset memory. The address information includes the storage address of the pixel data in the preset memory and the byte offset information in the storage address. Specifically, offset is used to represent the offset corresponding to the target source pixel, W represents the bit width of the preset memory, Address represents the storage address, and byte_offset represents the byte offset information, then:
Address=offset>>(log 2W) Address=offset>>(log 2 W)
byte_offset=offset%Wbyte_offset=offset%W
其中,“>>”表示右移运算符,“%”表示取余运算符。具体地,以求得的以2为底的预设存储器的位宽W的对数作为目标右移数,将通过二进制表示的偏移量offset向右移动该目标右移数,得到存储地址Address;具体地,将偏移量offset除以预设存储器的位宽W后得到的余数作为字节偏移信息byte_offset。Among them, ">>" represents the right shift operator, and "%" represents the remainder operator. Specifically, taking the obtained logarithm of the bit width W of the preset memory with the base 2 as the target right shift number, the offset represented by binary is shifted to the right by the target right shift number to obtain the storage address Address ; Specifically, the remainder obtained by dividing the offset offset by the bit width W of the preset memory is used as the byte offset information byte_offset.
例如,当预设存储器的位宽为8个字节,则:For example, when the bit width of the preset memory is 8 bytes, then:
Address=offset>>3Address=offset>>3
byte_offset=offset%8byte_offset=offset%8
在A3中,根据A2中求得的各个地址信息,分别从各个预设存储其中获取对应的目标源像素点的像素数据。示例性地,若如图2所示的目标源像素点A在步骤A2求得的存储地址为地址0,字节偏移量3,则对应地在奇数列存储器地址编号为0的存储器中的第三个字节和获取到目标源像素点A的像素数据;同时,目标源像素点B的像素数据也根据其对应的地址信息在偶数列存储器中获取。In A3, according to each address information obtained in A2, the pixel data of the corresponding target source pixel is obtained from each preset storage respectively. Exemplarily, if the storage address obtained by the target source pixel point A in step A2 as shown in FIG. 2 is address 0 and the byte offset is 3, then the corresponding memory address in the memory with the odd-numbered column memory address number 0 is 0. The third byte sums the acquired pixel data of the target source pixel point A; at the same time, the pixel data of the target source pixel point B is also acquired in the even-numbered column memory according to its corresponding address information.
本申请实施例由于能够根据各个目标源像素点在源图像中的位置信息准确地确定每个目标源像素点对应的预设存储器、偏移量及地址信息,因此能够保证目标源像素点的像素数据读取的准确性,进而保证目标像素数据计算的准确性。Since the embodiment of the present application can accurately determine the preset memory, offset and address information corresponding to each target source pixel according to the position information of each target source pixel in the source image, it can ensure that the pixel of the target source pixel is The accuracy of data reading, thereby ensuring the accuracy of target pixel data calculation.
可选地,若所述位置信息包括各个所述目标源像素点的坐标信息,则所述根据各个所述目标源像素点在所述源图像中的所述位置信息,确定各个所述目标源像素点分别对应的预设存储器以及偏移量,包括:Optionally, if the position information includes the coordinate information of each of the target source pixels, then determining each of the target sources according to the position information of each of the target source pixels in the source image. The preset memory and offset corresponding to the pixel points, including:
B1:根据各个所述目标源像素点在所述源图像中的坐标信息,确定各个所述目标源像素点对应的位置类型;B1: Determine the position type corresponding to each of the target source pixels according to the coordinate information of each of the target source pixels in the source image;
B2:根据各个所述目标源像素点在所述源图像中的位置类型,确定各个所述目标源像素点分别对应的预设存储器以及对应的第一偏移量计算公式;B2: Determine the preset memory corresponding to each of the target source pixels and the corresponding first offset calculation formula according to the position type of each of the target source pixels in the source image;
B3:根据所述各个所述目标源像素点的坐标信息及所述第一偏移量计算公式,确定各个所述目标源像素点在各自对应的所述预设存储器中的偏移量。B3: Determine the offset of each of the target source pixels in the corresponding preset memory according to the coordinate information of each of the target source pixels and the first offset calculation formula.
在B1中,每个目标源像素点分别根据其在源图像中的坐标信息,确定该目标源像素点对应的位置类型。示例性地,如图3所示,根据目标源像素点A 的坐标(1,1),确定其为奇数行奇数列位置类型;根据目标源像素点B的坐标(2,1),确定其为奇数行偶数列位置类型;根据目标源像素点C的坐标(1,2),确定其为偶数行奇数列位置类型;根据目标源像素点D的坐标(2,2),确定其为偶数行偶数列位置类型。In B1, each target source pixel is determined according to its coordinate information in the source image to determine the position type corresponding to the target source pixel. Exemplarily, as shown in FIG. 3 , according to the coordinates (1, 1) of the target source pixel A, it is determined to be an odd row and odd column position type; according to the coordinates (2, 1) of the target source pixel B, it is determined It is the position type of odd-numbered rows and even-numbered columns; according to the coordinates (1, 2) of the target source pixel point C, it is determined to be the position type of even-numbered rows and odd-numbered columns; according to the coordinates (2, 2) of the target source pixel point D, it is determined to be an even number Row even column position type.
在B2中,根据各个目标源像素点在源图像中的位置类型,确定各个目标源像素点分别对应的预设存储器,以及对应的用于计算偏移量的第一偏移量计算公式。示例性地,在图3中,目标源像素点A对应的预设存储器为上述的第四预设存储器,目标源像素点B对应的预设存储器为上述的第三预设存储器,目标源像素点C对应的预设存储器为上述的第二预设存储器,目标源像素点D对应的预设存储器为上述的第一预设存储器。可选地,目标源像素点中奇数行奇数列位置类型以及偶数行奇数列类型的目标源像素点(即x轴坐标为奇数的源像素点,如图3所示的A、C)对应的第一偏移量计算公式为:In B2, a preset memory corresponding to each target source pixel and a corresponding first offset calculation formula for calculating the offset are determined according to the position type of each target source pixel in the source image. Exemplarily, in FIG. 3 , the preset memory corresponding to the target source pixel point A is the above-mentioned fourth preset memory, the preset memory corresponding to the target source pixel point B is the above-mentioned third preset memory, and the target source pixel point B is the above-mentioned third preset memory. The preset memory corresponding to point C is the aforementioned second preset memory, and the preset memory corresponding to the target source pixel point D is the aforementioned first preset memory. Optionally, in the target source pixel point, the target source pixel point of the odd-numbered row and odd-numbered column position type and the target source pixel of the even-numbered row and odd-numbered column type (that is, the source pixel point whose x-axis coordinate is an odd number, such as A and C as shown in Figure 3) corresponds to The first offset calculation formula is:
offset=(width>>1)*(y>>1)+(x>>1)offset=(width>>1)*(y>>1)+(x>>1)
源像素点中奇数行偶数列位置类型以及偶数行偶数列类型的目标源像素点(即x轴坐标为偶数的源像素点,如图3所示的B、D)对应的第一偏移量计算公式为:The first offset corresponding to the position type of odd-numbered rows and even-numbered columns in the source pixel point and the target source pixel point of the even-numbered row and even-numbered column type (that is, the source pixel point whose x-axis coordinate is an even number, as shown in B and D in Figure 3) The calculation formula is:
offset=((width>>1)+width[0])*(y>>1)+(x>>1)offset=((width>>1)+width[0])*(y>>1)+(x>>1)
其中,offset表示偏移量,width表示源图像的宽度,>>表示右移运算符,*表示乘号,x表示目标源像素点的横坐标(即列坐标),y表示目标源像素点的纵坐标(即行坐标),width[0]在width为奇数时的值为0、width为偶数时的值为1。Among them, offset represents the offset, width represents the width of the source image, >> represents the right shift operator, * represents the multiplication sign, x represents the abscissa (ie column coordinate) of the target source pixel, and y represents the target source pixel. Vertical coordinate (ie row coordinate), width[0] is 0 when width is odd, and 1 when width is even.
在B3中,根据各个目标源像素点的坐标信息和确定出的第一偏移量计算公式,确定各个目标源像素点在各自对应的预设存储器中的偏移量。示例性地,将如图3所示的目标源像素点A(1,1)、目标源像素点C(1,2)分别代入在步骤B2中确定出的其对应的第一偏移量计算公式offset=(width>>1)*(y>>1)+(x>>1),分别求得目标源像素点A对应在第四预设存储器中的偏移量以及目标源像素点C对应在第二预设存储器中的偏移量;将目标源像素点B(2,1)、目标源像素点D(2,2)分别代入在步骤B2中确定出的其对应的第一偏移量计算公式offset=((width>>1)+width[0])*(y>>1)+(x>>1),分别求得目标源像素点B对应在第三预设存储器中的偏移量以及目标源像素点D对应在第一预设存储器中的偏移量。In B3, the offset of each target source pixel in the corresponding preset memory is determined according to the coordinate information of each target source pixel and the determined first offset calculation formula. Exemplarily, the target source pixel point A(1,1) and the target source pixel point C(1,2) as shown in FIG. 3 are respectively substituted into the corresponding first offset calculation determined in step B2. The formula offset=(width>>1)*(y>>1)+(x>>1), respectively obtain the offset corresponding to the target source pixel A in the fourth preset memory and the target source pixel C Corresponding to the offset in the second preset memory; substitute the target source pixel point B(2,1) and the target source pixel point D(2,2) into the corresponding first offset determined in step B2 respectively. The offset calculation formula offset=((width>>1)+width[0])*(y>>1)+(x>>1), respectively obtain the target source pixel point B corresponding to the third preset memory and the target source pixel point D corresponds to the offset in the first preset memory.
可选地,若所述至少两个相邻的目标源像素点包括第一目标源像素点及除所述第一目标源像素点以外的第二目标源像素点,所述位置信息包括所述第一目标源像素点的坐标信息及所述第二目标源像素点相对于所述第一目标源像素点的相对位置信息,则所述根据各个所述目标源像素点在所述源图像中的所述位置信息,确定各个所述目标源像素点分别对应的预设存储器以及偏移量,包括:Optionally, if the at least two adjacent target source pixels include a first target source pixel and a second target source pixel other than the first target source pixel, the position information includes the The coordinate information of the first target source pixel point and the relative position information of the second target source pixel point relative to the first target source pixel point, then according to each target source pixel point in the source image The position information of , determine the preset memory and offset corresponding to each of the target source pixels, including:
C1:根据所述第一目标源像素点的坐标信息及所述第二目标源像素点相对 于所述第一目标源像素点的相对位置信息,确定各个所述目标源像素点对应的位置类型及对应的第二偏移量计算公式;C1: Determine the position type corresponding to each target source pixel according to the coordinate information of the first target source pixel and the relative position information of the second target source pixel relative to the first target source pixel and the corresponding second offset calculation formula;
C2:根据所述第一目标源像素点的坐标信息及各个所述第二偏移量计算公式,确定各个目标源像素点在各自对应的所述预设存储器中的偏移量。C2: Determine the offset of each target source pixel in the corresponding preset memory according to the coordinate information of the first target source pixel and each of the second offset calculation formulas.
本申请实施例中,具体可以确定出的至少两个相邻的目标源像素点中选取坐标值较小的源像素点作为第一目标源像素点,其它目标源像素点作为第二目标源像素点。可选地,所述至少两个相邻的目标源像素点具体包括四个相邻的目标源像素点,则具体以位于左上角的源像素点作为第一目标源像素点,其它三个目标源像素点作为第二目标源像素点;根据该第一目标源像素点的坐标信息及第二目标源像素点与该第一目标源像素点的相对位置,确定对应的位置类型和第二偏移量计算公式;之后,根据第一目标源像素点的坐标及确定出的与四个目标源像素点分别对应的四个第二偏移量计算公式,确定四个目标源像素点对应在各自的预设存储器中的偏移量。可选地,该第二偏移量计算公式的确定如下:In the embodiment of the present application, the source pixel with a smaller coordinate value may be selected as the first target source pixel among the at least two adjacent target source pixels determined, and the other target source pixels as the second target source pixel point. Optionally, the at least two adjacent target source pixels specifically include four adjacent target source pixels, then the source pixel located in the upper left corner is specifically used as the first target source pixel, and the other three target The source pixel is used as the second target source pixel; according to the coordinate information of the first target source pixel and the relative position of the second target source pixel and the first target source pixel, the corresponding position type and the second offset are determined. The displacement calculation formula; then, according to the coordinates of the first target source pixel point and the determined four second offset calculation formulas corresponding to the four target source pixel points, it is determined that the four target source pixel points correspond to the respective The offset in the preset memory for . Optionally, the second offset calculation formula is determined as follows:
左上角目标源像素点的第二偏移量计算公式:The formula for calculating the second offset of the target source pixel in the upper left corner:
当sx为奇数时,offset=(width>>1)*(sy>>1)+(sx>>1)When sx is odd, offset=(width>>1)*(sy>>1)+(sx>>1)
当sx为偶数时,offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)When sx is an even number, offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)
右上角目标源像素点的第二偏移量计算公式:The formula for calculating the second offset of the target source pixel in the upper right corner:
当sx为奇数时,offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)+1When sx is odd, offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)+1
当sx为偶数时,offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)When sx is an even number, offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)
左下角目标源像素点的第二偏移量计算公式:The formula for calculating the second offset of the target source pixel in the lower left corner:
当sx为偶数、sy为偶数时:When sx is even and sy is even:
offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)
当sx为奇数、sy为偶数时:When sx is odd and sy is even:
offset=(width>>1)*(sy>>1)+(sx>>1)offset=(width>>1)*(sy>>1)+(sx>>1)
当sx为偶数、sy为奇数时:When sx is even and sy is odd:
offset=((width>>1)+width[0])*((sy>>1)+1)+(sx>>1)offset=((width>>1)+width[0])*((sy>>1)+1)+(sx>>1)
当sx为奇数、sy为奇数时:When sx is odd and sy is odd:
offset=(width>>1)*((sy>>1)+1)+(sx>>1)offset=(width>>1)*((sy>>1)+1)+(sx>>1)
右下角目标源像素点的第二偏移量计算公式:The formula for calculating the second offset of the target source pixel in the lower right corner:
当sx为偶数、sy为偶数时:When sx is even and sy is even:
offset=(width>>1)*(sy>>1)+(sx>>1)offset=(width>>1)*(sy>>1)+(sx>>1)
当sx为奇数、sy为偶数时:When sx is odd and sy is even:
offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)+1offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)+1
当sx为奇数、sy为奇数时:When sx is odd and sy is odd:
offset=(width>>1)*((sy>>1)+1)+(sx>>1)offset=(width>>1)*((sy>>1)+1)+(sx>>1)
当sx为偶数、sy为奇数时:When sx is even and sy is odd:
offset=((width>>1)+width[0])*((sy>>1)+1)+(sx>>1)+1offset=((width>>1)+width[0])*((sy>>1)+1)+(sx>>1)+1
其中,offset表示偏移量,width表示源图像的宽度,>>表示右移运算符, *表示乘号,sx表示第一目标源像素点的横坐标(即列坐标),sy表示第一目标源像素点的纵坐标(即行坐标),width[0]在width为奇数时的值为0、width为偶数时的值为1。Among them, offset represents the offset, width represents the width of the source image, >> represents the right shift operator, * represents the multiplication sign, sx represents the abscissa (ie the column coordinate) of the first target source pixel, and sy represents the first target The ordinate (ie row coordinate) of the source pixel, width[0] is 0 when width is odd, and 1 when width is even.
示例性地,如图3所示的目标源像素点A为第一目标源像素点,其坐标为(1,1),目标源像素点B、C、D为第二目标源像素点。在C1中,根据第一目标源像素点A(1,1),确定sx=1,sy=1,sx、sy均为奇数;确定目标源像素点A对应的位置类型为奇数行奇数列位置类型且对应的第二偏移量计算公式为:offset=(width>>1)*(sy>>1)+(sx>>1);确定目标源像素点B的位置类型为奇数行偶数列位置类型且对应的第二偏移量计算公式为:offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)+1;确定目标源像素点C的位置类型为偶数行奇数列位置类型且对应的第二偏移量计算公式为:offset=(width>>1)*((sy>>1)+1)+(sx>>1);确定目标源像素点D的位置类型为偶数行偶数列位置类型且对应的第二偏移量计算公式为:offset=(width>>1)*((sy>>1)+1)+(sx>>1)。之后,在C2中,将目标源像素点A的坐标sx=1,sy=1代入确定出的四个第二偏移量计算公式,分别得到目标源像素点A、B、C、D对应的偏移量。Exemplarily, as shown in FIG. 3 , the target source pixel A is the first target source pixel, and its coordinates are (1, 1), and the target source pixels B, C, and D are the second target source pixels. In C1, according to the first target source pixel point A(1,1), it is determined that sx=1, sy=1, and both sx and sy are odd numbers; it is determined that the position type corresponding to the target source pixel point A is an odd-numbered row and an odd-numbered column position type and the corresponding second offset calculation formula is: offset=(width>>1)*(sy>>1)+(sx>>1); determine that the position type of the target source pixel B is odd-numbered rows and even-numbered columns The calculation formula of the position type and the corresponding second offset is: offset=((width>>1)+width[0])*(sy>>1)+(sx>>1)+1; determine the target source pixel The position type of point C is the position type of even row and odd column and the corresponding second offset calculation formula is: offset=(width>>1)*((sy>>1)+1)+(sx>>1) ; Determine that the position type of the target source pixel point D is the position type of the even-numbered row and even-numbered column and the corresponding second offset calculation formula is: offset=(width>>1)*((sy>>1)+1)+( sx>>1). After that, in C2, the coordinates sx=1 and sy=1 of the target source pixel A are substituted into the four determined second offset calculation formulas to obtain the corresponding target source pixels A, B, C, and D respectively. Offset.
本申请实施例中,具体通过各个目标源像素点的坐标信息及第一偏移量计算公式来确定各个目标源像素点对应的偏移量,或者,具体通过确定出的目标源像素点中的第一目标源像素点的坐标信息、其它目标源像素点与该第一目标源像素点的相对位置、以及确定出的第二偏移量计算公式来确定各个目标源像素点对应的偏移量,保证源像素点的像素数据读取的准确性,进而保证目标像素数据计算的准确性。In the embodiment of the present application, the offset corresponding to each target source pixel is specifically determined by the coordinate information of each target source pixel and the first offset calculation formula, or, specifically by the determined target source pixel in the The coordinate information of the first target source pixel, the relative positions of other target source pixels and the first target source pixel, and the determined second offset calculation formula to determine the offset corresponding to each target source pixel , to ensure the accuracy of reading the pixel data of the source pixel point, and then to ensure the accuracy of the calculation of the target pixel data.
图10示出了本申请实施例提供的第三种图像处理方法的流程示意图,该图像处理方法应用于空间变换网络(Spatial Transformer Network,STN),该STN的架构图如图11所示。图11中的源数据即为源图像数据,包括了源图像中每个源像素点的像素数据,目标数据即为待生成图像逐一生成目标像素数据后得到的图像数据,称为目标图像数据,该目标图像数据中的每一个像素点填充了对应的一个目标像素数据。如图10所述的图像处理方法详述如下:FIG. 10 shows a schematic flowchart of a third image processing method provided by an embodiment of the present application. The image processing method is applied to a Spatial Transformer Network (STN), and an architecture diagram of the STN is shown in FIG. 11 . The source data in Figure 11 is the source image data, including the pixel data of each source pixel in the source image, and the target data is the image data obtained by generating the target pixel data one by one in the image to be generated, which is called target image data. Each pixel in the target image data is filled with a corresponding target pixel data. The image processing method shown in Figure 10 is detailed as follows:
在S1001中,通过参数预测,确定STN的目标参数。In S1001, the target parameters of the STN are determined through parameter prediction.
在STN网络中,待生成图像的坐标(x,y)与其在源图像中对应的映射坐标(x',y')存在如下的坐标映射关系:In the STN network, the coordinates (x, y) of the image to be generated and their corresponding mapping coordinates (x', y') in the source image have the following coordinate mapping relationship:
Figure PCTCN2021088428-appb-000001
Figure PCTCN2021088428-appb-000001
其中,a、b、c、d、e、f为六个目标参数,通过这六个目标参数可以反映待生成图像与源图像之间的平移、缩放、旋转等变换关系。具体地,可以通过训练样本对STN中的连续若干层神经网络层(包括卷积层、连接层)进行训练处理实现参数预测,得到STN的目标参数a、b、c、d、e、f。Among them, a, b, c, d, e, and f are six target parameters, which can reflect the transformation relationship between the image to be generated and the source image, such as translation, scaling, and rotation. Specifically, parameter prediction can be achieved by training several consecutive neural network layers (including convolutional layers and connection layers) in the STN through training samples, and the target parameters a, b, c, d, e, and f of the STN can be obtained.
在S1002中,根据所述目标参数,确定与待生成图像中的待生成像素点对应的源图像的映射坐标。In S1002, according to the target parameter, the mapping coordinates of the source image corresponding to the to-be-generated pixel points in the to-be-generated image are determined.
根据确定出的目标参数a、b、c、d、e、f及如上所示的坐标映射关系,确定出待生成像素点(x,y)对应在源图像中的映射坐标(x',y')。According to the determined target parameters a, b, c, d, e, f and the coordinate mapping relationship shown above, determine the mapping coordinates (x', y) of the pixel to be generated (x, y) corresponding to the source image ').
在S1003中,根据所述映射坐标,确定所述四个相邻的目标源像素点。In S1003, the four adjacent target source pixels are determined according to the mapping coordinates.
确定出的映射坐标(x',y')中,x'和y'为小数,而源图像中只有横纵坐标均为整数的源像素点的像素数据,因此需要根据映射坐标来确定与该映射坐标最接近的四个相邻的目标源像素点。示例性地,如图3所示,若待生成像素点A'对应在源图像中的映射坐标为(1.6,1.4),则在源图像中对应的四个相邻的目标源像素点为A(1,1)、B(2,1)、C(1,2)、D(2,2)。In the determined mapping coordinates (x', y'), x' and y' are decimals, and in the source image, there is only the pixel data of the source pixels whose horizontal and vertical coordinates are integers. Map the four adjacent target source pixels with the closest coordinates. Exemplarily, as shown in FIG. 3 , if the mapping coordinates corresponding to the pixel point A' to be generated in the source image are (1.6, 1.4), then the corresponding four adjacent target source pixel points in the source image are A. (1,1), B(2,1), C(1,2), D(2,2).
在S1004中,根据所述四个相邻的目标源像素点在所述源图像中的位置信息,分别从第一预设存储器、第二预设存储器、第三预设存储器及第四预设存储器获取各个所述目标源像素点的像素数据;其中,所述第一预设存储器用于存储在所述源图像中行位置序号为偶数且列位置序号为偶数的源像素点的像素数据,所述第二预设存储器用于存储在所述源图像中行位置序号为偶数且列位置序号为奇数的源像素点的像素数据,所述第三预设存储器用于存储在所述源图像中行位置序号为奇数且列位置序号为偶数的源像素点的像素数据,所述第四预设存储器用于存储在所述源图像中行位置序号为奇数且列位置序号为奇数的源像素点的像素数据。In S1004, according to the position information of the four adjacent target source pixels in the source image, the first preset memory, the second preset memory, the third preset memory and the fourth preset memory are respectively obtained. The memory acquires the pixel data of each of the target source pixel points; wherein, the first preset memory is used to store the pixel data of the source pixel points whose row position serial numbers are even and column position serial numbers are even in the source image, so The second preset memory is used to store the pixel data of the source pixels whose row position serial numbers are even and the column position serial numbers are odd in the source image, and the third preset memory is used to store the row positions in the source image. The pixel data of the source pixels whose serial numbers are odd and the column position serial numbers are even, the fourth preset memory is used to store the pixel data of the source pixels whose row position serial numbers are odd and the column position serial numbers are odd in the source image .
本申请实施例的步骤S1004与上述的步骤S402相同,具体请参见上述对步骤S402的相关描述,此处不赘述。Step S1004 in this embodiment of the present application is the same as the above-mentioned step S402. For details, please refer to the above-mentioned related description of the step S402, which will not be repeated here.
在S1005中,根据所述四个相邻的目标源像素点的像素数据进行双线性插值运算,确定所述待生成像素点的目标像素数据。In S1005, a bilinear interpolation operation is performed according to the pixel data of the four adjacent target source pixel points, and the target pixel data of the to-be-generated pixel point is determined.
示例性地,如图3所示的待生成像素点A'对应在源图像中的四个相邻的目标源像素点为A(1,1)、B(2,1)、C(1,2)、D(2,2),设其对应的像素数据分别用dataA、dataB、dataC、dataD表示,则待生成像素点A'的目标像素数据data_A'的计算公式如下:Exemplarily, as shown in FIG. 3, the pixel point A' to be generated corresponds to the four adjacent target source pixel points in the source image as A(1,1), B(2,1), C(1, 2), D(2,2), suppose its corresponding pixel data are represented by dataA, dataB, dataC, dataD respectively, then the calculation formula of the target pixel data data_A' of the pixel point A' to be generated is as follows:
data_A'=(1-0.6)×(1-0.4)×dataAdata_A'=(1-0.6)×(1-0.4)×dataA
+(1-0.6)×(1-0.6)×dataB+(1-0.6)×(1-0.6)×dataB
+(1-0.4)×(1-0.4)×dataC+(1-0.4)×(1-0.4)×dataC
+(1-0.4)×(1-0.6)×dataD+(1-0.4)×(1-0.6)×dataD
本申请实施例中,将图像处理方法具体应用于STN中,STN所需处理的图像数据量一般比较庞大,且每个待生成像素点的目标像素数据需要根据四个相邻的目标源像素点的像素数据进行插值运算确定。由于通过本申请实施例的方法,能够一次性从不同的预设存储器中同时获取与待生成像素点对应的四个相邻的源像素点的像素数据,从而快速地确定目标像素数据,因此能够极大地提高STN的处理效率。In the embodiment of the present application, the image processing method is specifically applied to the STN. The amount of image data to be processed by the STN is generally relatively large, and the target pixel data of each pixel to be generated needs to be based on four adjacent target source pixels. The pixel data is determined by interpolation. Because through the method of the embodiment of the present application, the pixel data of the four adjacent source pixel points corresponding to the pixel points to be generated can be simultaneously acquired from different preset memories at one time, so that the target pixel data can be quickly determined, so it is possible to Greatly improve the processing efficiency of STN.
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence numbers of the steps in the above embodiments does not mean the sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
实施例二:Embodiment 2:
图12示出了本申请实施例提供的一种图像处理装置的结构示意图,为了便于说明,仅示出了与本申请实施例相关的部分:FIG. 12 shows a schematic structural diagram of an image processing apparatus provided by an embodiment of the present application. For the convenience of description, only parts related to the embodiment of the present application are shown:
该图像处理装置包括:目标源像素点确定单元121、像素数据获取单元122、目标像素数据确定单元123。其中:The image processing apparatus includes: a target source pixel point determination unit 121 , a pixel data acquisition unit 122 , and a target pixel data determination unit 123 . in:
目标源像素点确定单元121,用于确定与待生成图像中的待生成像素点对应的至少两个相邻的目标源像素点,所述目标源像素点为源图像中的源像素点。The target source pixel point determination unit 121 is configured to determine at least two adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image, where the target source pixel points are the source pixel points in the source image.
像素数据获取单元122,用于根据各个所述目标源像素点在所述源图像中的位置信息,分别从不同的预设存储器中获取各个所述目标源像素点的像素数据,其中每个所述预设存储器分别存储一种位置类型的源像素点,所述位置类型根据所述源像素点在源图像中的位置信息确定。The pixel data obtaining unit 122 is configured to obtain the pixel data of each target source pixel from different preset memories according to the position information of each target source pixel in the source image, wherein each target source pixel is The preset memory respectively stores source pixels of one type of location, and the location type is determined according to the location information of the source pixels in the source image.
目标像素数据确定单元123,用于根据各个所述目标源像素点的像素数据进行插值运算,确定所述待生成像素点的目标像素数据。The target pixel data determination unit 123 is configured to perform an interpolation operation according to the pixel data of each of the target source pixel points, and determine the target pixel data of the to-be-generated pixel point.
可选地,所述图像处理装置还包括:Optionally, the image processing apparatus further includes:
第一获取单元,用于获取源图像,所述源图像中的各个源像素点均包含了各自的像素数据;a first acquiring unit, configured to acquire a source image, where each source pixel in the source image contains respective pixel data;
第一存储单元,用于根据所述源图像中的各个源像素点对应的位置类型,将所述源图像中的各个源像素点的像素数据存储于与所述位置类型对应的预设存储器中。a first storage unit, configured to store the pixel data of each source pixel in the source image in a preset memory corresponding to the location type according to the location type corresponding to each source pixel in the source image .
可选地,所述源像素点确定单元121,具体用于确定与待生成图像中的待生成像素点对应的四个相邻的目标源像素点;Optionally, the source pixel point determination unit 121 is specifically configured to determine four adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image;
对应地,所述像素数据获取单元122,具体用于根据所述四个相邻的目标源像素点在所述源图像中的位置信息,分别从第一预设存储器、第二预设存储器、第三预设存储器及第四预设存储器获取各个所述目标源像素点的像素数据;其中,所述第一预设存储器用于存储在所述源图像中行位置序号为偶数且列位置序号为偶数的源像素点的像素数据,所述第二预设存储器用于存储在所述源图像中行位置序号为偶数且列位置序号为奇数的源像素点的像素数据,所述第三预设存储器用于存储在所述源图像中行位置序号为奇数且列位置序号为偶数的源像素点的像素数据,所述第四预设存储器用于存储在所述源图像中行位置序号为奇数且列位置序号为奇数的源像素点的像素数据。Correspondingly, the pixel data acquisition unit 122 is specifically configured to obtain information from the first preset memory, the second preset memory, the The third preset memory and the fourth preset memory acquire the pixel data of each of the target source pixels; wherein, the first preset memory is used for storing the row position serial number is even and the column position serial number is even in the source image The pixel data of the even-numbered source pixels, the second preset memory is used to store the pixel data of the source pixels whose row position serial numbers are even and the column position serial numbers are odd in the source image, and the third preset memory for storing pixel data of source pixels whose row position serial numbers are odd and column position serial numbers are even in the source image, and the fourth preset memory is used for storing odd row position serial numbers and column positions in the source image The pixel data of the odd-numbered source pixel.
可选地,所述图像处理装置还包括:Optionally, the image processing apparatus further includes:
第二获取单元,用于获取源图像,所述源图像中的各个源像素点均包含了各自的像素数据;a second acquiring unit, configured to acquire a source image, where each source pixel in the source image contains respective pixel data;
第一分类单元,用于根据所述源图像中的各个源像素点对应的行位置序号的奇偶性,对应将所述源图像中的各个源像素点的像素数据分为偶数行像素数据及奇数行像素数据;The first classification unit is used to correspondingly divide the pixel data of each source pixel in the source image into even-numbered row pixel data and odd-numbered pixel data according to the parity of the row position serial numbers corresponding to each source pixel in the source image. row pixel data;
第二存储单元,根据所述偶数行像素数据中各个源像素点对应的列位置序号的奇偶性,对应将所述偶数行像素数据选择存储于第一预设存储器或者第二预设存储器;The second storage unit, according to the parity of the column position serial number corresponding to each source pixel point in the even-numbered row pixel data, correspondingly selects and stores the even-numbered row pixel data in the first preset memory or the second preset memory;
第三存储单元,根据所述奇数行像素数据中各个源像素点对应的列位置序号的奇偶性,对应将所述奇数行像素数据选择存储于第三预设存储器或者第四预设存储器。The third storage unit selects and stores the odd row pixel data in the third preset memory or the fourth preset memory according to the parity of the column position serial numbers corresponding to each source pixel in the odd row pixel data.
可选地,若所述图像处理装置具体应用于空间变换网络,则所述图像处理装置还包括:Optionally, if the image processing apparatus is specifically applied to a spatial transformation network, the image processing apparatus further includes:
目标参数确定单元,用于通过参数预测,确定所述空间变换网络的目标参数;a target parameter determination unit, configured to determine the target parameter of the spatial transformation network through parameter prediction;
对应地,所述源像素点确定单元121包括映射坐标确定模块和源像素点确定模块:Correspondingly, the source pixel point determination unit 121 includes a mapping coordinate determination module and a source pixel point determination module:
映射坐标确定模块,用于根据所述目标参数,确定与待生成图像中的待生成像素点对应的源图像的映射坐标;a mapping coordinate determination module, configured to determine, according to the target parameter, the mapping coordinates of the source image corresponding to the to-be-generated pixels in the to-be-generated image;
源像素点确定模块,用于根据所述映射坐标,确定所述四个相邻的目标源像素点;a source pixel point determination module, configured to determine the four adjacent target source pixel points according to the mapping coordinates;
对应地,所述目标像素数据确定单元123,具体用于根据所述四个相邻的目标源像素点的像素数据进行双线性插值运算,确定所述待生成像素点的目标像素数据。Correspondingly, the target pixel data determining unit 123 is specifically configured to perform a bilinear interpolation operation according to the pixel data of the four adjacent target source pixel points, and determine the target pixel data of the to-be-generated pixel point.
可选地,所述像素数据获取单元122包括偏移量确定模块、地址信息确定模块和像素数据获取模块:Optionally, the pixel data acquisition unit 122 includes an offset determination module, an address information determination module and a pixel data acquisition module:
偏移量确定模块,用于根据各个所述目标源像素点在所述源图像中的所述位置信息,确定各个所述源像素点分别对应的预设存储器以及偏移量;an offset determination module, configured to determine a preset memory and an offset corresponding to each of the source pixels according to the position information of each of the target source pixels in the source image;
地址信息确定模块,用于根据各个所述偏移量,分别确定各个所述目标源像素点的像素数据在各自对应的所述预设存储器中的地址信息;The address information determination module is configured to determine, according to each of the offsets, the address information of the pixel data of each of the target source pixel points in the respective corresponding preset memories;
像素数据获取模块,用于根据各个所述地址信息,分别从各个所述预设存储器中获取对应的各个所述目标源像素点的像素数据。A pixel data acquisition module, configured to acquire pixel data of each of the corresponding target source pixels from each of the preset memories according to each of the address information.
可选地,若所述位置信息包括各个所述目标源像素点的坐标信息,则所述偏移量确定模块,具体用于根据各个所述目标源像素点在所述源图像中的坐标信息,确定各个所述目标源像素点对应的位置类型;根据各个所述目标源像素点在所述源图像中的位置类型,确定各个所述目标源像素点分别对应的预设存储器以及对应的第一偏移量计算公式;根据所述各个所述目标源像素点的坐标信息及所述第一偏移量计算公式,确定各个所述目标源像素点在各自对应的所述预设存储器中的偏移量;Optionally, if the position information includes coordinate information of each of the target source pixels, the offset determination module is specifically configured to, according to the coordinate information of each of the target source pixels in the source image, , determine the position type corresponding to each target source pixel point; according to the position type of each target source pixel point in the source image, determine the preset memory corresponding to each target source pixel point and the corresponding first an offset calculation formula; according to the coordinate information of each of the target source pixels and the first offset calculation formula, determine the corresponding position of each target source pixel in the corresponding preset memory. Offset;
可选地,若所述至少两个相邻的目标源像素点包括第一目标源像素点及除所述第一目标源像素点以外的第二目标源像素点,所述位置信息包括所述第一目标源像素点的坐标信息及所述第二目标源像素点相对于所述第一目标源像素点的相对位置信息,则所述偏移量确定模块,具体用于根据所述第一目标源像素点的坐标信息及所述第二目标源像素点相对于所述第一目标源像素点的相对位置信息,确定各个所述目标源像素点对应的位置类型及对应的第二偏移量计算公式;根据所述第一目标源像素点的坐标信息及各个所述第二偏移量计算公式,确定各个所述目标源像素点在各自对应的所述预设存储器中的偏移 量。Optionally, if the at least two adjacent target source pixels include a first target source pixel and a second target source pixel other than the first target source pixel, the position information includes the The coordinate information of the first target source pixel point and the relative position information of the second target source pixel point with respect to the first target source pixel point, the offset determination module is specifically used for determining the offset according to the first target source pixel point. The coordinate information of the target source pixel point and the relative position information of the second target source pixel point relative to the first target source pixel point, determine the position type corresponding to each target source pixel point and the corresponding second offset according to the coordinate information of the first target source pixel and each of the second offset calculation formulas, determine the offset of each of the target source pixels in the corresponding preset memory .
需要说明的是,上述装置/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。It should be noted that the information exchange, execution process and other contents between the above-mentioned devices/units are based on the same concept as the method embodiments of the present application. For specific functions and technical effects, please refer to the method embodiments section. It is not repeated here.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned functions can be allocated to different functional units, Module completion, that is, dividing the internal structure of the device into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment may be integrated in one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit, and the above-mentioned integrated units may adopt hardware. It can also be realized in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing from each other, and are not used to limit the protection scope of the present application. For the specific working processes of the units and modules in the above-mentioned system, reference may be made to the corresponding processes in the foregoing method embodiments, which will not be repeated here.
实施例三:Embodiment three:
图13是本申请一实施例提供的终端设备的示意图。如图13所示,该实施例的终端设备13包括:处理器130、存储器131以及存储在所述存储器131中并可在所述处理器130上运行的计算机程序132,例如图像处理程序。所述处理器130执行所述计算机程序132时实现上述各个图像处理方法实施例中的步骤,例如图1所示的步骤S101至S103。或者,所述处理器130执行所述计算机程序132时实现上述各装置实施例中各模块/单元的功能,例如图12所示单元121至123的功能。FIG. 13 is a schematic diagram of a terminal device provided by an embodiment of the present application. As shown in FIG. 13 , the terminal device 13 in this embodiment includes: a processor 130 , a memory 131 , and a computer program 132 stored in the memory 131 and executable on the processor 130 , such as an image processing program. When the processor 130 executes the computer program 132 , the steps in each of the above image processing method embodiments are implemented, for example, steps S101 to S103 shown in FIG. 1 . Alternatively, when the processor 130 executes the computer program 132, the functions of the modules/units in each of the foregoing apparatus embodiments, for example, the functions of the units 121 to 123 shown in FIG. 12, are implemented.
示例性的,所述计算机程序132可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器131中,并由所述处理器130执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序132在所述终端设备13中的执行过程。例如,所述计算机程序132可以被分割成目标源像素点确定单元、像素数据获取单元、目标像素数据确定单元,各单元具体功能如下:Exemplarily, the computer program 132 may be divided into one or more modules/units, and the one or more modules/units are stored in the memory 131 and executed by the processor 130 to complete the this application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program 132 in the terminal device 13 . For example, the computer program 132 can be divided into a target source pixel point determination unit, a pixel data acquisition unit, and a target pixel data determination unit. The specific functions of each unit are as follows:
目标源像素点确定单元,用于确定与待生成图像中的待生成像素点对应的至少两个相邻的目标源像素点,所述目标源像素点为源图像中的源像素点;a target source pixel point determination unit, configured to determine at least two adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image, where the target source pixel points are the source pixel points in the source image;
像素数据获取单元,用于根据各个所述目标源像素点在所述源图像中的位置信息,分别从不同的预设存储器中获取各个所述目标源像素点的像素数据,其中每个所述预设存储器分别存储一种位置类型的源像素点,所述位置类型根据所述源像素点在源图像中的位置信息确定;A pixel data acquisition unit, configured to acquire pixel data of each of the target source pixels from different preset memories according to the position information of each of the target source pixels in the source image, wherein each of the target source pixels The preset memories respectively store source pixels of a position type, and the position type is determined according to the position information of the source pixels in the source image;
目标像素数据确定单元,用于根据各个所述目标源像素点的像素数据进行插值运算,确定所述待生成像素点的目标像素数据。The target pixel data determination unit is configured to perform interpolation operation according to the pixel data of each of the target source pixel points, and determine the target pixel data of the to-be-generated pixel point.
所述终端设备13可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述终端设备可包括,但不仅限于,处理器130、存储器131。 本领域技术人员可以理解,图13仅仅是终端设备13的示例,并不构成对终端设备13的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述终端设备还可以包括输入输出设备、网络接入设备、总线等。The terminal device 13 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server. The terminal device may include, but is not limited to, the processor 130 and the memory 131 . Those skilled in the art can understand that FIG. 13 is only an example of the terminal device 13, and does not constitute a limitation on the terminal device 13, and may include more or less components than the one shown, or combine some components, or different components For example, the terminal device may further include an input and output device, a network access device, a bus, and the like.
所称处理器130可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The so-called processor 130 may be a central processing unit (Central Processing Unit, CPU), or other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
所述存储器131可以是所述终端设备13的内部存储单元,例如终端设备13的硬盘或内存。所述存储器131也可以是所述终端设备13的外部存储设备,例如所述终端设备13上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器131还可以既包括所述终端设备13的内部存储单元也包括外部存储设备。所述存储器131用于存储所述计算机程序以及所述终端设备所需的其他程序和数据。所述存储器131还可以用于暂时地存储已经输出或者将要输出的数据。The memory 131 may be an internal storage unit of the terminal device 13 , such as a hard disk or a memory of the terminal device 13 . The memory 131 can also be an external storage device of the terminal device 13, such as a plug-in hard disk equipped on the terminal device 13, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, Flash Card, etc. Further, the memory 131 may also include both an internal storage unit of the terminal device 13 and an external storage device. The memory 131 is used to store the computer program and other programs and data required by the terminal device. The memory 131 may also be used to temporarily store data that has been output or will be output.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned functions can be allocated to different functional units, Module completion, that is, dividing the internal structure of the device into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment may be integrated in one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit, and the above-mentioned integrated units may adopt hardware. It can also be realized in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing from each other, and are not used to limit the protection scope of the present application. For the specific working processes of the units and modules in the above-mentioned system, reference may be made to the corresponding processes in the foregoing method embodiments, which will not be repeated here.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the foregoing embodiments, the description of each embodiment has its own emphasis. For parts that are not described or described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.

Claims (10)

  1. 一种图像处理方法,其特征在于,包括:An image processing method, comprising:
    确定与待生成图像中的待生成像素点对应的至少两个相邻的目标源像素点,所述目标源像素点为源图像中的源像素点;Determine at least two adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image, where the target source pixel points are the source pixel points in the source image;
    根据各个所述目标源像素点在所述源图像中的位置信息,分别从不同的预设存储器中获取各个所述目标源像素点的像素数据,其中每个所述预设存储器分别存储一种位置类型的源像素点,所述位置类型根据所述源像素点在源图像中的位置信息确定;According to the position information of each target source pixel in the source image, the pixel data of each target source pixel is obtained from different preset memories, wherein each of the preset memories stores a The source pixel point of the position type, the position type is determined according to the position information of the source pixel point in the source image;
    根据各个所述目标源像素点的像素数据进行插值运算,确定所述待生成像素点的目标像素数据。An interpolation operation is performed according to the pixel data of each of the target source pixel points, and the target pixel data of the to-be-generated pixel point is determined.
  2. 如权利要求1所述的图像处理方法,其特征在于,在所述确定与待生成图像中的待生成像素点对应的至少两个相邻的目标源像素点之前,还包括:The image processing method according to claim 1, wherein before the determining at least two adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image, the method further comprises:
    获取源图像,所述源图像中的各个源像素点均包含了各自的像素数据;Acquiring a source image, where each source pixel in the source image contains respective pixel data;
    根据所述源图像中的各个源像素点对应的位置类型,将所述源图像中的各个源像素点的像素数据存储于与所述位置类型对应的预设存储器中。According to the position type corresponding to each source pixel in the source image, the pixel data of each source pixel in the source image is stored in a preset memory corresponding to the position type.
  3. 如权利要求1所述的图像处理方法,其特征在于,所述确定与待生成图像中的待生成像素点对应的至少两个相邻的目标源像素点,包括:The image processing method according to claim 1, wherein the determining at least two adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image comprises:
    确定与待生成图像中的待生成像素点对应的四个相邻的目标源像素点;Determine four adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image;
    所述根据各个所述目标源像素点在所述源图像中的位置信息,分别从不同的预设存储器中获取各个所述目标源像素点的像素数据,包括:The obtaining pixel data of each target source pixel from different preset memories according to the position information of each target source pixel in the source image, including:
    根据所述四个相邻的目标源像素点在所述源图像中的位置信息,分别从第一预设存储器、第二预设存储器、第三预设存储器及第四预设存储器获取各个所述目标源像素点的像素数据;其中,所述第一预设存储器用于存储在所述源图像中行位置序号为偶数且列位置序号为偶数的源像素点的像素数据,所述第二预设存储器用于存储在所述源图像中行位置序号为偶数且列位置序号为奇数的源像素点的像素数据,所述第三预设存储器用于存储在所述源图像中行位置序号为奇数且列位置序号为偶数的源像素点的像素数据,所述第四预设存储器用于存储在所述源图像中行位置序号为奇数且列位置序号为奇数的源像素点的像素数据。According to the position information of the four adjacent target source pixel points in the source image, obtain each The pixel data of the target source pixel; wherein, the first preset memory is used to store the pixel data of the source pixel whose row position sequence number is even and the column position sequence number is even in the source image, and the second preset memory It is assumed that the memory is used to store the pixel data of the source pixel points whose row position serial numbers are even and the column position serial numbers are odd in the source image, and the third preset memory is used for storing the row position serial numbers in the source image are odd and odd. The pixel data of the source pixels whose column position numbers are even, and the fourth preset memory is used to store the pixel data of the source pixels whose row position numbers are odd and the column position numbers are odd in the source image.
  4. 如权利要求3所述的图像处理方法,其特征在于,在所述确定与待生成图像中的待生成像素点对应的四个相邻的目标源像素点之前,还包括:The image processing method according to claim 3, characterized in that before said determining the four adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image, the method further comprises:
    获取源图像,所述源图像中的各个源像素点均包含了各自的像素数据;Acquiring a source image, where each source pixel in the source image contains respective pixel data;
    根据所述源图像中的各个源像素点对应的行位置序号的奇偶性,对应将所述源图像中的各个源像素点的像素数据分为偶数行像素数据及奇数行像素数据;According to the parity of the row position serial number corresponding to each source pixel in the source image, correspondingly divide the pixel data of each source pixel in the source image into even-numbered row pixel data and odd-numbered row pixel data;
    根据所述偶数行像素数据中各个源像素点对应的列位置序号的奇偶性,对应将所述偶数行像素数据选择存储于第一预设存储器或者第二预设存储器;According to the parity of the column position serial number corresponding to each source pixel point in the even-numbered row pixel data, the even-numbered row pixel data is correspondingly selected and stored in the first preset memory or the second preset memory;
    根据所述奇数行像素数据中各个源像素点对应的列位置序号的奇偶性,对应将所述奇数行像素数据选择存储于第三预设存储器或者第四预设存储器。According to the parity of the column position serial numbers corresponding to each source pixel point in the odd-numbered row pixel data, the odd-numbered row pixel data is correspondingly selected and stored in the third preset memory or the fourth preset memory.
  5. 如权利要求3所述的图像处理方法,其特征在于,若所述图像处理方法 应用于空间变换网络,则在所述确定与待生成图像中的待生成像素点对应的四个相邻的目标源像素点之前,还包括:The image processing method according to claim 3, wherein, if the image processing method is applied to a spatial transformation network, in the determining of four adjacent objects corresponding to the pixels to be generated in the image to be generated Before the source pixel point, it also includes:
    通过参数预测,确定所述空间变换网络的目标参数;Determine the target parameters of the spatial transformation network through parameter prediction;
    所述确定与待生成图像中的待生成像素点对应的四个相邻的目标源像素点,包括:The determining of four adjacent target source pixels corresponding to the pixels to be generated in the image to be generated includes:
    根据所述目标参数,确定与待生成图像中的待生成像素点对应的源图像的映射坐标;According to the target parameter, determine the mapping coordinates of the source image corresponding to the to-be-generated pixel points in the to-be-generated image;
    根据所述映射坐标,确定所述四个相邻的目标源像素点;According to the mapping coordinates, determine the four adjacent target source pixels;
    对应地,所述根据各个所述目标源像素点的像素数据进行插值运算,确定所述待生成像素点的目标像素数据,包括:Correspondingly, the performing interpolation operation according to the pixel data of each of the target source pixels to determine the target pixel data of the pixels to be generated includes:
    根据所述四个相邻的源像素点中的各个目标源像素点的像素数据进行双线性插值运算,确定所述待生成像素点的目标像素数据。A bilinear interpolation operation is performed according to the pixel data of each target source pixel among the four adjacent source pixels, and the target pixel data of the to-be-generated pixel is determined.
  6. 如权利要求1任意一项所述的图像处理方法,其特征在于,所述根据各个所述目标源像素点在所述源图像中的位置信息,分别从不同的预设存储器中获取各个所述目标源像素点的像素数据,包括:The image processing method according to any one of claim 1, wherein, according to the position information of each target source pixel in the source image, each of the target source pixels is obtained from different preset memories respectively. The pixel data of the target source pixel, including:
    根据各个所述目标源像素点在所述源图像中的所述位置信息,确定各个所述目标源像素点分别对应的预设存储器以及偏移量;According to the position information of each target source pixel in the source image, determine the preset memory and offset corresponding to each target source pixel respectively;
    根据各个所述偏移量,分别确定各个所述目标源像素点的像素数据在各自对应的所述预设存储器中的地址信息;According to each of the offsets, respectively determine the address information of the pixel data of each of the target source pixel points in the corresponding preset memory;
    根据各个所述地址信息,分别从各个所述预设存储器中获取对应的各个所述目标源像素点的像素数据。According to each of the address information, the pixel data of each of the corresponding target source pixel points is obtained from each of the preset memories, respectively.
  7. 如权利要求6所述的图像处理方法,其特征在于,若所述位置信息包括各个所述目标源像素点的坐标信息,则所述根据各个所述目标源像素点在所述源图像中的所述位置信息,确定各个所述目标源像素点分别对应的预设存储器以及偏移量,包括:6. The image processing method according to claim 6, wherein, if the position information includes coordinate information of each of the target source pixels, the method according to the coordinate information of each of the target source pixels in the source image The position information determines the preset memory and offset corresponding to each of the target source pixels, including:
    根据各个所述目标源像素点在所述源图像中的坐标信息,确定各个所述目标源像素点对应的位置类型;According to the coordinate information of each target source pixel in the source image, determine the position type corresponding to each target source pixel;
    根据各个所述目标源像素点在所述源图像中的位置类型,确定各个所述目标源像素点分别对应的预设存储器以及对应的第一偏移量计算公式;According to the position type of each target source pixel in the source image, determine the preset memory corresponding to each target source pixel and the corresponding first offset calculation formula;
    根据所述各个所述目标源像素点的坐标信息及所述第一偏移量计算公式,确定各个所述目标源像素点在各自对应的所述预设存储器中的偏移量;According to the coordinate information of each of the target source pixels and the first offset calculation formula, determine the offset of each of the target source pixels in the corresponding preset memory;
    或者,若所述至少两个相邻的目标源像素点包括第一目标源像素点及除所述第一目标源像素点以外的第二目标源像素点,所述位置信息包括所述第一目标源像素点的坐标信息及所述第二目标源像素点相对于所述第一目标源像素点的相对位置信息,则所述根据各个所述目标源像素点在所述源图像中的所述位置信息,确定各个所述目标源像素点分别对应的预设存储器以及偏移量,包括:Or, if the at least two adjacent target source pixels include a first target source pixel and a second target source pixel other than the first target source pixel, the position information includes the first target source pixel The coordinate information of the target source pixel point and the relative position information of the second target source pixel point with respect to the first target source pixel point, then according to all the target source pixel points in the source image The position information is determined, and the preset memory and offset corresponding to each of the target source pixels are determined, including:
    根据所述第一目标源像素点的坐标信息及所述第二目标源像素点相对于所述第一目标源像素点的相对位置信息,确定各个所述目标源像素点对应的位置类型及对应的第二偏移量计算公式;According to the coordinate information of the first target source pixel point and the relative position information of the second target source pixel point relative to the first target source pixel point, determine the position type and corresponding position of each target source pixel point The second offset calculation formula of ;
    根据所述第一目标源像素点的坐标信息及各个所述第二偏移量计算公式, 确定各个所述目标源像素点在各自对应的所述预设存储器中的偏移量。According to the coordinate information of the first target source pixel point and each of the second offset calculation formulas, the offset of each of the target source pixel points in the corresponding preset memory is determined.
  8. 一种图像处理装置,其特征在于,包括:An image processing device, comprising:
    目标源像素点确定单元,用于确定与待生成图像中的待生成像素点对应的至少两个相邻的目标源像素点,所述目标源像素点为源图像中的源像素点;a target source pixel point determination unit, configured to determine at least two adjacent target source pixel points corresponding to the to-be-generated pixel points in the to-be-generated image, where the target source pixel points are the source pixel points in the source image;
    像素数据获取单元,用于根据各个所述目标源像素点在所述源图像中的位置信息,分别从不同的预设存储器中获取各个所述目标源像素点的像素数据,其中每个所述预设存储器分别存储一种位置类型的源像素点,所述位置类型根据所述源像素点在源图像中的位置信息确定;A pixel data acquisition unit, configured to acquire pixel data of each of the target source pixels from different preset memories according to the position information of each of the target source pixels in the source image, wherein each of the target source pixels The preset memories respectively store source pixels of a position type, and the position type is determined according to the position information of the source pixels in the source image;
    目标像素数据确定单元,用于根据各个所述目标源像素点的像素数据进行插值运算,确定所述待生成像素点的目标像素数据。The target pixel data determination unit is configured to perform interpolation operation according to the pixel data of each of the target source pixel points, and determine the target pixel data of the to-be-generated pixel point.
  9. 一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,当所述处理器执行所述计算机程序时,使得终端设备实现如权利要求1至7任一项所述方法的步骤。A terminal device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that when the processor executes the computer program, the terminal device realizes the The steps of the method as claimed in any one of claims 1 to 7.
  10. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,当所述计算机程序被处理器执行时,使得终端设备实现如权利要求1至7任一项所述方法的步骤。A computer-readable storage medium storing a computer program, characterized in that, when the computer program is executed by a processor, the terminal device is made to realize the implementation of any one of claims 1 to 7 steps of the method.
PCT/CN2021/088428 2020-07-22 2021-04-20 Image processing method and apparatus, terminal device, and storage medium WO2022016927A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010713390.2A CN111915673B (en) 2020-07-22 2020-07-22 Image processing method, image processing device, terminal equipment and storage medium
CN202010713390.2 2020-07-22

Publications (1)

Publication Number Publication Date
WO2022016927A1 true WO2022016927A1 (en) 2022-01-27

Family

ID=73281304

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/088428 WO2022016927A1 (en) 2020-07-22 2021-04-20 Image processing method and apparatus, terminal device, and storage medium

Country Status (2)

Country Link
CN (1) CN111915673B (en)
WO (1) WO2022016927A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111915673B (en) * 2020-07-22 2022-01-11 深圳云天励飞技术股份有限公司 Image processing method, image processing device, terminal equipment and storage medium
CN112508776B (en) * 2020-12-11 2024-02-27 网易(杭州)网络有限公司 Action migration method and device and electronic equipment
CN114119675B (en) * 2021-11-10 2023-07-18 爱芯元智半导体(上海)有限公司 Pixel offset acquisition method and device, electronic equipment and storage medium
CN115456858B (en) * 2022-09-16 2023-07-18 深圳思谋信息科技有限公司 Image processing method, device, computer equipment and computer readable storage medium
CN116152043B (en) * 2023-03-24 2024-03-08 摩尔线程智能科技(北京)有限责任公司 Memory management method and device based on image processing and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000059583A (en) * 1998-08-10 2000-02-25 Nec Corp Picture processing method and device therefor
CN106201363A (en) * 2016-07-26 2016-12-07 四川大学 The memorizer of the random real time access of video flowing Pixel-level data and storage method
CN110738615A (en) * 2019-10-11 2020-01-31 珠海市杰理科技股份有限公司 Fisheye image correction method, device and system and storage medium
CN111131740A (en) * 2019-12-03 2020-05-08 中国航空工业集团公司洛阳电光设备研究所 VESA time sequence real-time conversion method for realizing arbitrary scaling
CN111915673A (en) * 2020-07-22 2020-11-10 深圳云天励飞技术有限公司 Image processing method, image processing device, terminal equipment and storage medium

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005148436A (en) * 2003-11-17 2005-06-09 Fujinon Corp Projection type display device
CN102467360B (en) * 2010-11-12 2016-01-20 南京理工大学 The configurable image display control method of parameter
CN103533366B (en) * 2012-07-03 2016-11-23 展讯通信(上海)有限公司 The caching method compensated for video motion and device
US9697603B2 (en) * 2014-12-19 2017-07-04 Toshiba Medical Systems Corporation Medical image data processing system and method for vessel segmentation using pre- and post-contrast data
BR112020004557A2 (en) * 2017-09-15 2020-09-08 Sony Corporation device and image processing method.
CN110458755B (en) * 2018-05-07 2023-01-13 华为技术有限公司 Image processing method, related device and computer storage medium
CN110503602B (en) * 2018-05-18 2023-07-04 杭州海康微影传感科技有限公司 Image projection transformation method and device and electronic equipment
US10623714B2 (en) * 2018-05-24 2020-04-14 Innolux Corporation Stereoscopic display device and method for operating using pixel offset map
CN110928503B (en) * 2019-10-26 2024-03-22 森大(深圳)技术有限公司 Data addressing method, device, equipment and storage medium for regional random printing

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000059583A (en) * 1998-08-10 2000-02-25 Nec Corp Picture processing method and device therefor
CN106201363A (en) * 2016-07-26 2016-12-07 四川大学 The memorizer of the random real time access of video flowing Pixel-level data and storage method
CN110738615A (en) * 2019-10-11 2020-01-31 珠海市杰理科技股份有限公司 Fisheye image correction method, device and system and storage medium
CN111131740A (en) * 2019-12-03 2020-05-08 中国航空工业集团公司洛阳电光设备研究所 VESA time sequence real-time conversion method for realizing arbitrary scaling
CN111915673A (en) * 2020-07-22 2020-11-10 深圳云天励飞技术有限公司 Image processing method, image processing device, terminal equipment and storage medium

Also Published As

Publication number Publication date
CN111915673A (en) 2020-11-10
CN111915673B (en) 2022-01-11

Similar Documents

Publication Publication Date Title
WO2022016927A1 (en) Image processing method and apparatus, terminal device, and storage medium
US5657403A (en) Vision coprocessing
US8947449B1 (en) Color space conversion between semi-planar YUV and planar YUV formats
CN1329870C (en) Block-based rotation of arbitrary-shaped images
CA3029590A1 (en) Method and device for performing mapping on spherical panoramic image
US11094069B2 (en) Template based anatomical segmentation of medical images
WO2022166258A1 (en) Behavior recognition method and apparatus, terminal device, and computer-readable storage medium
CN111984189B (en) Neural network computing device, data reading method, data storage method and related equipment
CN109035134A (en) Panorama Mosaic method, apparatus, electronic equipment and storage medium
JP7376881B2 (en) Systems, methods and devices for image processing
MX2008015960A (en) Providing multiple and native representations of an image.
CN112215751A (en) Image scaling method, image scaling device and terminal equipment
WO2020228172A1 (en) Continuous image amplification method and apparatus based on radial basis function and storage medium
US20220270353A1 (en) Data augmentation based on attention
US8134562B2 (en) Method for assisting in data calculation by using display card
CN115809959A (en) Image processing method and device
JP2011259511A (en) Image processing apparatus and image processing method
KR20090124177A (en) Device for processing image of large size into scaled image tiles and the method therefor
CN110490825B (en) Method, device and equipment for correcting coded picture and storage medium
JP4313527B2 (en) Image drawing device
CN117057982B (en) Integrated circuit for performing distortion transformation on image and electronic equipment
CN113111891B (en) Image reconstruction method and device, terminal equipment and storage medium
JP5658612B2 (en) Image processing apparatus, image processing system, and image processing method
CN115936971A (en) Image conversion method, component, chip and storage medium
TWI632527B (en) Image capture and output method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21846412

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21846412

Country of ref document: EP

Kind code of ref document: A1