Inserts a single band into a multi-band image overwriting the original band

@param input Single band image
@param band Which band the image is to be inserted into
@param output The multi-band image which the input image is to be inserted into
432575
public static void insertBand( GrayS32 input, int band , InterleavedS32 output) {

		final int numBands = output.numBands;
		for (int y = 0; y < input.height; y++) {
			int indexIn = input.getStartIndex() + y * input.getStride();
			int indexOut = output.getStartIndex() + y * output.getStride() + band;
			int end = indexOut + output.width*numBands - band;
			for (; indexOut < end; indexOut += numBands , indexIn++ ) {
				output.data[indexOut] = input.data[indexIn];
			}
		}
	}
470890
public static void format(final Source input, final Result output) {
        try {
            // Use an identity transformation to write the source to the result.
            final Transformer transformer = createTransformer(null);
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");

            transformer.transform(input, output);
        } catch (final Exception ex) {
            LOGGER.error("Problem formatting DOM representation.", ex);
        }
    }
504258
protected void connectInner(GrayS32 input, GrayS32 output) {

		int startX = connectRule == ConnectRule.EIGHT ? 1 : 0;

		for( int y = 0; y < input.height-1; y++ ) {
			int indexIn = input.startIndex + y*input.stride + startX;
			int indexOut = output.startIndex + y*output.stride + startX;

			for( int x = startX; x < input.width-1; x++ , indexIn++, indexOut++) {
				int inputLabel = input.data[indexIn];
				int outputLabel = output.data[indexOut];
				if( outputLabel == -1 ) { // see if it needs to create a new output segment
					output.data[indexOut] = outputLabel = regionMemberCount.size;
					regionMemberCount.add(1);
					mergeList.add(outputLabel);
				}

				for( int i = 0; i < edgesIn.length; i++ ) {
					if( inputLabel == input.data[indexIn+edgesIn[i]] ) {
						int outputAdj = output.data[indexOut+edgesOut[i]];
						if( outputAdj == -1 ) {  // see if not assigned
							regionMemberCount.data[outputLabel]++;
							output.data[indexOut+edgesOut[i]] = outputLabel;
						} else if( outputLabel != outputAdj ) { // see if assigned to different regions
							markMerge(outputLabel,outputAdj);
						} // do nothing, same input and output labels
					}
				}
			}
		}
	}
95462
public static <T extends ImageGray<T>> void maximum(Planar<T> input, T output) {
		maximum(input, output, 0, input.getNumBands() - 1);
	}
435605
@Override
	public void setInput( Input input ) {
		super.setInput(input);
		orientation.reshape(input.width,input.height);
		magnitude.reshape(input.width,input.height);

		computePixelFeatures();
	}
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);
				}
			});
		}
	}
634263
public static <In extends ImageGray,Out extends ImageGray>
	Out checkDeclare(In input, Out output , Class<Out> typeOut) {
		if (output == null) {
			output = (Out) GeneralizedImageOps.createSingleBand(typeOut, input.width, input.height);
		} else {
			output.reshape(input.width, input.height);
		}
		return output;
	}
694308
public static <O extends ImageGray<O>>
	void reshapeOutput( ImagePyramid<?> pyramid , O[] output ) {

		for( int i = 0; i < output.length; i++ ) {
			int w = pyramid.getWidth(i);
			int h = pyramid.getHeight(i);
			output[i].reshape(w, h);
		}
	}
477413
public void setInput(INDArray input) {
        this.input = input;
        if (this.layers == null) {
            init();
        }
        if (input != null) {
            if (input.length() == 0)
                throw new IllegalArgumentException(
                        "Invalid input: length 0 (shape: " + Arrays.toString(input.shape()) + ")");

            // FIXME: int cast
            setInputMiniBatchSize((int) input.size(0));
        }
    }
35561
public static void applyTransform(GrayU8 input , int transform[] , GrayU8 output ) {
		output.reshape(input.width,input.height);

		if( BoofConcurrency.USE_CONCURRENT ) {
			ImplEnhanceHistogram_MT.applyTransform(input, transform, output);
		} else {
			ImplEnhanceHistogram.applyTransform(input, transform, output);
		}
	}
1296443
public static <T extends ImageBase<T>> void abs( T input , T output )
	{
		if( input instanceof ImageGray) {
			if (GrayS8.class == input.getClass()) {
				PixelMath.abs((GrayS8) input, (GrayS8) output);
			} else if (GrayS16.class == input.getClass()) {
				PixelMath.abs((GrayS16) input, (GrayS16) output);
			} else if (GrayS32.class == input.getClass()) {
				PixelMath.abs((GrayS32) input, (GrayS32) output);
			} else if (GrayS64.class == input.getClass()) {
				PixelMath.abs((GrayS64) input, (GrayS64) output);
			} else if (GrayF32.class == input.getClass()) {
				PixelMath.abs((GrayF32) input, (GrayF32) output);
			} else if (GrayF64.class == input.getClass()) {
				PixelMath.abs((GrayF64) input, (GrayF64) output);
			}
			// otherwise assume it is an unsigned image type
		} else if( input instanceof ImageInterleaved ) {
			if (InterleavedS8.class == input.getClass()) {
				PixelMath.abs((InterleavedS8) input, (InterleavedS8) output);
			} else if (InterleavedS16.class == input.getClass()) {
				PixelMath.abs((InterleavedS16) input, (InterleavedS16) output);
			} else if (InterleavedS32.class == input.getClass()) {
				PixelMath.abs((InterleavedS32) input, (InterleavedS32) output);
			} else if (InterleavedS64.class == input.getClass()) {
				PixelMath.abs((InterleavedS64) input, (InterleavedS64) output);
			} else if (InterleavedF32.class == input.getClass()) {
				PixelMath.abs((InterleavedF32) input, (InterleavedF32) output);
			} else if (InterleavedF64.class == input.getClass()) {
				PixelMath.abs((InterleavedF64) input, (InterleavedF64) output);
			}
		} else {
			Planar in = (Planar)input;
			Planar out = (Planar)output;

			for (int i = 0; i < in.getNumBands(); i++) {
				abs(in.getBand(i),out.getBand(i));
			}
		}
	}
837792
protected void stageOutput(final String output) {
        boolean print = getPhaseConfiguration().isVerbose();
        if (print) {
            output(INDENT + INDENT + output);
        }
    }
1007913
public static <T extends ImageBase<T>> void plus(T input, double value, T output) {
		if( input instanceof ImageGray) {
			if (GrayU8.class == input.getClass()) {
				PixelMath.plus((GrayU8) input, (int) value, (GrayU8) output);
			} else if (GrayS8.class == input.getClass()) {
				PixelMath.plus((GrayS8) input, (int) value, (GrayS8) output);
			} else if (GrayU16.class == input.getClass()) {
				PixelMath.plus((GrayU16) input, (int) value, (GrayU16) output);
			} else if (GrayS16.class == input.getClass()) {
				PixelMath.plus((GrayS16) input, (int) value, (GrayS16) output);
			} else if (GrayS32.class == input.getClass()) {
				PixelMath.plus((GrayS32) input, (int) value, (GrayS32) output);
			} else if (GrayS64.class == input.getClass()) {
				PixelMath.plus((GrayS64) input, (long) value, (GrayS64) output);
			} else if (GrayF32.class == input.getClass()) {
				PixelMath.plus((GrayF32) input, (float) value, (GrayF32) output);
			} else if (GrayF64.class == input.getClass()) {
				PixelMath.plus((GrayF64) input, value, (GrayF64) output);
			} else {
				throw new IllegalArgumentException("Unknown image Type: " + input.getClass().getSimpleName());
			}
		} else if( input instanceof ImageInterleaved ) {
			if (InterleavedU8.class == input.getClass()) {
				PixelMath.plus((InterleavedU8) input, (int) value, (InterleavedU8) output);
			} else if (InterleavedS8.class == input.getClass()) {
				PixelMath.plus((InterleavedS8) input, (int) value, (InterleavedS8) output);
			} else if (InterleavedU16.class == input.getClass()) {
				PixelMath.plus((InterleavedU16) input, (int) value, (InterleavedU16) output);
			} else if (InterleavedS16.class == input.getClass()) {
				PixelMath.plus((InterleavedS16) input, (int) value, (InterleavedS16) output);
			} else if (InterleavedS32.class == input.getClass()) {
				PixelMath.plus((InterleavedS32) input, (int) value, (InterleavedS32) output);
			} else if (InterleavedS64.class == input.getClass()) {
				PixelMath.plus((InterleavedS64) input, (long) value, (InterleavedS64) output);
			} else if (InterleavedF32.class == input.getClass()) {
				PixelMath.plus((InterleavedF32) input, (float) value, (InterleavedF32) output);
			} else if (InterleavedF64.class == input.getClass()) {
				PixelMath.plus((InterleavedF64) input, value, (InterleavedF64) output);
			} else {
				throw new IllegalArgumentException("Unknown image Type: " + input.getClass().getSimpleName());
			}
		} else {
			Planar in = (Planar)input;
			Planar out = (Planar)output;

			for (int i = 0; i < in.getNumBands(); i++) {
				plus(in.getBand(i),value,out.getBand(i));
			}
		}
	}
900709
public static void grayToBitmap( GrayU8 input , Bitmap output , byte[] storage) {
		if( output.getWidth() != input.getWidth() || output.getHeight() != input.getHeight() ) {
			throw new IllegalArgumentException("Image shapes are not the same");
		}
		
		if( storage == null )
			storage = declareStorage(output,null);
		
		ImplConvertBitmap.grayToArray(input, storage,output.getConfig());
		output.copyPixelsFromBuffer(ByteBuffer.wrap(storage));
	}
71609
public static <T extends ImageGray<T>>
	void applyTransform( T input , int transform[] , int minValue , T output ) {
		InputSanityCheck.checkSameShape(input, output);

		if( input instanceof GrayU8) {
			EnhanceImageOps.applyTransform((GrayU8) input, transform, (GrayU8) output);
		} else if( input instanceof GrayS8) {
			EnhanceImageOps.applyTransform((GrayS8)input,transform,minValue,(GrayS8)output);
		} else if( input instanceof GrayU16) {
			EnhanceImageOps.applyTransform((GrayU16)input,transform,(GrayU16)output);
		} else if( input instanceof GrayS16) {
			EnhanceImageOps.applyTransform((GrayS16)input,transform,minValue,(GrayS16)output);
		} else if( input instanceof GrayS32) {
			EnhanceImageOps.applyTransform((GrayS32)input,transform,minValue,(GrayS32)output);
		} else {
			throw new IllegalArgumentException("Image type not supported. "+input.getClass().getSimpleName());
		}
	}
19748
public static void imageToTensor(Planar<GrayF32> input , Tensor_F32 output , int miniBatch) {
		if( input.isSubimage())
			throw new RuntimeException("Subimages not accepted");
		if( output.getDimension() != 4 )
			throw new IllegalArgumentException("Output should be 4-DOF.  batch + spatial (channel,height,width)");
		if( output.length(1) != input.getNumBands() )
			throw new IllegalArgumentException("Number of bands don't match");
		if( output.length(2) != input.getHeight() )
			throw new IllegalArgumentException("Spatial height doesn't match");
		if( output.length(3) != input.getWidth() )
			throw new IllegalArgumentException("Spatial width doesn't match");

		for (int i = 0; i < input.getNumBands(); i++) {
			GrayF32 band = input.getBand(i);
			int indexOut = output.idx(miniBatch,i,0,0);

			int length = input.width*input.height;
			System.arraycopy(band.data, 0,output.d,indexOut,length);
		}
	}
420808
public static <T extends ImageGray<T>>
	void scaleDown2(T input , T output ) {
		if( input instanceof GrayF32) {
			ImplPyramidOps.scaleDown2((GrayF32)input,(GrayF32)output);
		} else if( input instanceof GrayU8) {
			ImplPyramidOps.scaleDown2((GrayU8)input,(GrayU8)output);
		} else {
			throw new IllegalArgumentException("Image type not yet supported");
		}
	}