Convert an array of floats into an image

2019-08-04 17:21发布

my goal is to take in an array of floats, make an image, resize the image, then read out an array of floats from the resized image.

The data I'm feeding into the image itself doesn't correspond to a true graphic, but I'm trying to find a work-around for interpolating data when resizing a float array.

From the research I've done it seems like the steps involved are:

  1. Create a WritableRaster object and feed it the float array
  2. Send that WritableRaster object into a BufferedImage object
  3. Resize the BufferedImage object (using bilinear interpolation)
  4. Somehow get a float array from the BufferedImage

Help, tips, and example code would be greatly appreciated!!! My brains fried today.

1条回答
Juvenile、少年°
2楼-- · 2019-08-04 17:31

If you convert the floats to integers, you can create a BufferedImage out of them directly with using BufferedImage.setRGB(int, int, int, int, int[], int, int)

Use BufferedImage.getScaledInstance() to scale it, then use the corresponding getRGB() method to the above setRGB().

查看更多
登录 后发表回答