2 pièce(s) jointe(s)
petit bug sur convolution
alors je vois pas trop d'ou vient mon probleme, a gauche une image moyennée par ImageJ (radius=10) a droite ma propre implantation.
je n'arrive pas à expliquer l'effet de stries qu on y voit... problème de base à mon avis :aie:
Pourtant mon parcours ressemble a 2 gouttes d'eau a celui d'IJ :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
int width = img.getWidth();
int height = img.getHeight();
int[] res = new int[width*height];
int rad = 10;
int xedge = width-rad;
int yedge = height-rad;
for (int y = 0 ; y < height; y++ ) {
int offset1 = y*width;;
for (int x = 0 ; x < width ; x++) {
int pixel = x+offset1;
int[][] vignet_ = new int[rad * 2 + 1][rad * 2 + 1];
edgePixel = y<rad || y>=yedge || x<rad || x>=xedge;
for (int ym = -rad; ym <= rad; ym++){
int offset = x+(y+ym)*width;
for (int xm = -rad; xm <= rad; xm++){
if (!edgePixel)
vignet_[ym+rad][xm+rad] = ip.get(offset+xm);
else
vignet_[ym+rad][xm+rad] = getPixel(x+xm, y+ym, width, height);
}
}
res[pixel]= (int) mean(vignet_);
}
} |
une idée ?