publicvoiddrawMosaicImage(Graphics g){for(int i=0;i<width;i+=10){for(int j=0;j<height;j+=10){int pixel = srcImageArray[i][j];Color color =newColor(pixel);g.setColor(color);g.fillRect(i,j,10,10);}}}
六.灰度
publicvoiddrawGrayImage(Graphics g){for(int i=0;i<width;i++){for(int j=0;j<height;j++){intPixel= srcImageArray[i][j];int red =(Pixel>>16)&0xFF;int green =(Pixel>>8)&0xFF;int blue =(Pixel>>0)&0xFF;int gray =(red +green +blue)/3;Color color =newColor(gray,gray,gray);g.setColor(color);g.fillRect(i,j,1,1);}}}
七.素描
publicvoiddrawBinaryImage(Graphics g){for(int i=0;i<width;i++){for(int j=0;j<height;j++){int pixel =srcImageArray[i][j];int red =(pixel >>16)&0xFF;int green =(pixel >>8)&0xFF;int blue =(pixel >>0)&0xFF;int gray =(red + green + blue)/3;if(gray <127){g.setColor (Color.BLACK);}else{g.setColor (Color.WHITE);}g.fillRect (i, j,1,1);}}}
美白
publicvoiddrawWhiteImage(Graphics g){for(int i =0; i < width; i++){for(int j =0; j < height; j++){int pixel = srcImageArray[i][j];Color color =newColor(pixel);int red =(pixel >>16)&0xFF;int green =(pixel >>8)&0xFF;int blue =(pixel >>0)&0xFF;if(red <235&& green <235&& blue <235){Color color1 =newColor(red +20, green +20, blue +20);g.setColor(color1);}else{g.setColor(color);}g.fillRect(i,j,1,1);}}}
油画
publicvoiddrawOilImage(Graphics g){Random random =newRandom();for(int i =0; i < width; i +=3){for(int j =0; j < height; j +=3){int pixel = srcImageArray[i][j];Color color =newColor(pixel);g.setColor (color);g.fillOval (i, j, random.nextInt (8)+5, random.nextInt (8)+5);}}}
轮廓检测
publicvoiddrawImage_02(Graphics g){for(int i =0; i < width -2; i++){for(int j =0; j < height -2; j++){int pixel = srcImageArray[i][j];int red =(pixel >>16)&0xFF;int green =(pixel >>8)&0xFF;int blue =(pixel >>0)&0xFF;int gray =(red + green + blue)/3;int pixel1 = srcImageArray[i +2][j +2];int red1 =(pixel1 >>16)&0xFF;int green1 =(pixel1 >>8)&0xFF;int blue1 =(pixel1 >>0)&0xFF;int gray1 =(red1 + green1 + blue1)/3;if(Math.abs(gray - gray1)>25){bufferedImage.setRGB(i, j,Color.BLACK.getRGB());}else{bufferedImage.setRGB(i, j,Color.WHITE.getRGB());}}}g.drawImage(bufferedImage,0,0,null);}