Method for electronic zoom with sub-pixel offset
09741095 · 2017-08-22
Assignee
Inventors
- Mark Gohlke (McKinney, TX, US)
- Christopher J. Baker (McKinney, TX, US)
- Trent A. Jacobs (McKinney, TX, US)
Cpc classification
G06T3/4092
PHYSICS
International classification
G06T3/40
PHYSICS
G09G5/00
PHYSICS
Abstract
A system and method for interpolating between pixels of an image for providing zoom and pan features. A piecewise cubic spline is used to find the values of each of four provisional interpolation points in each of four rows of an image and, similarly, a piecewise cubic spline is used to interpolate between the provisional interpolation points to find the value of a point in the output image. Boundary conditions used to constrain the coefficients of the piecewise cubic spline provide enhanced quality in the output image.
Claims
1. A system for generating an interpolated value at a first interpolation point between two central source points of a set of four source points, the four source points aligned along a first direction, each source point having a value, the system comprising: a display; and a processing unit configured to calculate the interpolated value as a first cubic function f.sub.0(a), wherein:
f.sub.0(a)=a.sub.0a.sup.3+b.sub.0a.sup.2+c.sub.0a+d.sub.0 wherein
2. The system of claim 1, wherein the processing unit is configured to calculate a.sub.0, b.sub.0, c.sub.0, and d.sub.0, according to
3. The system of claim 2, wherein the processing unit is configured to calculate a.sub.0, b.sub.0, c.sub.0, and d.sub.0 by multiplying only each element of Q that is equal to neither 0 nor 1 by an element of the vector
4. The system of claim 1, comprising at least one synchronous dynamic random access memory (SDRAM) configured to store an input image.
5. The system of claim 4, comprising a first SDRAM to store the input image and a second SDRAM to store an output image.
6. The system of claim 5, wherein the first SDRAM and the second SDRAM are different SDRAMs.
7. The system of claim 4, wherein the processing unit comprises a ring buffer configured to hold four lines of an image, the processing unit configured to select from each of the four lines four pixels at a time as source points.
8. The system of claim 7, wherein the ring buffer is configured to hold two additional lines of an image, and the processing unit is configured to transfer data from the first memory to lines of the ring buffer not being used, at the time of the transfer, as source points.
9. The system of claim 1, wherein the processing unit is configured to calculate the interpolated value using fixed-point arithmetic.
10. The system of claim 9, wherein the processing unit is configured to represent the quantity a using 32-bit fixed-point arithmetic including one sign bit, 25 bits to the left of the binary point, and 6 bits to the right of the binary point.
11. A method for generating an interpolated value at a first interpolation point between two central source points of a set of four source points, the four source points aligned along a first direction, each source point having a value, the method comprising: calculating the interpolated value as a first cubic function f.sub.0(a), wherein:
f.sub.0(a)=a.sub.0a.sup.3+b.sub.0a.sup.2+c.sub.0a+d.sub.0 wherein
12. The method of claim 11, comprising calculating a.sub.0, b.sub.0, c.sub.0, and d.sub.0, according to
13. The method of claim 12, wherein the act of calculating a.sub.0, b.sub.0, c.sub.0, and d.sub.0 comprises multiplying only each element of Q that is equal to neither 0 nor 1 by an element of the vector
14. The method of claim 11, wherein the four source points are four pixels of an image.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) Features, aspects, and embodiments are described in conjunction with the attached drawings, in which:
(2)
(3)
(4)
(5)
(6)
(7)
(8)
DETAILED DESCRIPTION
(9) The detailed description set forth below in connection with the appended drawings is intended as a description of exemplary embodiments of a method for electronic zoom with sub-pixel offset provided in accordance with the present invention and is not intended to represent the only forms in which the present invention may be constructed or utilized. The description sets forth the features of the present invention in connection with the illustrated embodiments. It is to be understood, however, that the same or equivalent functions and structures may be accomplished by different embodiments that are also intended to be encompassed within the spirit and scope of the invention. As denoted elsewhere herein, like element numbers are intended to indicate like elements or features.
(10) The digital image being processed may be rectangular, and it may be convenient to associate a horizontal direction in the image with a first axis, e.g., an X axis, and a vertical direction in the image with a second axis, e.g., a Z axis. Each pixel may then have a location in the X-Z coordinate system corresponding to the coordinates of the pixel in that coordinate system.
(11) Referring to
(12) A value may be interpolated at a point 105 by generating a piecewise cubic function over the three contiguous inter-pixel intervals and evaluating the piecewise cubic function at the interpolation point 105. The first of these intervals is between the source point 110 at X=−1 and the source point 115 at X=0, the second of these intervals is between the source point 115 at X=0 and the source point 120 at X=1 and the third of these intervals is between the source point 120 at X=1 and the source point 125 at X=2.
(13) The corresponding three cubic functions forming the piecewise cubic spline may be written
f.sub.−1(x)=a.sub.−1(x+1).sup.3+b.sub.−1(x+1).sup.2+c.sub.−1(x+1)+d.sub.−1 −1≦x≦0
f.sub.0(x)=a.sub.0(x).sup.3+b.sub.0(x).sup.2+c.sub.0(x)+d.sub.0 0≦x≦1
f.sub.1(x)=a.sub.1(x−1).sup.3+b.sub.1(x−1).sup.2+c.sub.1(x−1)+d.sub.−1 1≦x≦2
(14) respectively. Once the four coefficients a.sub.0, b.sub.0, c.sub.0, and d.sub.0 are found, the value at the interpolation point is given by f.sub.0(a)=a.sub.0(a).sup.3+b.sub.0(a).sup.2+c.sub.0(a)+d.sub.0.
(15) The 12 coefficients a.sub.i, b.sub.i, c.sub.i, and d.sub.i may be selected so that the piecewise cubic spline takes on the values y.sub.−1, y.sub.0, y.sub.1, and y.sub.2 at the four source points 110, 115, 120, 125:
f.sub.−1(−1)=y.sub.−1
f.sub.−1(0)=f.sub.0(0)=y.sub.0
f.sub.0(1)=f.sub.1(1)=y.sub.1
f.sub.1(2)=y.sub.2
(16) This set of six constraints is not sufficient to uniquely determine the 12 coefficients a.sub.i, b.sub.i, c.sub.i, and d.sub.i, and, moreover, these constraints do not ensure that the spline is smooth at the source points; the first derivative may be discontinuous at the source points, for example. Requiring that the spline be smooth, in the sense that the first and second derivatives be continuous at the source points 115, 120, results in four additional constraints:
f′.sub.−1(0)=f′.sub.0(0)
f′.sub.0(1)=f′.sub.1(1)
f″.sub.−1(0)=f″.sub.0(0)
f″.sub.0(1)=f″.sub.1(1)
(17) Finally, two additional constraints may be obtained from the assumption that the spline is relaxed or natural, i.e., that the second derivatives vanish at the ends of the spline, at the source points 110, 125:
f″.sub.−1(−1)=0
f.sub.1″(2)=0
(18) The first and second derivatives of the three cubic functions, in terms of the coefficients a.sub.i, b.sub.i, c.sub.i, and d.sub.i are obtained by differentiating:
f.sub.−1(x)=3a.sub.−1(x+1).sup.2+2b.sub.−1(x+1)+c.sub.−1 −1≦x≦0
f′.sub.0(x)=3a.sub.0(x).sup.2+2b.sub.0(x)+c.sub.0 0≦x≦1
f′.sub.1(x)=3a.sub.1(x−1).sup.2+2b.sub.1(x−1)+c.sub.1 1≦x≦2
f″.sub.−1(x)=6a.sub.−1(x+1)+2b.sub.−1−1≦x≦0
f″.sub.0(x)=6a.sub.0(x)+.sup.2b.sub.0 0≦x≦1
f″.sub.1(x)=6a.sub.1(x−1)+2b.sub.1 1≦x≦2
(19) Applying the constraints on the values of the three cubic functions, and on their derivatives, then results in sets of equations for the 12 coefficients a.sub.i, b.sub.i, c.sub.i, and d.sub.i. For the first cubic function, these equations are:
f.sub.−1(−1)=d.sub.−1 =y.sub.−1
f.sub.−1(0)=a.sub.−1+b.sub.−1+c.sub.−1+d.sub.−1 =y.sub.0
f′.sub.−1(−1)=c.sub.−1
f′.sub.−1(0)=3a.sub.−1+2b.sub.−1+c.sub.−1 =f.sub.0(0)
f″.sub.−1(−1)=2b.sub.−1 =0
f″.sub.−1(0)=6a.sub.−1+2b.sub.−1 =f″.sub.0(0)
(20) For the second cubic function, the equations for the coefficients a.sub.i, b.sub.i, c.sub.i, and d.sub.i are:
f.sub.0(0)=d.sub.0 =y.sub.0
f.sub.0(1)=a.sub.0+b.sub.0+c.sub.0+d.sub.0 =y.sub.1
f′.sub.0(0)=c.sub.0=f′.sub.−1(0)
f′.sub.0(1)=3a.sub.0+2b.sub.0+c.sub.0 =f′.sub.1(1)
f″.sub.0(0)=2b.sub.0 =f″.sub.−1(0)
f″.sub.0(1)=6a.sub.0+2b.sub.0 =f″.sub.1(1)
(21) Finally, for the third cubic function, the equations for the coefficients a.sub.i, b.sub.i, c.sub.i, and d.sub.i are:
f.sub.1(1)=d.sub.1 =y.sub.1
f.sub.1(2)=a.sub.1+b.sub.1+c.sub.1+d.sub.1 =y.sub.2
f′.sub.1(1)=c.sub.1 =f′.sub.0(0)
f′.sub.1(2)=3a.sub.1+2b.sub.1+c.sub.1
f″.sub.1(1)=2b.sub.1 =f″.sub.0(1)
f″.sub.1(2)=6a.sub.1+2b.sub.1 =0
(22) These equations may be rewritten as a set of equations with the values y.sub.−1, y.sub.0, y.sub.1, and y.sub.2 on the left-hand side and the coefficients a.sub.i, b.sub.i, c.sub.i, and d.sub.i on the right-hand side:
y.sub.−1=d.sub.−1
y.sub.0=a.sub.−1+b.sub.−1+c.sub.−1+d.sub.−1
0=3a.sub.−1+2b.sub.−1+c.sub.−1−c.sub.0
0=2b.sub.−1
0=6a.sub.−1+2b.sub.−1−2b.sub.0
y.sub.0=d.sub.0
y.sub.1=a.sub.0+b.sub.0+c.sub.0+d.sub.0
0=3a.sub.0+2b.sub.0+c.sub.0−c.sub.1
0=6a.sub.0+2b.sub.0−2b.sub.1
y.sub.1=d.sub.1
y.sub.2=a.sub.1+b.sub.1+c.sub.1+d.sub.1
0=6a.sub.1+2b.sub.1
(23) This set of equations may be written in the matrix form
M{right arrow over (q)}={right arrow over (y)},
(24) where
(25)
(26) The four coefficients a.sub.0, b.sub.0, c.sub.0, and d.sub.0 are needed to evaluate the cubic spline at the interpolation point 105. These may be obtained by inverting the equation M{right arrow over (q)}={right arrow over (y)}:
{right arrow over (q)}=M.sup.−1{right arrow over (y)},
(27) and extracting from the vector {right arrow over (q)} the four coefficients a.sub.0, b.sub.0, c.sub.0, and d.sub.0:
(28)
(29) Inverting M and calculating the matrix product above results in the following explicit expression for the four coefficients a.sub.0, b.sub.0, c.sub.0, and d.sub.0:
(30)
(31) which may be rewritten as
(32)
(33) with
(34)
(35) Finally, the interpolated value f.sub.0(a) at the interpolation point 105, at which x=a, may be written f.sub.0(a)=a.sub.0a.sup.3+b.sub.0a.sup.2+c.sub.0a+d.sub.0, with the coefficients a.sub.0, b.sub.0, c.sub.0, and d.sub.0 found as described above.
(36) Referring to
(37)
with
(38)
(39) may instead form the curve 205c, which also passes through the source points 205b but does not satisfy all of the constraints listed above, and defines different interpolated values at various points along the spline. Similarly, in
(40) Differences between various approaches to interpolation may be seen in the three images in
(41) To perform interpolation in two dimensions, as for example in the images of
(42) For example, the method may be applied to the pixels 540, 545, 550, 555 in the first row to obtain a provisional interpolated value at the provisional interpolation point 510. In this step the interpolation uses: (i) the value of the second-nearest pixel, to the provisional interpolation point 510, in a first direction parallel to an image axis (the −X direction), i.e., the pixel 540, (ii) the value of the nearest pixels in the first direction, i.e., the pixel 545, (iii) the value of the nearest pixel in a second direction opposite the first direction (the +X direction), i.e., the pixel 550, and (iv) the value of the second-nearest pixel in the second direction, i.e., the pixel 555. The pixels in the second, third, and fourth rows may then be used to obtain provisional interpolation values at the provisional interpolation points 515, 520, and 525 respectively.
(43) Finally, in a second stage, the four provisional interpolation values at the provisional interpolation points 510, 515, 520, 525 may be used to obtain the interpolated value at the ultimate interpolation point 505, again using a cubic spline according to an embodiment of the present invention. This phase uses: (i) the value of the second-nearest provisional interpolation point, to the ultimate interpolation point 505, in a third direction parallel to an image axis (the −Z direction), i.e., the provisional interpolation point 525, (ii) the value of the nearest provisional interpolation point in the third direction, i.e., the provisional interpolation point 520, (iii) the value of the nearest provisional interpolation point in a second direction opposite the first direction (the +Z direction), i.e., the provisional interpolation point 515, and (iv) the value of the second-nearest provisional interpolation point in the second direction, i.e., the provisional interpolation point 510.
(44) Thus, referring to
(45) Embodiments of the present invention are computationally efficient and also provide the capability to interpolate images to essentially arbitrary zoom factors, which need not be the same along the two axes of an image. The resulting images are virtually free of artifacts, providing a higher quality output to the viewer.
(46) Interpolation may be performed with embodiments which include a processing unit. The term “processing unit” is used herein to include any combination of hardware, firmware, and software, employed to process data or digital signals. Processing unit hardware may include, for example, application specific integrated circuits (ASICs), general purpose or special purpose central processing units (CPUs), digital signal processors (DSPs), graphics processing units (GPUs), and programmable logic devices such as field programmable gate arrays (FPGAs).
(47) It may be advantageous, when performing interpolations, to minimize the number of operations required in the processing unit. This may be accomplished, for example, when evaluating
(48)
(49) by omitting the step of multiplication for elements, of the matrix Q, that are either 0 (in which case the product is 0) or 1 (in which case the product is the corresponding element of the vector
(50)
For example, because the last row of the matrix Q is composed of three zeroes and a one, the value of d.sub.0 is simply y.sub.0, i.e., d.sub.0 may be obtained without performing any multiplications. For efficiency, the calculations involved in interpolating may be performed using fixed-point arithmetic, using for example a 25Q6 format with a sign bit, i.e., a format having six bits to the right of the binary point, which may also be written Q25.6.
(51) The value of the position a, relative to the nearest source point in a first direction, of the point to be interpolated may be calculated, from the zoom and offset of the output image relative to the input image, as the fractional part of the sum of (i) the offset and (ii) the ratio of (a) the position, in the original image, of the nearest source point in the first direction to (b) the zoom factor, where a zoom factor greater than 1 corresponds to magnification. In operation, a general purpose computer or other processing unit may feed the offset and the reciprocal of the zoom factor to the processing unit performing the interpolation, so that the latter need not perform a division operation but may instead multiply by the reciprocal of the zoom factor. In one embodiment the reciprocal of the zoom factor is an unsigned fixed point number, e.g., an unsigned 2Q30 fixed point number.
(52) The location of the point in the binary representations of both the sub-pixel offset and the zoom factor may be selected in each case as a trade between the range of zoom control available and the zoom resolution, within limits determined by the required interpolation accuracy.
(53) In one embodiment, the input image is stored in synchronous dynamic random access memory (SDRAM), and the output image may also be stored, and if so it may be stored in the same or in a separate SDRAM, as it is formed. The interpolation is performed by a special purpose processing unit which may be based on an FPGA or ASIC. Line buffers are used between the SDRAM and the processing unit, as first-in, first-out (FIFO) structures for clock domain transfer between the SDRAM and the processing unit. The processing unit contains a ring buffer storing, for example, six lines of the input image, from which four lines are used at any time, according to the algorithm disclosed above, to generate one line of the output image. If the zoom factor is greater than 1, then in some instances, to form a subsequent line of the output image, the same four lines of the input image will be required, and in some instances an additional line of the input image will be needed, and a previously used line of the input image will no longer be needed. A ring buffer is well suited to these data requirements, as a new line may be read in to the buffer at the same time as four other lines in the buffer are being processed to form a line of the output image. If the zoom factor is less than 1, but not less than ½, then as many as two additional lines of the input image may be needed in the buffer when one line of the output image has been formed and the processing unit begins forming the subsequent line. Thus, in one embodiment, a 6-line ring buffer is used in the processing unit.
(54) Although limited embodiments of a method for electronic zoom with sub-pixel offset have been specifically described and illustrated herein, many modifications and variations will be apparent to those skilled in the art. Accordingly, it is to be understood that the method for electronic zoom with sub-pixel offset employed according to principles of this invention may be embodied other than as specifically described herein. The invention is also defined in the following claims, and equivalents thereof.