Down samples a planar image.  Type checking is done at runtime.

@param input Input image. Not modified.
@param sampleWidth Width of square region.
@param output Output image. Modified.
491123
public static <T extends ImageGray<T>> void down(Planar<T> input ,
												  int sampleWidth , Planar<T> output )
	{
		for( int band = 0; band < input.getNumBands(); band++ ) {
			down(input.getBand(band), sampleWidth, output.getBand(band));
		}
	}
447767
public void seg(File input, File output) throws Exception{
        Utils.seg(input, output, isRemoveStopWord(), segmentation.getSegmentationAlgorithm(), word -> statistics(word, 1, statisticsMap));
    }
937815
public static <T extends ImageGray<T>> void stdDev(Planar<T> input, T output, @Nullable T avg) {
		stdDev(input, output, avg, 0, input.getNumBands() - 1);
	}
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);
		}
	}
472169
public static void convertToBoof(Picture input, ImageBase output) {
		if( input.getColor() == ColorSpace.RGB ) {
			ImplConvertJCodecPicture.RGB_to_PLU8(input, (Planar) output);
		} else if( input.getColor() == ColorSpace.YUV420 ) {
			if( output instanceof Planar) {
				Planar ms = (Planar)output;
				if( ms.getImageType().getDataType() == ImageDataType.U8 ) {
					ImplConvertJCodecPicture.yuv420_to_PlRgb_U8(input, ms);
				} else if( ms.getImageType().getDataType() == ImageDataType.F32 ) {
					ImplConvertJCodecPicture.yuv420_to_PlRgb_F32(input, ms);
				}
			} else if( output instanceof GrayU8) {
				ImplConvertJCodecPicture.yuv420_to_U8(input, (GrayU8) output);
			} else if( output instanceof GrayF32) {
				ImplConvertJCodecPicture.yuv420_to_F32(input, (GrayF32) output);
			} else {
				throw new RuntimeException("Unexpected output image type");
			}
		}
	}
844553
public static int downSampleSize( int length , int squareWidth ) {
		int ret = length/squareWidth;
		if( length%squareWidth != 0 )
			ret++;

		return ret;
	}
506760
protected void initialize(T input , GrayS32 output ) {
		this.graph = output;
		final int N = input.width*input.height;

		regionSize.resize(N);
		threshold.resize(N);
		for( int i = 0; i < N; i++ ) {
			regionSize.data[i] = 1;
			threshold.data[i] = K;
			graph.data[i] = i; // assign a unique label to each pixel since they are all their own region initially
		}

		edges.reset();
		edgesNotMatched.reset();
	}
23420
public static void RGB_to_PLU8(Picture input, Planar<GrayU8> output) {
		if( input.getColor() != ColorSpace.RGB )
			throw new RuntimeException("Unexpected input color space!");
		if( output.getNumBands() != 3 )
			throw new RuntimeException("Unexpected number of bands in output image!");

		output.reshape(input.getWidth(),input.getHeight());

		int dataIn[] = input.getData()[0];

		GrayU8 out0 = output.getBand(0);
		GrayU8 out1 = output.getBand(1);
		GrayU8 out2 = output.getBand(2);

		int indexIn = 0;
		int indexOut = 0;
		for (int i = 0; i < output.height; i++) {
			for (int j = 0; j < output.width; j++, indexOut++ ) {
				int r = dataIn[indexIn++];
				int g = dataIn[indexIn++];
				int b = dataIn[indexIn++];

				out2.data[indexOut] = (byte)r;
				out1.data[indexOut] = (byte)g;
				out0.data[indexOut] = (byte)b;
			}
		}
	}
7523
static void downSamplingMergeInto(final DoublesSketch src, final UpdateDoublesSketch tgt) {
    final int srcK = src.getK();
    final int tgtK = tgt.getK();
    final long tgtN = tgt.getN();

    if ((srcK % tgtK) != 0) {
      throw new SketchesArgumentException(
          "source.getK() must equal target.getK() * 2^(nonnegative integer).");
    }

    final int downFactor = srcK / tgtK;
    checkIfPowerOf2(downFactor, "source.getK()/target.getK() ratio");
    final int lgDownFactor = Integer.numberOfTrailingZeros(downFactor);

    if (src.isEmpty()) { return; }

    final DoublesSketchAccessor srcSketchBuf = DoublesSketchAccessor.wrap(src);
    final long nFinal = tgtN + src.getN();

    for (int i = 0; i < srcSketchBuf.numItems(); i++) { // update only the base buffer
      tgt.update(srcSketchBuf.get(i));
    }

    final int spaceNeeded = DoublesUpdateImpl.getRequiredItemCapacity(tgtK, nFinal);
    final int curCombBufCap = tgt.getCombinedBufferItemCapacity();
    if (spaceNeeded > curCombBufCap) { //copies base buffer plus current levels
      tgt.growCombinedBuffer(curCombBufCap, spaceNeeded);
    }

    //working scratch buffers
    final DoublesArrayAccessor scratch2KAcc = DoublesArrayAccessor.initialize(2 * tgtK);
    final DoublesArrayAccessor downScratchKAcc = DoublesArrayAccessor.initialize(tgtK);

    final DoublesSketchAccessor tgtSketchBuf = DoublesSketchAccessor.wrap(tgt, true);

    long srcBitPattern = src.getBitPattern();
    long newTgtBitPattern = tgt.getBitPattern();
    for (int srcLvl = 0; srcBitPattern != 0L; srcLvl++, srcBitPattern >>>= 1) {
      if ((srcBitPattern & 1L) > 0L) {
        justZipWithStride(
                srcSketchBuf.setLevel(srcLvl),
                downScratchKAcc,
                tgtK,
                downFactor
        );
        newTgtBitPattern = DoublesUpdateImpl.inPlacePropagateCarry(
                srcLvl + lgDownFactor,    //starting level
                downScratchKAcc,       //optSrcKBuf,
                scratch2KAcc,          //size2KBuf,
                false,                    //do mergeInto version
                tgtK,
                tgtSketchBuf,
                newTgtBitPattern
        );

        tgt.putBitPattern(newTgtBitPattern); //off-heap is a no-op
      }
    }
    if (tgt.isDirect() && (nFinal > 0)) {
      final WritableMemory mem = tgt.getMemory();
      mem.clearBits(FLAGS_BYTE, (byte) EMPTY_FLAG_MASK);
    }
    tgt.putN(nFinal);

    assert (tgt.getN() / (2L * tgtK)) == newTgtBitPattern; // internal consistency check

    double srcMax = src.getMaxValue();
    srcMax = Double.isNaN(srcMax) ? Double.NEGATIVE_INFINITY : srcMax;
    double srcMin = src.getMinValue();
    srcMin = Double.isNaN(srcMin) ? Double.POSITIVE_INFINITY : srcMin;

    double tgtMax = tgt.getMaxValue();
    tgtMax = Double.isNaN(tgtMax) ? Double.NEGATIVE_INFINITY : tgtMax;
    double tgtMin = tgt.getMinValue();
    tgtMin = Double.isNaN(tgtMin) ? Double.POSITIVE_INFINITY : tgtMin;

    if (srcMax > tgtMax) { tgt.putMaxValue(srcMax); }
    if (srcMin < tgtMin) { tgt.putMinValue(srcMin); }
  }
1033285
public final void sample()
  {
    long count = _count.get();
    long lastCount = _lastAvgCount.getAndSet(count);
    long time = _time.get();
    long lastTime = _lastAvgTime.getAndSet(time);

    if (count == lastCount)
      _value = 0;
    else
      _value = _scale * (time - lastTime) / (double) (count - lastCount);
  }
774762
@Override
  public final void sample()
  {
    long count = _count.get();
    long lastCount = _lastCount.getAndSet(count);
    
    _value = count - lastCount;
  }
837902
protected Planar<GrayF32> preprocess(Planar<GrayF32> image) {
		// Shrink the image to input size
		if( image.width == imageSize && image.height == imageSize ) {
			this.imageRgb.setTo(image);
		} else if( image.width < imageSize || image.height < imageSize ) {
			throw new IllegalArgumentException("Image width or height is too small");
		} else {
			massage.massage(image,imageRgb);
		}
		return imageRgb;
	}
1373260
public static void down(GrayU16 input , int sampleWidth , GrayI16 output ) {
		if( sampleWidth == 2 ) {
			if(BoofConcurrency.USE_CONCURRENT ) {
				ImplAverageDownSample2_MT.down(input, output);
			} else {
				ImplAverageDownSample2.down(input, output);
			}
		} else {
			if(BoofConcurrency.USE_CONCURRENT ) {
				ImplAverageDownSampleN_MT.down(input, sampleWidth, output);
			} else {
				ImplAverageDownSampleN.down(input, sampleWidth, output);
			}
		}
	}
310470
@Override
    public InputType getOutputType(InputType... inputType) throws InvalidKerasConfigurationException {
        if (inputType.length > 1)
            throw new InvalidKerasConfigurationException(
                    "Keras Subsampling 2D layer accepts only one input (received " + inputType.length + ")");
        return this.getSubsampling2DLayer().getOutputType(-1, inputType[0]);
    }
16264
private void setDestPixel(int[] dstImage, int x, int y, int p)
    {
        dstImage[x + y * width * SCALE] = p;
    }
1074591
private BitMatrix sampleGrid(BitMatrix image,
                               ResultPoint topLeft,
                               ResultPoint topRight,
                               ResultPoint bottomRight,
                               ResultPoint bottomLeft) throws NotFoundException {

    GridSampler sampler = GridSampler.getInstance();
    int dimension = getDimension();

    float low = dimension / 2.0f - nbCenterLayers;
    float high = dimension / 2.0f + nbCenterLayers;

    return sampler.sampleGrid(image,
                              dimension,
                              dimension,
                              low, low,   // topleft
                              high, low,  // topright
                              high, high, // bottomright
                              low, high,  // bottomleft
                              topLeft.getX(), topLeft.getY(),
                              topRight.getX(), topRight.getY(),
                              bottomRight.getX(), bottomRight.getY(),
                              bottomLeft.getX(), bottomLeft.getY());
  }
857765
public static <T extends ImageGray<T>>
	void planarToBitmap(Planar<T> 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);
		
		if( input.getBandType() == GrayU8.class )
			ImplConvertBitmap.planarToArray_U8((Planar)input, storage,output.getConfig());
		else if( input.getBandType() == GrayF32.class )
			ImplConvertBitmap.planarToArray_F32((Planar)input, storage,output.getConfig());
		else
			throw new IllegalArgumentException("Unsupported BoofCV Type");
		output.copyPixelsFromBuffer(ByteBuffer.wrap(storage));
	}