najah01_3
Messages postés35Date d'inscriptiondimanche 24 septembre 2006StatutMembreDernière intervention17 juillet 2007
-
23 juin 2007 à 07:03
Twinuts
Messages postés5375Date d'inscriptiondimanche 4 mai 2003StatutModérateurDernière intervention14 juin 2023
-
23 juin 2007 à 14:07
salam ,
voila mon code qui fait un detecteur horizoatal et vertical . mais le probleme est qu il ne donne pas le resultat siuhaitable . parfois il affiche l image tel quelle .
public int filterRGB(int x, int y, int rgb) {
if (y == 0) {
return rgb ;
}
if (x == 0) {
return rgb ;
}
int yprevious = y - 1 ;
if (yprevious < 0 ) {
yprevious = width - 1;
}
int xprevious = x - 1 ;
if (xprevious < 0 ) {
xprevious = height - 1;
}
int ypreviousRGB = data[width*x + yprevious] ;
int xpreviousRGB = data[x + xprevious*height] ;
int a1 = (rgb >> 24) & 0xFF;
int r1 = (rgb >> 16) & 0xFF;
int g1= (rgb >> 8) & 0xFF;
int b1= rgb & 0xFF;
int r2 = (ypreviousRGB >> 16) & 0xFF;
int g2 = (ypreviousRGB >> 8) & 0xFF ;
int b2 = ypreviousRGB & 0xFF;
int r3 = (xpreviousRGB >> 16) & 0xFF;
int g3 = (xpreviousRGB >> 8) & 0xFF ;
int b3 = xpreviousRGB & 0xFF;
int r4 = r2 - r1 ;
int g4 = g2 - g1 ;
int b4 = b2 - b1 ;
int r5 = r3 - r1 ;
int g5 = g3 - g1 ;
int b5 = b3 - b1 ;
int r6 =(int) (Math.sqrt((r4*r4)+(r5*r5)));
int g6 = (int)(Math.sqrt((g4*g4)+(g5*g5)));
int b6 = (int) (Math.sqrt((b4*b4)+(b5*b5)));