<p>
Performs pixel-wise addition<br>
d(x,y) = inputA(x,y) + inputB(x,y)
</p>
@param inputA Input image. Not modified.
@param inputB Input image. Not modified.
@param output Output image. Modified.
641
public static <T extends ImageBase<T>, O extends ImageBase>
	void add(T inputA, T inputB, O output) {
		if( inputA instanceof ImageGray) {
			if (GrayU8.class == inputA.getClass()) {
				PixelMath.add((GrayU8) inputA, (GrayU8) inputB, (GrayU16) output);
			} else if (GrayS8.class == inputA.getClass()) {
				PixelMath.add((GrayS8) inputA, (GrayS8) inputB, (GrayS16) output);
			} else if (GrayU16.class == inputA.getClass()) {
				PixelMath.add((GrayU16) inputA, (GrayU16) inputB, (GrayS32) output);
			} else if (GrayS16.class == inputA.getClass()) {
				PixelMath.add((GrayS16) inputA, (GrayS16) inputB, (GrayS32) output);
			} else if (GrayS32.class == inputA.getClass()) {
				PixelMath.add((GrayS32) inputA, (GrayS32) inputB, (GrayS32) output);
			} else if (GrayS64.class == inputA.getClass()) {
				PixelMath.add((GrayS64) inputA, (GrayS64) inputB, (GrayS64) output);
			} else if (GrayF32.class == inputA.getClass()) {
				PixelMath.add((GrayF32) inputA, (GrayF32) inputB, (GrayF32) output);
			} else if (GrayF64.class == inputA.getClass()) {
				PixelMath.add((GrayF64) inputA, (GrayF64) inputB, (GrayF64) output);
			} else {
				throw new IllegalArgumentException("Unknown image Type: " + inputA.getClass().getSimpleName());
			}
		} else if (inputA instanceof Planar) {
			Planar inA = (Planar)inputA;
			Planar inB = (Planar)inputB;
			Planar out = (Planar)output;

			for (int i = 0; i < inA.getNumBands(); i++) {
				add(inA.getBand(i),inB.getBand(i),out.getBand(i));
			}
		}
	}
376022
public static void log( GrayF32 input , GrayF32 output ) {

		output.reshape(input.width,input.height);

		if( BoofConcurrency.USE_CONCURRENT ) {
			ImplPixelMath_MT.log(input,output);
		} else {
			ImplPixelMath.log(input,output);
		}
	}
956647
@Override
    public Matrix applyCommon(Matrix a, Matrix b) {
        int n = a.rows() * b.rows();
        int m = a.columns() * b.columns();
        int p = b.rows();
        int q = b.columns();

        Matrix result = a.blankOfShape(n, m);

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                result.set(i, j, a.get(i / p, j / q) * b.get(i % p, j % q));
            }
        }

        return result;
    }
30314
public static void divide( GrayU8 input , double denominator , GrayU8 output ) {

		output.reshape(input.width,input.height);

		int columns = input.width;
		if(BoofConcurrency.USE_CONCURRENT ) {
			ImplPixelMath_MT.divideU_A(input.data,input.startIndex,input.stride,denominator , 
					output.data,output.startIndex,output.stride,
					input.height,columns);
		} else {
			ImplPixelMath.divideU_A(input.data,input.startIndex,input.stride,denominator , 
					output.data,output.startIndex,output.stride,
					input.height,columns);
		}
	}
1199059
public static void independent( BufferedImage input ) {
		// convert the BufferedImage into a Planar
		Planar<GrayU8> image = ConvertBufferedImage.convertFromPlanar(input,null,true,GrayU8.class);

		// declare the output blurred image
		Planar<GrayU8> blurred = image.createSameShape();
		
		// Apply Gaussian blur to each band in the image
		for( int i = 0; i < image.getNumBands(); i++ ) {
			// note that the generalized version of BlurImageOps is not being used, but the type
			// specific version.
			BlurImageOps.gaussian(image.getBand(i),blurred.getBand(i),-1,5,null);
		}
		
		// Declare the BufferedImage manually to ensure that the color bands have the same ordering on input
		// and output
		BufferedImage output = new BufferedImage(image.width,image.height,input.getType());
		ConvertBufferedImage.convertTo(blurred, output,true);

		gui.addImage(input,"Input");
		gui.addImage(output,"Gaussian Blur");
	}
429424
public static double sum( ImageBase input ) {

		if( input instanceof ImageGray) {
			if (GrayU8.class == input.getClass()) {
				return ImageStatistics.sum((GrayU8) input);
			} else if (GrayS8.class == input.getClass()) {
				return ImageStatistics.sum((GrayS8) input);
			} else if (GrayU16.class == input.getClass()) {
				return ImageStatistics.sum((GrayU16) input);
			} else if (GrayS16.class == input.getClass()) {
				return ImageStatistics.sum((GrayS16) input);
			} else if (GrayS32.class == input.getClass()) {
				return ImageStatistics.sum((GrayS32) input);
			} else if (GrayS64.class == input.getClass()) {
				return ImageStatistics.sum((GrayS64) input);
			} else if (GrayF32.class == input.getClass()) {
				return ImageStatistics.sum((GrayF32) input);
			} else if (GrayF64.class == input.getClass()) {
				return ImageStatistics.sum((GrayF64) input);
			} else {
				throw new IllegalArgumentException("Unknown image Type");
			}
		} else if( input instanceof ImageInterleaved ) {
			if (InterleavedU8.class == input.getClass()) {
				return ImageStatistics.sum((InterleavedU8) input);
			} else if (InterleavedS8.class == input.getClass()) {
				return ImageStatistics.sum((InterleavedS8) input);
			} else if (InterleavedU16.class == input.getClass()) {
				return ImageStatistics.sum((InterleavedU16) input);
			} else if (InterleavedS16.class == input.getClass()) {
				return ImageStatistics.sum((InterleavedS16) input);
			} else if (InterleavedS32.class == input.getClass()) {
				return ImageStatistics.sum((InterleavedS32) input);
			} else if (InterleavedS64.class == input.getClass()) {
				return ImageStatistics.sum((InterleavedS64) input);
			} else if (InterleavedF32.class == input.getClass()) {
				return ImageStatistics.sum((InterleavedF32) input);
			} else if (InterleavedF64.class == input.getClass()) {
				return ImageStatistics.sum((InterleavedF64) input);
			} else {
				throw new IllegalArgumentException("Unknown image Type");
			}
		} else if( input instanceof Planar ) {
			double sum = 0;
			Planar in = (Planar) input;
			for (int i = 0; i < in.getNumBands(); i++) {
				sum += sum( in.getBand(i));
			}
			return sum;
		} else {
			throw new IllegalArgumentException("Image type not yet supported "+input.getClass().getSimpleName());
		}
	}
480553
public static void addEquals( DMatrix3 a , DMatrix3 b ) {
        a.a1 += b.a1;
        a.a2 += b.a2;
        a.a3 += b.a3;
    }
71002
public void setInput( I input ) {
		this.inputImage = input;

		// reset the state flag so that everything need sto be computed
		if( stale != null ) {
			for( int i = 0; i < stale.length; i++) {
				boolean a[] = stale[i];
				for( int j = 0; j < a.length; j++ ) {
					a[j] = true;
				}
			}
		}
	}
469099
public static void changeSign(DMatrixD1 input , DMatrixD1 output)
    {
        output.reshape(input.numRows,input.numCols);

        final int size = input.getNumElements();

        for( int i = 0; i < size; i++ ) {
            output.data[i] = -input.data[i];
        }
    }
394275
public static void fill(GrayI16 input, int value) {

		for (int y = 0; y < input.height; y++) {
			int index = input.getStartIndex() + y * input.getStride();
			Arrays.fill(input.data,index,index+input.width, (short)value);
		}
	}
1368752
public static void elementDiv(DMatrixD1 a , DMatrixD1 b )
    {
        if( a.numCols != b.numCols || a.numRows != b.numRows ) {
            throw new MatrixDimensionException("The 'a' and 'b' matrices do not have compatible dimensions");
        }

        int length = a.getNumElements();

        for( int i = 0; i < length; i++ ) {
            a.div(i, b.get(i));
        }
    }
1351571
@Override
	public void process(GrayF32 input , GrayU8 output ) {
		imageI2.reshape(input.width,input.height);
		meanImage.reshape(input.width,input.height);
		meanI2.reshape(input.width,input.height);
		tmp.reshape(input.width,input.height);
		imageI2.reshape(input.width,input.height);

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

		float NP = (radius*2+1)*(radius*2+1);

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

		// Compute I^2
		PixelMath.pow2(input, imageI2);

		// Compute local mean of I^2
		BlurImageOps.mean(imageI2, meanI2, radius, tmp, work);

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

				for (int x = 0; x < input.width; x++, i++) {
					float mean = meanImage.data[i];
					float A = meanI2.data[i] - (mean*mean/NP);

					// threshold = mean + k*sqrt( A )
					float threshold = mean + k*(float)Math.sqrt(A);
					output.data[indexOut++] = (byte) (input.data[indexIn++] <= threshold ? 1 : 0);
				}
			}
			//CONCURRENT_ABOVE });
		} else {
			//CONCURRENT_BELOW BoofConcurrency.loopFor(0, input.height, y -> {
			for (int y = 0; y < input.height; y++) {
				int i = y * meanI2.width;
				int indexIn = input.startIndex + y * input.stride;
				int indexOut = output.startIndex + y * output.stride;

				for (int x = 0; x < input.width; x++, i++) {
					float mean = meanImage.data[i];
					float A = meanI2.data[i] - (mean*mean/NP);

					// threshold = mean + k*sqrt( A )
					float threshold = mean + k*(float)Math.sqrt(A);
					output.data[indexOut++] = (byte) (input.data[indexIn++] >= threshold ? 1 : 0);
				}
			}
			//CONCURRENT_ABOVE });
		}
	}
1282940
public static void fill(InterleavedI16 input, int value) {

		for (int y = 0; y < input.height; y++) {
			int index = input.getStartIndex() + y * input.getStride();
			int end = index + input.width*input.numBands;
			Arrays.fill(input.data,index,end, (short)value);
		}
	}
193028
public static void diag( DMatrix4x4 input , DMatrix4 out ) {
        out.a1 = input.a11;
        out.a2 = input.a22;
        out.a3 = input.a33;
        out.a4 = input.a44;
    }
6984
public void add(String input) {
        TrieNode currentNode = root;

        for(char c: input.toCharArray()) {
            Map<Character, TrieNode> children = currentNode.getChildren();
            TrieNode matchingNode = children.get(c);
            if(matchingNode != null) {
                currentNode = matchingNode;
            } else {
                TrieNode newNode = new TrieNode();
                children.put(c, newNode);
                currentNode = newNode;
            }
        }
        currentNode.end=true; // this is the end of an input that was added, there may be more children
    }
259241
public void process( Input left , Input right , Disparity disparity ) {
		// initialize data structures
		InputSanityCheck.checkSameShape(left, right, disparity);

		if( maxDisparity >  left.width-2*radiusX )
			throw new RuntimeException(
					"The maximum disparity is too large for this image size: max size "+(left.width-2*radiusX));

		lengthHorizontal = left.width*rangeDisparity;

		_process(left,right,disparity);
	}
544024
@Deprecated
	public void addSecondInput(Operator<IN2>... input) {
		this.input2 = Operator.createUnionCascade(this.input2, input);
	}