Clipps and scales the input iamge as neccisary
@param input Input image.  Typically larger than output
@param output Output image
344817
public void massage( T input , T output ) {
		if( clip ) {
			T inputAdjusted = clipInput(input, output);

			// configure a simple change in scale for both axises
			transform.a11 = input.width / (float) output.width;
			transform.a22 = input.height / (float) output.height;
			// this change is automatically reflected in the distortion class.  It is configured to cache nothing

			distort.apply(inputAdjusted, output);
		} else {
			// scale each axis independently.  It will have the whole image but it will be distorted
			transform.a11 = input.width / (float) output.width;
			transform.a22 = input.height / (float) output.height;

			distort.apply(input, output);
		}

	}
582555
public static void scale(Image srcImg, OutputStream out, float scale) throws IORuntimeException {
		scale(srcImg, getImageOutputStream(out), scale);
	}
576425
public void process(Planar<T> input, Planar<T> output) {

		int N = input.getNumBands();
		for( int i = 0; i < N; i++ ) {
			this.output[i] = FactoryGImageGray.wrap(output.getBand(i),this.output[i]);
			interp[i].setImage(input.getBand(i));
		}

		int indexMap = 0;
		for( int i = 0; i < output.height; i++ ) {
			int indexOut = output.startIndex + i*output.stride;
			for( int j = 0; j < output.width; j++ , indexOut++,indexMap++ ) {
				Point2D_F32 p = mapPixels[indexMap];
				if( p != null ) {
					for( int k = 0; k < N; k++ ) {
						this.output[k].set(indexOut, interp[k].get( p.x, p.y));
					}
				}
			}
		}
	}
1027283
public static void copy(InputStream input, OutputStream output) throws IOException {
		byte[] buf = new byte[BUFFER_SIZE];
		int num = 0;

		while ((num = input.read(buf, 0, buf.length)) != -1) {
			output.write(buf, 0, num);
		}
	}
171060
public static <T extends ImageGray<T>>
	void scaleImageUp(T input , T output , int scale, InterpolatePixelS<T> interp ) {
		if( scale <= 1 )
			throw new IllegalArgumentException("Scale must be >= 2");
		if( input instanceof GrayF32) {
			ImplPyramidOps.scaleImageUp((GrayF32)input,(GrayF32)output,scale,(InterpolatePixelS)interp);
		} else if( input instanceof GrayU8) {
			ImplPyramidOps.scaleImageUp((GrayU8)input,(GrayU8)output,scale,(InterpolatePixelS)interp);
		} else {
			throw new IllegalArgumentException("Image type not yet supported");
		}
	}
3694
public static void minimum(Planar<GrayF64> input, GrayF64 output) {
		output.reshape(input.width,input.height);
		if (BoofConcurrency.USE_CONCURRENT) {
			ImplImageBandMath_MT.minimum(input, output, 0, input.getNumBands() - 1);
		} else {
			ImplImageBandMath.minimum(input, output, 0, input.getNumBands() - 1);
		}
	}
95462
public static <T extends ImageGray<T>> void maximum(Planar<T> input, T output) {
		maximum(input, output, 0, input.getNumBands() - 1);
	}
1340105
protected void imageToOutput( double x , double y , Point2D_F64 pt ) {
		pt.x = x/scale - tranX/scale;
		pt.y = y/scale - tranY/scale;
	}
94942
public static void scale(InputStream srcStream, OutputStream destStream, int width, int height, Color fixedColor) throws IORuntimeException {
		scale(read(srcStream), getImageOutputStream(destStream), width, height, fixedColor);
	}
994690
private void updateScaling() {

        List<I_CmsTransform> transforms = new ArrayList<>();
        CmsCroppingParamBean crop = m_croppingProvider.get();
        CmsImageInfoBean info = m_imageInfoProvider.get();

        double wv = m_image.getElement().getParentElement().getOffsetWidth();
        double hv = m_image.getElement().getParentElement().getOffsetHeight();
        if (crop == null) {
            transforms.add(
                new CmsBoxFit(CmsBoxFit.Mode.scaleOnlyIfNecessary, wv, hv, info.getWidth(), info.getHeight()));
        } else {
            int wt, ht;
            wt = crop.getTargetWidth() >= 0 ? crop.getTargetWidth() : info.getWidth();
            ht = crop.getTargetHeight() >= 0 ? crop.getTargetHeight() : info.getHeight();
            transforms.add(new CmsBoxFit(CmsBoxFit.Mode.scaleOnlyIfNecessary, wv, hv, wt, ht));
            if (crop.isCropped()) {
                transforms.add(
                    new CmsBoxFit(CmsBoxFit.Mode.scaleAlways, wt, ht, crop.getCropWidth(), crop.getCropHeight()));
                transforms.add(new CmsTranslate(crop.getCropX(), crop.getCropY()));
            } else {
                transforms.add(
                    new CmsBoxFit(CmsBoxFit.Mode.scaleAlways, wt, ht, crop.getOrgWidth(), crop.getOrgHeight()));
            }
        }
        CmsCompositeTransform chain = new CmsCompositeTransform(transforms);
        m_coordinateTransform = chain;
        if ((crop == null) || !crop.isCropped()) {
            m_region = transformRegionBack(
                m_coordinateTransform,
                CmsRectangle.fromLeftTopWidthHeight(0, 0, info.getWidth(), info.getHeight()));
        } else {
            m_region = transformRegionBack(
                m_coordinateTransform,
                CmsRectangle.fromLeftTopWidthHeight(
                    crop.getCropX(),
                    crop.getCropY(),
                    crop.getCropWidth(),
                    crop.getCropHeight()));
        }
    }
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");
	}
951237
public static <OUTPUT, INPUT extends Comparable<INPUT>> List<OUTPUT> executeLargeInputs(Collection<INPUT> input, Function<List<INPUT>, List<OUTPUT>> function,
    IntFunction<Integer> partitionSizeManipulations) {
    return executeLargeInputs(input, function, size -> size == 0 ? Collections.emptyList() : new ArrayList<>(size), partitionSizeManipulations);
  }
404140
public static byte[] scaleImage(byte[] imageBytes, String outputFormat,
                                    Integer targetSize) throws Exception {

        InputStream is = null;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] imageInBytes = null;
        BufferedImage image = null;
        BufferedImage resizedImage = null;

        try {
            is = new ByteArrayInputStream(imageBytes);
            image = ImageIO.read(is);
            resizedImage = Scalr.resize(image, targetSize);
            ImageIO.write(resizedImage, outputFormat, baos);
            imageInBytes = baos.toByteArray();
        } catch (Exception e) {
            throw new Exception("Error on resizing an image: " + e.getMessage());
        } finally {
            IOUtils.closeQuietly(is);
            IOUtils.closeQuietly(baos);
            if (image != null) {
                image.flush();
            }
            if (resizedImage != null) {
                resizedImage.flush();
            }
        }
        return imageInBytes;
    }
284759
public static void down(ImageGray input , int sampleWidth , ImageGray output ) {
		if( input instanceof GrayU8) {
			down((GrayU8) input, sampleWidth, (GrayI8) output);
		} else if( input instanceof GrayS8) {
			down((GrayS8) input, sampleWidth, (GrayI8) output);
		} else if( input instanceof GrayU16) {
			down((GrayU16) input, sampleWidth, (GrayI16) output);
		} else if( input instanceof GrayS16) {
			down((GrayS16) input, sampleWidth, (GrayI16) output);
		} else if( input instanceof GrayS32) {
			down((GrayS32) input, sampleWidth, (GrayS32) output);
		} else if( input instanceof GrayF32) {
			down((GrayF32) input, sampleWidth, (GrayF32) output);
		} else if( input instanceof GrayF64) {
			down((GrayF64) input, sampleWidth, (GrayF64) output);
		} else {
			throw new IllegalArgumentException("Unknown image type");
		}
	}
1138156
public void process(T input , GrayU8 output ) {
		output.reshape(input.width,input.height);

		int requestedBlockWidth = this.requestedBlockWidth.computeI(Math.min(input.width,input.height));

		selectBlockSize(input.width,input.height,requestedBlockWidth);

		stats.reshape(input.width/blockWidth,input.height/blockHeight);


		int innerWidth = input.width%blockWidth == 0 ?
				input.width : input.width-blockWidth-input.width%blockWidth;
		int innerHeight = input.height%blockHeight == 0 ?
				input.height : input.height-blockHeight-input.height%blockHeight;

		computeStatistics(input, innerWidth, innerHeight);
		applyThreshold(input,output);
	}
725903
public static void skip(long size, InputStream input) throws IOException {
        while (size > 0) {
            size -= input.skip(size);
        }
    }
278421
public static <T extends ImageGray<T>> void median(Planar<T> input, T output) {
		median(input, output, 0, input.getNumBands() - 1);
	}