Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>OK, here is the solution I ended up with.</p> <ol> <li><p>I transformed all my array[][] into a BufferedImage object</p> <pre><code>static BufferedImage BImageFrom2DArray(float data[][]) { int width = data.length; int height = data[0].length; BufferedImage myimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x &lt; width; x++) { for (int y = 0; y &lt; height; y++) { int value = (int) ((1f - data[x][y]) * 255f); myimage.setRGB(y, x, (value &lt;&lt; 16) | (value &lt;&lt; 8) | value); } } return myimage; } </code></pre></li> <li><p>Applied the affine transformation using AffineTransformOp with interpolation bicubic</p> <pre><code> AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BICUBIC); BufferedImage im_transformed = op.filter(im_src, null); </code></pre></li> <li><p>Transformed back the BufferedImage object into array[][]:</p> <pre><code> static float[][] ArrayFromBImage(BufferedImage bimage, int width, int height) { int max_x = bimage.getWidth(); int max_y = bimage.getHeight(); float[][] array = new float[width][height]; for (int x = 0; x &lt; width; x++) { for (int y = 0; y &lt; height; y++) { float red, alpha, value; int color; if (x &gt;= max_x || y &gt;= max_y) { array[y][x] = 0; } else { color = bimage.getRGB(x, y); alpha = (color &gt;&gt; 24) &amp; 0xFF; red = (color &gt;&gt; 16) &amp; 0xFF; value = 1f - red / 255; if (alpha == 0) { array[y][x] = 0; } else { array[y][x] = value; } } } } return array; } </code></pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload