0
我試圖以一種快速的方式得到一個圖像矩陣(像素配置)...在JAVA如何快速獲取圖像矩陣? JAVA
我可以得到的矩陣,但取決於圖片的分辨率,它需要很多時間,所以如果有人知道如何快速獲取它,請告訴我。
int a;
int r ;
int g ;
int b ;
for(int y = 0; y < bufImage2.getHeight(); y++) {
for(int x = 0 ; x < bufImage2.getWidth(); x++){
color = new Color(bufImage2.getRGB(x, y));
a = color.getAlpha();
r = color.getRed();
g = color.getGreen();
b = color.getBlue();
System.out.print(r+"."+g+"."+b+":");
}
這就是我用來獲取RGB值的「for」。
如果有圖書館或其他事情可以更快地告訴我。
謝謝。
但用這段代碼我掃描所有的圖像?因爲我需要所有像素的所有值。 @Kore –
@DennerPortuguez是的,你可以定義你想要讀取的圖片大小爲: int [] dataBuffInt = image.getRGB(0,0,w,h,null,0,w); 0和0是X和Y的開始,w和h是X和Y的結束 – Kore