import java.awt.*;
import java.awt.image.*;
import java.io.*;

// Super-class for noise functions
public abstract class noiseFilter extends EffectFilter
{
	// Global variables
	int SIZE = 1000;
	int Mid;
	
	// Returns a random value in a probability array	
	public void calc_array(double[] prob_in)
	{
		int Low = 0;
		int High = SIZE-1;
		double Rand = Math.random()*(SIZE-1) + 1;
		
		// Finds the value
		while (Low < High)
		{
			Mid = (Low + High)/2;
			if ((prob_in[Mid]* SIZE) < Rand)
			{
				Low = Mid +1;
			}
			else if ((prob_in[Mid] * SIZE) > Rand)
			{
				High = Mid -1;
			}
			else
			{
				Low = High = Mid;
			}
		}		
	}
}
