![](/img/trans.png)
[英]How to convert an image to an array of numbers (each number a pixel with its color) in javascript?
[英]how to Convert a Grayscale image where each pixel is 8 bits to an image having 3 bit representation for each pixel only?
在我的 java 项目中,我需要一种将 8 位 (0,225) 灰度图像转换为 3 位 (0,7) 的方法。 有任何想法吗?
我用过这个方法,但它给了我
线程“main”中的异常 java.lang.ArrayIndexOutOfBoundsException:坐标越界!
image.getRaster().setSample(x, y, image.getRaster().getSample(x,y, 0)/32)
我想你只是忘记了除以 32 不会给你一个整数。 尝试将该值解析为整数,它可能(或不)解决您的问题。
由于错误与数组大小有关,请确保您没有超出图像长度和高度的限制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.