Robot robo = new Robot();
BufferedImage notQuantized = robo.createScreenCapture(new Rectangle (0, 0, 300, 300));
BufferedImage Quantized = new BufferedImage(300, 300, BufferedImage.TYPE_INT_BGR);
File nonquantized = new File ("C:\\nonquantized.png");
File quantized = new File("C:\\quantized.png");
nonquantized.createNewFile();
quantized.createNewFile();
QuantizeFilter bla = new QuantizeFilter();
int [] outPixels = new int[300*300*3];
int [] inPixels = new int[300*300*3];
notQuantized.getRaster().getPixels(0, 0, 300, 300, inPixels);
bla.quantize(inPixels, outPixels, 300, 300,2, true, true);
Quantized.getRaster().setPixels(0, 0, 300, 300, outPixels);
ImageIO.write(Quantized, "png", quantized);
ImageIO.write(notQuantized, "png", nonquantized);
, 내가 남아있는 무슨이다 : 여기
내 아주 아주 간단한 코드입니다원래 IMG :
양자화 IMG :
문제의 추가 분석은 inPixels 배열이 잘못 채워진 것을 보여줍니다. 그것은 원래 이미지의 3 분의 1로 3 번 채워진다.
어떻게 해결할 수 있습니까?
또한 모든 링크는 Java에서 좋은 + 빠른 양자화 알고리즘을 사용합니까? 내가 찾는 것은 TYPE_INT_BGR 이미지를 취하여 새로운 TYPE_INT_BGR 이미지를 생성하지만 픽셀의 실제 차이는 거의 없으므로 쉽게 압축 될 수있는 알고리즘입니다.
예를 들어 원래 이미지에 255, 255, 234와 같은 값을 가진 픽셀이 있고 255, 255, 236과 같은 값을 가진 픽셀이 둘 다 255,255,240으로 변환되어야합니다. 건배