package FFT; /** * This class is a custom class used for storing and manipulating grayscale images * with double values * * @author bka * @version "0.1" */ /** * The class produces an iRPImage with double values */ public class doubleiRPImage{ protected int sizeX; protected int sizeY; protected double image[]; /** * Constructs an empty doubleiRPImage */ public doubleiRPImage() { sizeX = 0; sizeY = 0; image = new double[sizeX*sizeY]; } /** * Constructs an doubleiRPImage with given width and height * * @param width the width of the doubleiRPImage * @param height the height of the doubleiRPImage */ public doubleiRPImage(int width, int height) { sizeX = width; sizeY = height; image = new double[sizeX * sizeY]; } public void Clear(double v) { int i; for (i=0;imax) { max = image[i]; position = i; } } return position; } /** * Makes a copy of the doubleiRPImage * * @return the copy of this doubleiRPImage */ public doubleiRPImage copy() { doubleiRPImage G = new doubleiRPImage(this.GetSizeX(), this.GetSizeY()); for(int i =0; i< sizeX * sizeY ; i++) { G.image[i] = image[i]; } return G; } /** * Returns the arrayvalue of the doubleiRPImage on the place (x,y) * * @param x x position of the pixel * y y position of the pixel * @return the value of image at position (x,y) */ public double GetPixel(int x, int y){ return image[x + y * sizeX]; } /** * Returns the value of the image[] array on position i * * @param i the specified position * @return value of image[] at position i */ public double GetPixel(int i){ return image[i]; } /** * Sets the value of image[] at position (x,y) to a desired value * * @param x x-position * y y-position * value the desired value */ public void SetPixel(int x, int y, double value) { image[x + y * sizeX] = value; } /** * Sets the value of image[] at position i to a desired value * * @param i position i * value the desired value */ public void SetPixel(int i,double value){ image[i]=value; } /* * Zieht eine Linie von (a1,b1) nach (a2,b2) und setzt den jeweiligen * Pixelwert auf 'value' */ public void drawLineWithConstantValue(int a1,int b1,int a2,int b2,int value){ double a,b,delta; //System.out.println("("+a1+","+b1+") ("+a2+","+b2); if(Math.abs(b2-b1)a2) delta=-1; else delta=1; for(a = a1; a != a2+delta; a+=delta)//for(a = a1; a < a2; a++) { b = (double)b1 + ((double)(b2-b1)* ((double)a-(double)a1)/((double)a2-(double)a1)); //Die Abfrage ist zufallig wegen ArrayindexofBoundexception!! if(((int)b != sizeY) && ((int)a !=sizeX)) { SetPixel((int)a,(int)b, (double)value); } } } else { if (b1>b2) delta=-1; else delta=1; for(b = b1; b != b2+delta; b+=delta) { a =(double)a1 + ((double)(a2-a1)* ((double)b-(double)b1)/((double)b2-(double)b1)); if((int)b != sizeY && ((int)a != sizeX)) { SetPixel((int)a , (int)b , (double)value); } } } } /** * Makes an iRPImage of this doubleiRPImage * * @return iRPImage of this doubleiRPImage */ public iRPImage makeiRPImage() { double min, max; min = GetPixel(GetMin()); max = GetPixel(GetMax()); iRPImage A = new iRPImage(sizeX, sizeY); for(int i=0; i