Signal, sons, images Translation, rotation, zoom, interpolation bilinéaire Rappel Un pixel est codé de la manière suivante : Couleur = b + 256(g+256*r) Translation (Java) Il existe deux possibilités pour effectuer une translation d’image : bout = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); for( int i = 0; i < w; i++ ) for( int j = 0 ; j < h; j++ ){ //Sens naturel //Sens inverse mais pas de contrôle double newI = i+tx; nécessaire (getPixel retourne un pixel double newJ = j+ty; noir si hors de l'image) if(newI>0 && newJ>0 && newI<w && newJ<h) double newI = i-tx; bout.setRGB((int)newI,(int)newJ double newJ = j-ty; ,getPixel(bin,i,j)); bout.setRGB(i,j,getPixel(bin,(int)newI ,(int)newJ)); } Rotation (Java) bout = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); double tetaRadian = (Math.PI*angle)/180; //Conversion en radian for( int i = 0; i < w; i++ ) for( int j = 0 ; j < h; j++ ){ //cx et cy sont les coordonnées du center de l’image int x = (int) ((Math.cos(tetaRadian)*(icx)+Math.sin(tetaRadian)*(j-cy))+cx); int y = (int) ((-Math.sin(tetaRadian)*(icx)+Math.cos(tetaRadian)*(j-cy))+cy); bout.setRGB(i,j,getPixel(bin,x,y)); } Zoom (Java) bout = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); for( int i = 0; i < w; i++ ) for( int j = 0 ; j < h; j++ ){ //scale = indice du zoom (x2, x4,…) double x = ((i-cx)/scale)+cx; double y = ((j-cy)/scale)+cy; bout.setRGB(i,j,getPixel(bin,(int)x,(int)y)); } Scale (Java) bout = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); for( int i = 0; i < w; i++ ) for( int j = 0 ; j < h; j++ ){ double x = ((i-cx)/scale)+cx; double y = ((j-cy)/scale)+cy; bout.setRGB(i,j,getPixel(bin,(int)x,(int)y)); } Interpolation bilinéaire Interpolation : Permet d’estimer la couleur du pixel en fonction des pixels voisins. Dans le cas d’une interpolation bilinéaire on va prendre la distance avec tous les pixels proches et faire la moyenne de leur distance (on choisira alors l’arrondit le plus proche).