private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
BufferedImage image;
String str = "C:/Users/Vinicius/U.F.P.B/4º Período/Processamento Digital de Imagens/1º Trabalho/Arara.jpg";
try{
image = ImageIO.read(new File(str));
ImageIcon icon = new ImageIcon(image);
JLabel imageLabel = new JLabel(icon);
JFrame frame = new JFrame();
Container contentPane = frame.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(new JScrollPane(imageLabel), BorderLayout.CENTER);
frame.setSize(600, 400);
frame.setVisible(true);
int width = image.getWidth();
int height = image.getHeight();
frame.setTitle("Dimensões: " + height + " x " + width);
int nbands = image.getSampleModel().getNumBands();
Raster inputRaster = image.getData();
int[] pixels = new int[nbands * width * height];
inputRaster.getPixels(0, 0, width, height, pixels);
WritableRaster teste;
int[][] r = new int[width][height];
int[][] g = new int[width][height];
int[][] b = new int[width][height];
int[][] mediaR = new int[width][height];
int[][] mediaG = new int[width][height];
int[][] mediaB = new int[width][height];
Color rgb = null;
for(int w = 0; w < width; w++){
for(int h = 0; h < height; h++){
rgb = new Color(image.getRGB(w,h));
r[w][h] = rgb.getRed();
g[w][h] = rgb.getGreen();
b[w][h] = rgb.getBlue();
teste = image.getRaster();
mediaR[w][h] = (1/9 * ( r[w-1, h-1] + r[w-1, h] + r[w-1, h+1] +
+ r[w , h-1] + r[w , h] + r[w , h+1] +
+ r[w+1, h-1] + r[w+1, h] + r[w+1, h+1] ));
mediaG[i][j] = 1/9 * ( g[w-1, h-1] + g[w-1, h] + g[w-1, h+1] +
+ g[w , h-1] + g[w , h] + g[w , h+1] +
+ g[w+1, h-1] + g[w+1, h] + g[w+1, h+1] );
mediaB[i][j] = 1/9 * ( b[w-1, h-1] + b[w-1, h] + b[w-1, h+1] +
+ b[w , h-1] + b[w , h] + b[w , h+1] +
+ b[w+1, h-1] + b[w+1, h] + b[w+1, h+1] );
int rgb1[] = new int [3];
rgb1[0] = mediaR[w][h];
rgb1[1] = mediaG[w][h];
rgb1[2] = mediaB[w][h];
teste.setPixel(w, h,rgb1);
}
}
}catch(IOException ex){}
}
ta aí o codigo…a função deve fazer um filtro da média, o filtro da media se baseia no seguinte: pega-se um ponto na imagem(faz isso com todos) aí pega todos os pontos ao seu redor, os 3 de cima…de baixo…e as laterais… soma eles e divide por 9, eh um filtro de suavização…ta dando erro nessa parte do codigo de incompatibilitade int int[][] … mas ao fazer uma variavel int pra receber o valor, q tbm eh um int…da o mesmo erro…aí ja n sei mais como fazer