private static ImageProcessor doHysterisis(ImageProcessor edges, ImageProcessor gradient, double low, double high){
		ImageProcessor result = new ByteProcessor(edges.getWidth(), edges.getHeight());
		ImageProcessor med = result.duplicate();
		
		LinkedList<Integer> candidates = new LinkedList<Integer>();
		
		//seek strong and medium edges
		for(int i = 0; i < result.getWidth(); i++){
			for(int j = 0; j < result.getHeight(); j++){
				if(edges.get(i,j) == 255){
					double intensity = Float.intBitsToFloat(gradient.get(i,j));
					if(intensity > high){
						result.set(i,j,255);
					}
					if(intensity > low){
						candidates.add(i*result.getHeight() + j);
						med.set(i,j,255);
					}
				}
			}
		}
		//now look for medium edges that form some path to strong edges
		return search(candidates, result, med);
		
	}