Amplification and reduction of images (3)--double cube interpolation algorithm __ Image recognition

Source: Internet
Author: User

-----------------------------reprinted from Jia20003 blog " double cubic interpolation of image scaling" -----------------------------------

One: Mathematical Principles

If you know a function f (x) and its derivative at x=0,x=1, then the function can be interpolated between [0,1], when the function

When expressed as a three-time polynomial, we call the cubic interpolation. A three-time polynomial and its derivative:

F (x) =ax^3 +bx^2 + cx + D

F ' (x) =3ax^2 + 2bx +c

The polynomial at x=0, the X=1 value and its derivative values are:

F (0) = D;

F (1) = a + B + C + D;

F ' (0) =c

F ' (1) =3a + 2b + C

The above four equations can be equivalent to the following transformations:

A= 2f (0) –2f (1) + F ' (0) + F ' (1)

b= -3f (0) + 3f (1) –2f ' (0) –f ' (1)

c= F ' (0)

D= f ' (1)

Suppose you have four point values P0, p1, p2, p3 respectively in X=-1, X=0, X=1, x=2, assign values to f (0), F (1), F ' (0), respectively,

F ' (1) is:

F (0) = P1

F (1) = P2

F ' (0) = (p2–p0)/2

F ' (1) = (P3-P1)/2

This our cubic interpolation formula becomes:

F (p0,p1,p2,p3, X) = ( -1/2p0 + 3/2p1-3/2p2+ 1/2p3) X^3 + (p0-5/2p1 + 2p2-1/2d) x^2 + ( -1/2p0 +

1/2P2) x + p1

The two-cubic interpolation is the expression of cubic interpolation in two-dimensional space, and the interpolation formula can be expressed as:

G (x, y) = f (f (p00, P01, P02, p03, y), F (p10,p11, P12, P13, y), F (P20, P21, P22, P23, y), F (P30, p31, P32, P33, y), X)

The value of a g (x, y) target interpolation point can be obtained by solving the 16 parameters.

Two: dual-cubic interpolation advantages and disadvantages

Double-cubic interpolation in the image amplification process can retain more image details, enlarge the image with anti-aliasing after the function,

At the same time, the effect of image and source image is more real, the disadvantage is that the computational volume is relatively large, is a common three kinds of image amplification algorithm

One of the largest computational weights, it is said that Photoshop image amplification is the basic two-cubic interpolation optimization algorithm


Third: The operation effect of the program is as follows:


Four: Critical code resolution

Do not want to explain too much, the most important thing is to calculate the number of floating-point coordinates of the decimal part, that is, X, y range of values between [0,1]


V: Java-based program complete source code

[Java]   View plain  copy package cn.edu.jxau.luoweifu;      public class  bicubicinterpolationscale {          private static  double a00, a01, a02, a03;       private static  double a10, a11, a12, a13;       private static  double a20, a21, a22, a23;       private static  double a30, a31, a32, a33;       private static int  srcWidth;       private static int srcHeight;              /**       *  Double cubic interpolation        *  @param  inPixelsData  pixel matrix array         * @param  srcW  Original image width        *  @param  srcH  original image high         *  @param  destW  target image width        *  @param  destH  target Image High        *  @return   processed push three matrix array         */       public static int[] imgscale (int[)  INPIXELSDATA, INT SRCW, INT SRCH, INT DESTW, INT DESTH)  {            double[][][] input3DData =  Processonetothreedeminsion (INPIXELSDATA, SRCH, SRCW);            int[][][] outputthreedeminsionda

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.