package descriptors; import java.awt.image.BufferedImage; import java.util.Arrays; import preprocessing.Util; import segmentation.Labels; import segmentation.Regions; public class Polar { final double M_PI = 3.14159265358979323846; int barycenter_x; int barycenter_y; public void computeGravityCenter (BufferedImage image) { int i=0; int width = image.getWidth(); int height = image.getHeight(); int[] array = Util.getImageArray (image); // System.out.println("w : "+width+" h : "+height); // System.out.println(Arrays.toString(array)); int surface=0; barycenter_x=0; barycenter_y=0; for(int y=0;yd_max)?distance:d_max; } } //if (studied_region == 100) // System.out.println("D_max : " + d_max); pas_angulaire=( M_PI*2.0 / ANGLE ); //1.0/(double)RAYON; //if (studied_region == 100) // System.out.println("pas_ang : " + pas_angulaire); pas_largeur=(double)d_max/(double)RAYON; //if (studied_region == 100) // System.out.println("pas_largeur : " + pas_largeur + " dmax : " + d_max); r_pol=0;l=0; for(r=0;r x_max || X < x_min) { /*if (studied_region == 100) { System.out.println("pixel : " + l + " vale : 0"); }*/ outarray[l++]=0; continue; } if (Y > y_max || Y < y_min) { /*if (studied_region == 100) { System.out.println("pixel : " + l + " vale : 0"); }*/ outarray[l++]=0; continue; } if (lab.getValue(X + Y * width) == studied_region) { /*if (studied_region == 100) { System.out.println("pixel : " + l + " vale : 255 " + " labval : " + lab.getValue(X + Y * width) + " X : " + X + " Y : " + Y + " w : " + width); }*/ outarray[l++]=255; } else { /*if (studied_region == 100) { System.out.println("pixel : " + l + " vale : 0 " + " labval : " + lab.getValue(X + Y * width) + " X : " + X + " Y : " + Y + " w : " + width); }*/ outarray[l++]=0; } } r_pol+=pas_largeur; } /*if (studied_region == 100) for(r = 0;r < (ANGLE *RAYON);r++) { System.out.println("pos : " + r + " pixel : " + outarray[r] + " R_pol : " + r_pol); } */ //System.err.printf("O tamanho do polar size eh %d\n", size_polar); int startX = 0; int startY = 0; Util.greyToColorImage (outarray, ANGLE, RAYON); outimg.setRGB(startX, startY, ANGLE, RAYON, outarray, 0, ANGLE); return outimg; } public BufferedImage Compute_Polar_Image (BufferedImage image, int ANGLE, int RAYON) { int bclX, bclY; int l; int d_max=0; double pas_angulaire; double pas_largeur; double r_pol; int r; double theta; int width = image.getWidth(); int height = image.getHeight(); BufferedImage outimg = new BufferedImage(ANGLE, RAYON, BufferedImage.TYPE_INT_RGB); int[] outarray = new int[ANGLE*RAYON]; int[] array = Util.getImageArray (image); //if (studied_region == 100) // System.out.println("Rayon : " + RAYON + " Angle : " + ANGLE + " x_min : " + x_min + " x_max : " + x_max + " y_min : " + y_min+ " y_max : " + y_max); for(bclY = 0; bclY < height; bclY++) for(bclX = 0; bclX < width; bclX++) { if (array[bclX+bclY*width]!=0) { int distance=(int)(Math.ceil(Math.sqrt( (bclX-barycenter_x)*(bclX-barycenter_x)+(bclY-barycenter_y)*(bclY-barycenter_y) ) ) ) ; d_max=(distance>d_max)?distance:d_max; } } //if (studied_region == 100) // System.out.println("D_max : " + d_max); pas_angulaire=( M_PI*2.0 / ANGLE ); //1.0/(double)RAYON; //if (studied_region == 100) // System.out.println("pas_ang : " + pas_angulaire); pas_largeur=(double)d_max/(double)RAYON; //if (studied_region == 100) // System.out.println("pas_largeur : " + pas_largeur + " dmax : " + d_max); r_pol=0;l=0; for(r=0;r= width || X<0) { /*if (studied_region == 100) { System.out.println("pixel : " + l + " vale : 0"); }*/ outarray[l++]=0; continue; } if (Y >= height || Y < 0) { /*if (studied_region == 100) { System.out.println("pixel : " + l + " vale : 0"); }*/ outarray[l++]=0; continue; } if (array[X + Y * width] != 0 ) { /*if (studied_region == 100) { System.out.println("pixel : " + l + " vale : 255 " + " labval : " + lab.getValue(X + Y * width) + " X : " + X + " Y : " + Y + " w : " + width); }*/ outarray[l++]=255; } else { /*if (studied_region == 100) { System.out.println("pixel : " + l + " vale : 0 " + " labval : " + lab.getValue(X + Y * width) + " X : " + X + " Y : " + Y + " w : " + width); }*/ outarray[l++]=0; } } r_pol+=pas_largeur; } /*if (studied_region == 100) for(r = 0;r < (ANGLE *RAYON);r++) { System.out.println("pos : " + r + " pixel : " + outarray[r] + " R_pol : " + r_pol); } */ int startX = 0; int startY = 0; Util.greyToColorImage (outarray, ANGLE, RAYON); outimg.setRGB(startX, startY, ANGLE, RAYON, outarray, 0, ANGLE); return outimg; } public int matrix_size2 (int ANGLE) { int size = 0; for(int u=-ANGLE/2+1,i=0;id_max)?distance:d_max; } } pas_angulaire=( M_PI*2.0 / ANGLE ); pas_largeur=(double)d_max/(double)RAYON; r_pol=0;l=0; for(r=0;r x_max || X < x_min || Y > y_max || Y < y_min) { outarray[l++]=0; continue; } if (lab.getValue(X + Y * width) == studied_region) { outarray[l++]=255; } else { outarray[l++]=0; } } r_pol+=pas_largeur; } return outarray; } public BufferedImage Compute_TF_Image (BufferedImage inimg, int ANGLE, int RAYON) { int width = ANGLE; int height = RAYON; int[] inarray = Util.getImageArray(inimg); BufferedImage outimg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); int[] outarray = new int[width*height]; //System.out.println("Rayon : " + RAYON + " Angle : " + ANGLE); int i,j,k; int offset, offsetY; int u; for(j = 0, offset = 0, offsetY = 0; j < RAYON; j++, offsetY += width) { for(u=-ANGLE/2+1,i=0;i