Computes the phase of the complex image:<br>
phase = atan2( imaginary , real )
@param transform (Input) Complex interleaved image
@param phase (output) Phase of image
436465
public static void phase( InterleavedF32 transform , GrayF32 phase ) {
		checkImageArguments(phase,transform);

		for( int y = 0; y < transform.height; y++ ) {

			int indexTran = transform.startIndex + y*transform.stride;
			int indexPhase = phase.startIndex + y*phase.stride;

			for( int x = 0; x < transform.width; x++, indexTran += 2 ) {

				float real = transform.data[indexTran];
				float img = transform.data[indexTran+1];

				phase.data[indexPhase++] = (float)Math.atan2(img, real);
			}
		}
	}
135021
public static void rotateImage(File input, File output, String format, int degrees) 
	  throws IOException
	  {
	   	   
		  BufferedImage inputImage = ImageIO.read(input);	   

		    Graphics2D g = (Graphics2D) inputImage.getGraphics();
		    g.drawImage(inputImage, 0, 0, null);
	
		    AffineTransform at = new AffineTransform();
	
		    // scale image
		    //at.scale(2.0, 2.0);
	
		    // rotate 45 degrees around image center
		    at.rotate(degrees * Math.PI / 180.0, inputImage.getWidth() / 2.0, inputImage.getHeight() / 2.0);
		    //at.rotate(Math.toRadians(degrees), inputImage.getWidth() / 2.0, inputImage.getHeight() / 2.0);
	
		   
		    /*
		     * translate to make sure the rotation doesn't cut off any image data
		     */
		    AffineTransform translationTransform;
		    translationTransform = findTranslation(at, inputImage);
		    at.preConcatenate(translationTransform);
		   
		    
		    // instantiate and apply transformation filter
		    BufferedImageOp bio = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
		    
		    BufferedImage destinationBI = bio.filter(inputImage, null);
	
		    ImageIO.write(destinationBI, format, output);
		    
	  }
796257
public static void multiplyRealComplex( GrayF32 realA ,
											InterleavedF32 complexB , InterleavedF32 complexC ) {

		checkImageArguments(realA,complexB);

		InputSanityCheck.checkSameShape( complexB,complexC);

		for( int y = 0; y < realA.height; y++ ) {

			int indexA = realA.startIndex + y*realA.stride;
			int indexB = complexB.startIndex + y*complexB.stride;
			int indexC = complexC.startIndex + y*complexC.stride;

			for( int x = 0; x < realA.width; x++, indexA++ , indexB += 2  ,indexC += 2 ) {

				float real = realA.data[indexA];
				float realB = complexB.data[indexB];
				float imgB = complexB.data[indexB+1];

				complexC.data[indexC] = real*realB;
				complexC.data[indexC+1] = real*imgB;
			}
		}
	}
237248
public void transform (double data[], int i0, int stride) {
    checkData(data,i0,stride);
    int p, p_1, q;

    if (n == 1) return;		/* identity operation */

    /* bit reverse the ordering of input data for decimation in time algorithm */
    bitreverse(data, i0, stride);

    /* apply fft recursion */
    p = 1; q = n ;
    for (int i = 1; i <= logn; i++) {
      int a, b;

      p_1 = p ;
      p = 2 * p ;
      q = q / 2 ;

      /* a = 0 */

      for (b = 0; b < q; b++) {
	double t0_real = data[i0+stride*b*p] + data[i0+stride*(b*p + p_1)];
	double t1_real = data[i0+stride*b*p] - data[i0+stride*(b*p + p_1)];
	  
	data[i0+stride*b*p] = t0_real;
	data[i0+stride*(b*p + p_1)] = t1_real;
      }

      /* a = 1 ... p_{i-1}/2 - 1 */

      {
	double w_real = 1.0;
	double w_imag = 0.0;

	double theta = - 2.0 * Math.PI / p;
	
	double s = Math.sin(theta);
	double t = Math.sin(theta / 2.0);
	double s2 = 2.0 * t * t;
	
	for (a = 1; a < (p_1)/2; a++) {
	  /* trignometric recurrence for w-> exp(i theta) w */
	    
	  {
	    double tmp_real = w_real - s * w_imag - s2 * w_real;
	    double tmp_imag = w_imag + s * w_real - s2 * w_imag;
	    w_real = tmp_real;
	    w_imag = tmp_imag;
	  }
	    
	  for (b = 0; b < q; b++) {
	    double z0_real = data[i0+stride*(b*p + a)];
	    double z0_imag = data[i0+stride*(b*p + p_1 - a)];
	    double z1_real = data[i0+stride*(b*p + p_1 + a)];
	    double z1_imag = data[i0+stride*(b*p + p - a)];
		
	    /* t0 = z0 + w * z1 */
	    data[i0+stride*(b*p + a)]    =z0_real + w_real * z1_real - w_imag * z1_imag;
	    data[i0+stride*(b*p + p - a)]=z0_imag + w_real * z1_imag + w_imag * z1_real;
	    /* t1 = -(z0 - w * z1) */
	    data[i0+stride*(b*p + p_1 - a)]=z0_real - w_real * z1_real + w_imag * z1_imag;
	    data[i0+stride*(b*p + p_1 + a)]=-(z0_imag - w_real * z1_imag - w_imag * z1_real);
	  }
	}
      }

      if (p_1 >  1) {
	for (b = 0; b < q; b++) {
	  /* a = p_{i-1}/2 */
	  data[i0+stride*(b*p + p - p_1/2)] *= -1 ;
	}}
    }
  }
98664
public static void realToComplex(GrayF32 real , InterleavedF32 complex ) {
		checkImageArguments(real,complex);
		for( int y = 0; y < complex.height; y++ ) {

			int indexReal = real.startIndex + y*real.stride;
			int indexComplex = complex.startIndex + y*complex.stride;

			for( int x = 0; x < real.width; x++, indexReal++ , indexComplex += 2 ) {
				complex.data[indexComplex] = real.data[indexReal];
				complex.data[indexComplex+1] = 0;
			}
		}
	}
319574
public void setPhaseId(int v) {
    if (ProcessingStep_Type.featOkTst && ((ProcessingStep_Type)jcasType).casFeat_phaseId == null)
      jcasType.jcas.throwFeatMissing("phaseId", "edu.cmu.lti.oaqa.framework.types.ProcessingStep");
    jcasType.ll_cas.ll_setIntValue(addr, ((ProcessingStep_Type)jcasType).casFeatCode_phaseId, v);}
200626
public static void checkImageArguments( ImageBase image , ImageInterleaved transform ) {
		InputSanityCheck.checkSameShape(image,transform);
		if( 2 != transform.getNumBands() )
			throw new IllegalArgumentException("The transform must have two bands");
	}
23360
@Override
  public void getTransform(Matrix transform) {
    super.getTransform(transform);
    if (mDrawMatrix != null) {
      transform.preConcat(mDrawMatrix);
    }
  }
1186052
void transform_internal (double data[], int i0, int stride, int direction) {
    if (decimate==DECINFREQ) {
      transform_DIF(data,i0,stride,direction); }
    else {
      transform_DIT(data,i0,stride,direction); }}
1369226
public static void realToComplex(GrayF64 real , InterleavedF64 complex ) {
		checkImageArguments(real,complex);
		for( int y = 0; y < complex.height; y++ ) {

			int indexReal = real.startIndex + y*real.stride;
			int indexComplex = complex.startIndex + y*complex.stride;

			for( int x = 0; x < real.width; x++, indexReal++ , indexComplex += 2 ) {
				complex.data[indexComplex] = real.data[indexReal];
				complex.data[indexComplex+1] = 0;
			}
		}
	}
639464
public static void multiply(ComplexPolar_F64 a, ComplexPolar_F64 b, ComplexPolar_F64 result)
    {
        result.r = a.r*b.r;
        result.theta = a.theta + b.theta;
    }
600348
void setPhase(Phase phase){
    TaskStatus.Phase oldPhase = getPhase();
    if (oldPhase != phase){
      // sort phase started
      if (phase == TaskStatus.Phase.SORT){
        setShuffleFinishTime(JobTracker.getClock().getTime());
      } else if (phase == TaskStatus.Phase.REDUCE){
        setSortFinishTime(JobTracker.getClock().getTime());
      }
    }
    this.phase = phase; 
  }
867605
public static void FFT2(ComplexNumber[][] data, Direction direction) {
        int n = data.length;
        int m = data[0].length;
        //ComplexNumber[] row = new ComplexNumber[m];//Math.max(m, n)];

        for (int i = 0; i < n; i++) {
            // copy row
            //for ( int j = 0; j < m; j++ )
            //row[j] = data[i][j];
            ComplexNumber[] row = data[i];
            // transform it
            FourierTransform.FFT(row, direction);
            // copy back
            for (int j = 0; j < m; j++)
                data[i][j] = row[j];
        }

        // process columns
        ComplexNumber[] col = new ComplexNumber[n];

        for (int j = 0; j < m; j++) {
            // copy column
            for (int i = 0; i < n; i++)
                col[i] = data[i][j];
            // transform it
            FourierTransform.FFT(col, direction);
            // copy back
            for (int i = 0; i < n; i++)
                data[i][j] = col[i];
        }
    }
447675
@Override
	public void process(GrayF32 input , GrayU8 output ) {
		inputPow2.reshape(input.width,input.height);
		inputMean.reshape(input.width,input.height);
		inputMeanPow2.reshape(input.width,input.height);
		inputPow2Mean.reshape(input.width,input.height);
		stdev.reshape(input.width,input.height);
		tmp.reshape(input.width,input.height);
		inputPow2.reshape(input.width,input.height);

		int radius = width.computeI(Math.min(input.width,input.height))/2;

		// mean of input image = E[X]
		BlurImageOps.mean(input, inputMean, radius, tmp, work);

		// standard deviation = sqrt( E[X^2] + E[X]^2)
		PixelMath.pow2(input, inputPow2);
		BlurImageOps.mean(inputPow2,inputPow2Mean,radius,tmp, work);
		PixelMath.pow2(inputMean,inputMeanPow2);
		PixelMath.subtract(inputPow2Mean, inputMeanPow2, stdev);
		PixelMath.sqrt(stdev, stdev);

		float R = ImageStatistics.max(stdev);

		if( down ) {
			BoofConcurrency.loopFor(0, input.height, y -> {
				int i = y * stdev.width;
				int indexIn = input.startIndex + y * input.stride;
				int indexOut = output.startIndex + y * output.stride;

				for (int x = 0; x < input.width; x++, i++) {
					// threshold = mean.*(1 + k * ((deviation/R)-1));
					float threshold = inputMean.data[i] * (1.0f + k * (stdev.data[i] / R - 1.0f));
					output.data[indexOut++] = (byte) (input.data[indexIn++] <= threshold ? 1 : 0);
				}
			});
		} else {
			BoofConcurrency.loopFor(0, input.height, y -> {
				int i = y * stdev.width;
				int indexIn = input.startIndex + y * input.stride;
				int indexOut = output.startIndex + y * output.stride;

				for (int x = 0; x < input.width; x++, i++) {
					// threshold = mean.*(1 + k * ((deviation/R)-1));
					float threshold = inputMean.data[i] * (1.0f + k * (stdev.data[i] / R - 1.0f));
					output.data[indexOut++] = (byte) (input.data[indexIn++] >= threshold ? 1 : 0);
				}
			});
		}
	}
910041
private void writeAffineTransform (final AffineTransform transform) throws IOException
  {
    final double [] values = new double [6];
    transform.getMatrix (values);
    for (final double v : values)
    {
      writeOperand ((float) v);
    }
  }
1021803
void applyTransformation(Transformation2D transform) {
		m_vertices_mp.applyTransformation(transform);
		if (m_segments != null) {
			for (int i = 0, n = m_segments.size(); i < n; i++) {
				if (m_segments.get(i) != null) {
					m_segments.get(i).applyTransformation(transform);
				}
			}
		}
	}
1295244
@Override
	public void addWithAutomaticPhasing (Schedulable schedulable, int frequency) {
		// Calculate the phase and add the schedulable to the list
		add(schedulable, frequency, calculatePhase(frequency));
	}