Translation, rotation, zoom, interpolation bilinéaire

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
double newI = i+tx;
double newJ = j+ty;
if(newI>0 && newJ>0 && newI<w && newJ<h)
bout.setRGB((int)newI,(int)newJ
,getPixel(bin,i,j));
//Sens inverse mais pas de contrôle
nécessaire (getPixel retourne un pixel
noir si hors de l'image)
double newI = i-tx;
double newJ = j-ty;
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)*(i-
cx)+Math.sin(tetaRadian)*(j-cy))+cx);
int y = (int) ((-Math.sin(tetaRadian)*(i-
cx)+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).
1 / 1 100%

Translation, rotation, zoom, interpolation bilinéaire

La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans linterface ou les textes ? Ou savez-vous comment améliorer linterface utilisateur de StudyLib ? Nhésitez pas à envoyer vos suggestions. Cest très important pour nous !