Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7639667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:28:38+00:00 2026-05-31T08:28:38+00:00

Before I start, please accept my apologies that I’m not a mathematician and don’t

  • 0

Before I start, please accept my apologies that I’m not a mathematician and don’t really know the proper names for what I’m trying to do… 😉 Pointers to any plain-English explanations that might help would be most appreciated (as I’m purely Googling at the moment based upon what I think the solution might be).

If have a multi-dimensionsal array of source values and wanted to upscale that array by a factor of n, I think that what I’d need to use is Bicubic Interpolation Certainly the image top right on that page is representative of what I’m aiming for – creating a graduated flow of values between the underlying source data points, based upon the value(s) of their surrounding neighbours. I completely accept that by not increasing the volume of data I am not increasing the resolution of the data; merely blurring the edges.

Something akin to going from this;

Source grid

to this (and beyond);

Target grid

Following the link within the Wikipedia article gives me a (supposed) example implementation of what I’m striving for, but if it does I fear I’m currently missing the logical leap to get myself there. When I call getValue(source, 0.5, 0.5) on the BicubicInterpolator, what am I getting back? I thought that if I gave an x/y of (0.0,0.0) I would get back the bottom-left value of the grid and if I looked at (1,1) I would get top-right, and any value between would give me the specified position within the interpolated grid.

double[][] source  = new double[][] {{1, 1, 1, 2}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 1, 3, 3}};
BicubicInterpolator bi = new BicubicInterpolator();
for (double idx = 0; idx <= 1; idx += 0.1) {
  LOG.info("Result (" + String.format("%3.1f", idx) + ", " + String.format("%3.1f", idx) + ") : " + bi.getValue(source, idx, idx));         
}

The output for a diagonal line across my source grid however is;

Result (0.0, 0.0) : 2.0
Result (0.1, 0.1) : 2.08222625
Result (0.2, 0.2) : 2.128
Result (0.3, 0.3) : 2.13747125
Result (0.4, 0.4) : 2.11424
Result (0.5, 0.5) : 2.06640625
Result (0.6, 0.6) : 2.00672
Result (0.7, 0.7) : 1.9518312500000001
Result (0.8, 0.8) : 1.92064
Result (0.9, 0.9) : 1.93174625
Result (1.0, 1.0) : 2.0

I’m confused because the diagonals go from 1 to 3 and from 1 to 2; there’s nothing going from 2 to 2 with very little (overall) variation. Am I completely mis-understanding things?


EDIT : Following Peter’s suggestion to expand the boundary for analysis, the grid can now be generated as a quick’n’dirty upscale to a 30×30 matrix;

Grid from Peter's answer

Now that what’s going on is making a bit more sense, I can see that I need to consider a few additional things;

  • Control the overshoot (seen in the middle of the grid where the source has a block of four cells with a value of 2, but the interpolated value peaks at 2.2)
  • Cater for blank values in the source grid and have them treated as blanks, rather than zero, so that they don’t skew the calculation
  • Be prepare to be told I’m on a fool’s errand and that a different solution is needed
  • See if this was what the customer thought they actually wanted when they said “make it less blocky“
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:28:39+00:00Added an answer on May 31, 2026 at 8:28 am

    If you assume the “outside” temperature is the same as the outer most ring of values, and you want to shift which port of the grid you are considering…

    public static void main(String... args) {
        double[][] source = new double[][]{{1, 1, 1, 2}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 1, 3, 3}};
        BicubicInterpolator bi = new BicubicInterpolator();
        for (int i = 0; i <= 30; i++) {
            double idx = i / 10.0;
            System.out.printf("Result (%3.1f, %3.1f) : %3.1f%n", idx, idx, bi.getValue(source, idx, idx));
        }
    }
    
    public static class CubicInterpolator {
        public static double getValue(double[] p, double x) {
            int xi = (int) x;
            x -= xi;
            double p0 = p[Math.max(0, xi - 1)];
            double p1 = p[xi];
            double p2 = p[Math.min(p.length - 1,xi + 1)];
            double p3 = p[Math.min(p.length - 1, xi + 2)];
            return p1 + 0.5 * x * (p2 - p0 + x * (2.0 * p0 - 5.0 * p1 + 4.0 * p2 - p3 + x * (3.0 * (p1 - p2) + p3 - p0)));
        }
    }
    
    public static class BicubicInterpolator extends CubicInterpolator {
        private double[] arr = new double[4];
    
        public double getValue(double[][] p, double x, double y) {
            int xi = (int) x;
            x -= xi;
            arr[0] = getValue(p[Math.max(0, xi - 1)], y);
            arr[1] = getValue(p[xi], y);
            arr[2] = getValue(p[Math.min(p.length - 1,xi + 1)], y);
            arr[3] = getValue(p[Math.min(p.length - 1, xi + 2)], y);
            return getValue(arr, x+ 1);
        }
    }
    

    prints

    Result (0.0, 0.0) : 1.0
    Result (0.1, 0.1) : 1.0
    Result (0.2, 0.2) : 1.0
    Result (0.3, 0.3) : 1.1
    Result (0.4, 0.4) : 1.1
    Result (0.5, 0.5) : 1.3
    Result (0.6, 0.6) : 1.4
    Result (0.7, 0.7) : 1.6
    Result (0.8, 0.8) : 1.7
    Result (0.9, 0.9) : 1.9
    Result (1.0, 1.0) : 2.0
    Result (1.1, 1.1) : 2.1
    Result (1.2, 1.2) : 2.1
    Result (1.3, 1.3) : 2.1
    Result (1.4, 1.4) : 2.1
    Result (1.5, 1.5) : 2.1
    Result (1.6, 1.6) : 2.0
    Result (1.7, 1.7) : 2.0
    Result (1.8, 1.8) : 1.9
    Result (1.9, 1.9) : 1.9
    Result (2.0, 2.0) : 2.0
    Result (2.1, 2.1) : 2.1
    Result (2.2, 2.2) : 2.3
    Result (2.3, 2.3) : 2.5
    Result (2.4, 2.4) : 2.7
    Result (2.5, 2.5) : 2.8
    Result (2.6, 2.6) : 2.9
    Result (2.7, 2.7) : 3.0
    Result (2.8, 2.8) : 3.0
    Result (2.9, 2.9) : 3.0
    Result (3.0, 3.0) : 3.0
    

    Looking at how this works, you have a 2×2 grid of inside values and a 4×4 square outside it for outside values. the (0.0, 0.0) to (1.0, 1.0) values map the diagonal between 2 (in cell 2,2) and 2 (in cell 3,3) using the outer values to help interpolate the values.

    double[][] source = new double[][]{{1, 1, 1, 2}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 1, 3, 3}};
    BicubicInterpolator bi = new BicubicInterpolator();
    for (int i = -10; i <= 20; i++) {
        double idx = i / 10.0;
        System.out.printf("Result (%3.1f, %3.1f) : %3.1f%n", idx, idx, bi.getValue(source, idx, idx));
    }
    

    prints

    Result (-1.0, -1.0) : -5.0
    Result (-0.9, -0.9) : -2.8
    Result (-0.8, -0.8) : -1.2
    Result (-0.7, -0.7) : -0.2
    Result (-0.6, -0.6) : 0.5
    Result (-0.5, -0.5) : 1.0
    Result (-0.4, -0.4) : 1.3
    Result (-0.3, -0.3) : 1.5
    Result (-0.2, -0.2) : 1.7
    Result (-0.1, -0.1) : 1.9
    Result (0.0, 0.0) : 2.0
    Result (0.1, 0.1) : 2.1
    Result (0.2, 0.2) : 2.1
    Result (0.3, 0.3) : 2.1
    Result (0.4, 0.4) : 2.1
    Result (0.5, 0.5) : 2.1
    Result (0.6, 0.6) : 2.0
    Result (0.7, 0.7) : 2.0
    Result (0.8, 0.8) : 1.9
    Result (0.9, 0.9) : 1.9
    Result (1.0, 1.0) : 2.0
    Result (1.1, 1.1) : 2.1
    Result (1.2, 1.2) : 2.3
    Result (1.3, 1.3) : 2.5
    Result (1.4, 1.4) : 2.7
    Result (1.5, 1.5) : 2.8
    Result (1.6, 1.6) : 2.7
    Result (1.7, 1.7) : 2.1
    Result (1.8, 1.8) : 0.9
    Result (1.9, 1.9) : -1.4
    Result (2.0, 2.0) : -5.0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before you start flaming, I'm going to tell you that I am trying to
Important: we really need the stated functionality, so please don't start suggesting alternatives. We're
I usually try to do TDD with not much analysis (no diagrams) before start
Before I start, I know there is this post and it doesn't answer my
Before you start firing at me, I'm NOT looking to do this, but someone
Before I start with the real question, let me just say that I might
Guys before you start down voting me please read this question and please understand
!!! WARNING !!! Dearest SQL expert, please keep reading before to start to scream.
Ok, I think before I start I should just say that I'm a complete
I don't have a very good understanding of Javascript so appologies before we start.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.