我試圖把圖片作爲輸入,然後操縱所述圖片(我特別想讓它成爲灰度),然後輸出新圖像。這是我正在編輯的代碼的一小部分,但我卻陷入了困境。任何想法,我可以改變/接下來做什麼。不勝感激!以圖片作爲輸入,製作灰度和&然後輸出
public boolean recieveFrame (Image frame) {
int width = frame.width();
int height = frame.height();
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
Color c1 = frame.get(i, j);
double greyScale = (double) ((Color.red *.3) + (Color.green *.59) + (Color.blue * .11));
Color newGrey = Color.greyScale(greyScale);
frame.set(i, j, newGrey);
}
}
boolean shouldStop = displayImage(frame);
return shouldStop;
}
[如何去飽和圖像](http://stackoverflow.com/questions/6471340/how-do-i-desaturate-a-bufferedimage-in-java/6471524#6471524) – mre