### Question:
Interpolation { public float[][] cropAndResize(int lenX, int lenY, float minX, float minY, float maxX, float maxY) { float[][] output = new float[lenY][lenX]; float outputMaxIdxX = lenX - 1; float outputMaxIdxY = lenY - 1; float cropLenX = maxX - minX; float cropLenY = maxY - minY; for (int y = 0; y < lenY; y++) { for (int x = 0; x < lenX; x++) { float xSrc = (x / outputMaxIdxX) * cropLenX + minX; float ySrc = (y / outputMaxIdxY) * cropLenY + minY; output[y][x] = interpolate(input, xSrc, ySrc); } } return output; } Interpolation(float[][] input);  Interpolation(float[][] input, int lenX, int lenY);  Interpolation(float[][] input, int lenX, int lenY, int samples); protected  Interpolation(); static Interpolation getInstance(Type type, float[][] input); abstract float interpolateSampleX(float[] samples, float fracX); float interpolateX(float[] arr, float fracX, int offsetX); float interpolateSampleY(float[] samples, float fracY); float interpolateY(float[] arr, float fracY, int offsetY); float interpolateSample(float[][] samples, float fracX, float fracY); float interpolate(float[][] arr, float fracX, float fracY, int offsetX, int offsetY); float interpolate(float[][] arr, float inputX, float inputY); static float getSigFig(float value); float[][] resize(int lenX, int lenY); float[][] crop(float top, float right, float bottom, float left); float[][] cropAndResize(int lenX, int lenY,
            float minX, float minY, float maxX, float maxY);  }### Answer:
@Test public void testCropAndResize() { int lenX = 4; int lenY = 4; float minX = 1.0F; float minY = 1.0F; float maxX = 4.0F; float maxY = 4.0F; float[][] expResult = new float[][] { { 1, 2, 2, 3 }, { 4, 5, 5, 6 }, { 4, 5, 5, 6 }, { 7, 8, 8, 9 } }; float[][] result = instance.cropAndResize(lenX, lenY, minX, minY, maxX, maxY); assertArray2dEquals(expResult, result, 0.0001f); }
@Test public void testCropAndResize2() { int lenX = 6; int lenY = 6; float minX = 1.5F; float minY = 1.5F; float maxX = 4.5F; float maxY = 4.5F; float[][] expResult = new float[][]{ {3.0f, 3.5f, 3.5f, 3.8f, 4.4f, 4.5f,}, {4.5f, 5.0f, 5.0f, 5.3f, 5.9f, 6.0f,}, {4.5f, 5.0f, 5.0f, 5.3f, 5.9f, 6.0f,}, {5.4f, 5.9f, 5.9f, 6.2f, 6.8f, 6.9f,}, {7.2f, 7.7f, 7.7f, 8.0f, 8.6f, 8.7f,}, {7.5f, 8.0f, 8.0f, 8.3f, 8.9f, 9.0f } }; float[][] result = instance.cropAndResize(lenX, lenY, minX, minY, maxX, maxY); assertArray2dEquals(expResult, result, 0.0001f); }