Vc está estourando o seu array. Tome cuidado para só usar os recursos que vc tenha reservado…
ivandasilva
Meu querido, debuga a sua classe para ver onde o seu array esta estourando.
G
Gbzao
Você está tentando acessar um índice inexistente de sua array.
Verifique seus laços, e suas validações.
Marky.Vasconcelos
Voce esta tentando acessar o indice 480000 de algum array… eu acho bem dificil alguem precisar de um array desse tamanho.
Isso deve ser um erro de programação. Poste o código.
D
denerfs
Obrigado pelo auxílio.
Não estou conseguindo achar o ponto onde estoura o array (já que é grande).
Cada posição do array p é um pixel da imagem... então se tenho uma imagem de 800x600 o array p terá 800*600 posições.
O filtro irá percorrer cada posição e alterar baseada numa matriz de valores.
Dei uma olhada nos tipos de dados int mas parece que ele suporta o valor descrito.
Deve ser algum fator que não consigo ver no array.
Bom... segue o código.
publicvoidfiltro(){intwidth=img_in.getWidth();//Armazena a largura da imagem Bufferedintheight=img_in.getHeight();//Armazena a altura da imagem Bufferedint[]p=newint[width*height];//Cria o array de processamento da imagemintdx;intdy;intoffset=0;img_out=newBufferedImage(width,height,BufferedImage.TYPE_BYTE_GRAY);WritableRasterraster=img_out.getRaster();RasterinputRaster=img_in.getData();inputRaster.getPixels(0,0,width,height,p);for(inth=1;h<height;h++){for(intw=1;w<width;w++){dx=0;dy=0;offset=h*width+w;dx=(p[(h-1)*width+(w-1)]*1+p[h*width+(w-1)]*2+p[(h+1)*width+(w-1)]*1)+(p[(h-1)*width+(w+1)]*(-1)+p[h*width+(w+1)]*(-2)+p[(h+1)*width+(w+1)]*(-1));dy=(p[(h-1)*width+(w-1)]*1+p[(h-1)*width+w]*2+p[(h-1)*width+(w+1)]*1)+(p[(h+1)*width+(w-1)]*(-1)+p[(h+1)*width+w]*(-2)+p[(h+1)*width+(w+1)]*(-1));dx+=(p[offset]*9);dy+=(p[offset]*0);dx+=dy;if(dx<0){if((dx*(-1))<=255)raster.setSample(w,h,0,dx*(-1));elseraster.setSample(w,h,0,255);}elseif(dx>255){raster.setSample(w,h,0,255);}elseraster.setSample(w,h,0,dx);}}}
victorwss
denerfs:
Obrigado pelo auxílio.
Não estou conseguindo achar o ponto onde estoura o array (já que é grande).
Cada posição do array p é um pixel da imagem... então se tenho uma imagem de 800x600 o array p terá 800*600 posições.
O filtro irá percorrer cada posição e alterar baseada numa matriz de valores.
Dei uma olhada nos tipos de dados int mas parece que ele suporta o valor descrito.
Deve ser algum fator que não consigo ver no array.
Bom... segue o código.
publicvoidfiltro(){intwidth=img_in.getWidth();//Armazena a largura da imagem Bufferedintheight=img_in.getHeight();//Armazena a altura da imagem Bufferedint[]p=newint[width*height];//Cria o array de processamento da imagemintdx;intdy;intoffset=0;img_out=newBufferedImage(width,height,BufferedImage.TYPE_BYTE_GRAY);WritableRasterraster=img_out.getRaster();RasterinputRaster=img_in.getData();inputRaster.getPixels(0,0,width,height,p);for(inth=1;h<height;h++){for(intw=1;w<width;w++){dx=0;dy=0;offset=h*width+w;dx=(p[(h-1)*width+(w-1)]*1+p[h*width+(w-1)]*2+p[(h+1)*width+(w-1)]*1)+(p[(h-1)*width+(w+1)]*(-1)+p[h*width+(w+1)]*(-2)+p[(h+1)*width+(w+1)]*(-1));dy=(p[(h-1)*width+(w-1)]*1+p[(h-1)*width+w]*2+p[(h-1)*width+(w+1)]*1)+(p[(h+1)*width+(w-1)]*(-1)+p[(h+1)*width+w]*(-2)+p[(h+1)*width+(w+1)]*(-1));dx+=(p[offset]*9);dy+=(p[offset]*0);dx+=dy;if(dx<0){if((dx*(-1))<=255)raster.setSample(w,h,0,dx*(-1));elseraster.setSample(w,h,0,255);}elseif(dx>255){raster.setSample(w,h,0,255);}elseraster.setSample(w,h,0,dx);}}}
800*600=480000
O seu array tem 480000 posições, numeradas [color=red]de 0 até 479999[/color].
EDIT:
for(inth=1;h<height;h++){for(intw=1;w<width;w++){
Porque você começa em 1, e não em 0?
D
denerfs
É necessário começar na linha 1 e coluna 1 para não gerar ruído na imagem e para aplicar o filtro corretamente.