java - Obtain float[] or int[] from BufferedImage -
i trying use tone mapping code here. has function:
public void tonemap(final float[] image, final byte[] rgbout) { (int = 0; < image.length; i++) { final float clamped = math.max(0, math.min(1f, image[i])); rgbout[i] = (byte) (0xff & (short) (clamped * 255.0)); } }
it takes in float array , byte array of images , applies simple clamping pixel values. tried:
int[]rbg=((databufferint) image.getraster().getdatabuffer()).getdata();
but got following exception:
java.lang.classcastexception: java.awt.image.databufferbyte cannot cast java.awt.image.databufferint
other stackoverflow answers have explained why so.
i have image file want apply function file. know can read image bufferedimage
using imageio.read()
. how float[] rgb
it? possible? or there other libraries available can me conversion image float[] rgb
array of pixels?
edit:
as few people have mentioned in comments code above nothing pixel values in range of 0..255. want apply above code hdr images, .exr format image , have infinite range.
Comments
Post a Comment