将浮点数组转换为图像 [英] Convert an array of floats into an image
问题描述
我的目标是接收浮点数组,制作图像,调整图像大小,然后从调整大小的图像中读出一系列浮点数。
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:
- 创建一个WritableRaster对象并将其提供给float数组
- 将该WritableRaster对象发送到BufferedImage对象
- 调整BufferedImage对象的大小(使用双线性插值)
- 以某种方式从BufferedImage获取一个float数组
- Create a WritableRaster object and feed it the float array
- Send that WritableRaster object into a BufferedImage object
- Resize the BufferedImage object (using bilinear interpolation)
- Somehow get a float array from the BufferedImage
帮助,提示和示例代码将不胜感激!!!我的大脑今天炒了。
Help, tips, and example code would be greatly appreciated!!! My brains fried today.
推荐答案
如果你将浮点数转换为整数,你可以创建一个 BufferedImage
直接使用 BufferedImage.setRGB(int,int,int,int,int [],int,int)
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)
使用 BufferedImage.getScaledInstance()
进行缩放,然后使用相应的getRGB()方法对应于上面的setRGB()。
Use BufferedImage.getScaledInstance()
to scale it, then use the corresponding getRGB() method to the above setRGB().
这篇关于将浮点数组转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!