Creates a Gaussian filter for the specified image type.

@param type Image type.
@param radius Size of the filter.
@return mean image filter.
325333
public static <T extends ImageBase<T>> BlurStorageFilter<T> gaussian(ImageType<T> type , double sigma , int radius ) {
		return new BlurStorageFilter<>("gaussian", type, sigma, radius);
	}
1018775
public void setArcByCenter (float x, float y, float radius,
                                float start, float extent, int type) {
        setArc(x - radius, y - radius, radius * 2f, radius * 2f, start, extent, type);
    }
732067
public static int[] imageOffsets(double radius, int imgWidth) {


		double PI2 = Math.PI * 2.0;

		double circumference = PI2 * radius;
		int num = (int) Math.ceil(circumference);
		num = num - num % 4;

		double angleStep = PI2 / num;


		int temp[] = new int[(int) Math.ceil(circumference)];
		int i = 0;

		int prev = 0;

		for (double ang = 0; ang < PI2; ang += angleStep) {
			int x = (int) Math.round(Math.cos(ang) * radius);
			int y = (int) Math.round(Math.sin(ang) * radius);

			int pixel = y * imgWidth + x;

			if (pixel != prev) {
//                System.out.println("i = "+i+"  x = "+x+"  y = "+y);
				temp[i++] = pixel;
			}
			prev = pixel;
		}

		if (i == temp.length)
			return temp;
		else {
			int ret[] = new int[i];
			System.arraycopy(temp, 0, ret, 0, i);

			return ret;
		}
	}
1024116
public TrendChart doGraph(@QueryParameter String type) throws IOException {
        return createTrendChart(TimeScale.parse(type));
    }
330274
public static <T extends ImageBase<T>>
	BackgroundStationaryGaussian<T> stationaryGaussian(@Nonnull ConfigBackgroundGaussian config , ImageType<T> imageType ) {

		config.checkValidity();

		BackgroundStationaryGaussian<T> ret;

		switch( imageType.getFamily() ) {
			case GRAY:
				ret = new BackgroundStationaryGaussian_SB(config.learnRate,config.threshold,imageType.getImageClass());
				break;

			case PLANAR:
				ret =  new BackgroundStationaryGaussian_PL(config.learnRate,config.threshold,imageType);
				break;

			case INTERLEAVED:
				ret =  new BackgroundStationaryGaussian_IL(config.learnRate,config.threshold,imageType);
				break;

			default:
				throw new IllegalArgumentException("Unknown image type");
		}

		ret.setInitialVariance(config.initialVariance);
		ret.setMinimumDifference(config.minimumDifference);
		ret.setUnknownValue(config.unknownValue);

		return ret;
	}
41196
public BufferedImage getBufferedImage(int width, int height, int type) {
        int wDif,
                hDif,
                fWidth = 0,
                fHeight = 0;

        double imgWidth,
                imgHeight;

        double factor;
        imgWidth = image.getWidth();
        imgHeight = image.getHeight();


        switch (type) {
            case PROPORTIONAL:
                wDif = (int) imgWidth - width;
                hDif = (int) imgHeight - height;
                if (wDif > hDif) {
                    factor = width / imgWidth;
                } else {
                    factor = height / imgHeight;
                }
                fWidth = (int) Math.floor(imgWidth * factor);
                fHeight = (int) Math.floor(imgHeight * factor);
                break;
        }
        return getBufferedImage(fWidth, fHeight);
    }
288699
public static <T> T boxAllAs(Object src, Class<T> type) {
        return (T) boxAll(type, src, 0, -1);
    }
130733
@Override
    public BufferedImage filter(BufferedImage src, BufferedImage dest) {
        if (dest == null) {
            dest = createCompatibleDestImage(src, null);
        }

        BufferedImage image = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), getRenderingHints()).filter(src, dest);

        Graphics2D g2d = dest.createGraphics();
        try {
            g2d.drawImage(image, 0, 0, null);
        }
        finally {
            g2d.dispose();
        }

        // Blur
        image = ImageUtil.blur(image, 2.5f);

        Graphics2D g = dest.createGraphics();
        try {
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            g.drawImage(image, 0, 0, null);

            // Rotate it slightly for a more analogue feeling
            double angle = -.0055;
            g.rotate(angle);

            // Vignette/border
            g.setComposite(AlphaComposite.SrcOver.derive(.35f));
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    Math.max(image.getWidth(), image.getHeight()) / 1.65f,
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    new float[] {0, .85f, 1f},
                    new Color[] {new Color(0x0, true), new Color(0x0, true), Color.BLACK},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(0, 0, image.getWidth(), image.getHeight());

        }
        finally {
            g.dispose();
        }

        // Round corners
        BufferedImage foo = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = foo.createGraphics();
        try {
            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            graphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            graphics.setColor(Color.WHITE);
            double angle = (random.nextDouble() * .01) - .005;
            graphics.rotate(angle);
            graphics.fillRoundRect(4, 4, image.getWidth() - 8, image.getHeight() - 8, 20, 20);
        }
        finally {
            graphics.dispose();
        }

        // Noise
        NoiseFilter noise = new NoiseFilter();
        noise.setAmount(20);
        noise.setDensity(1);
        noise.setMonochrome(true);
        foo = noise.filter(foo, foo);

        foo = ImageUtil.blur(foo, 4.5f);

        // Compose image into rounded corners
        graphics = foo.createGraphics();
        try {
            graphics.setComposite(AlphaComposite.SrcIn);
            graphics.drawImage(dest, 0, 0, null);
        }
        finally {
            graphics.dispose();
        }

        float[] scales = new float[] {1, 1, 1, 1};
        float[] offsets = new float[] {80, 40, 0, 0};
        foo = new RescaleOp(scales, offsets, getRenderingHints()).filter(foo, foo);

        // Draw it all back to dest
        g = dest.createGraphics();
        try {
            g.setComposite(AlphaComposite.SrcOver);
            g.setColor(Color.WHITE);
            g.fillRect(0, 0, image.getWidth(), image.getHeight());
            g.drawImage(foo, 0, 0, null);
        }
        finally {
            g.dispose();
        }

        return dest;
    }
151805
public static <T> FnArrayOf<T> of(final Type<T> type) {
        return new FnArrayOf<T>(type);
    }
654999
public static <T extends ImageBase<T>> InterpolatePixelMB<T>
	createPixelMB(double min, double max, InterpolationType type, BorderType borderType, ImageType<T> imageType )
	{
		switch (imageType.getFamily()) {

			case PLANAR:
				return (InterpolatePixelMB<T>) createPixelPL((InterpolatePixelS)createPixelS(min, max, type, borderType, imageType.getDataType()));

			case GRAY:{
				InterpolatePixelS interpS = createPixelS(min,max,type,borderType,imageType.getImageClass());
				return new InterpolatePixel_S_to_MB(interpS);
			}

			case INTERLEAVED:
				switch( type ) {
					case NEAREST_NEIGHBOR:
						return nearestNeighborPixelMB((ImageType) imageType, borderType);

					case BILINEAR:
						return bilinearPixelMB((ImageType)imageType,borderType);

					default:
						throw new IllegalArgumentException("Interpolate type not yet support for ImageInterleaved");
				}

			default:
				throw new IllegalArgumentException("Add type: "+type);
		}
	}
545946
private static function getImaginaryPartsFromRadiusAndSin(RationalType $radius, RationalType $sin)
    {
        return array(
            TypeFactory::create('int', $radius->numerator()->get() * $sin->numerator()->get()),
            TypeFactory::create('int', $radius->denominator()->get() * $sin->denominator()->get())
        ) ;
    }
533641
protected static float[] createGaussianKernel(int radius) {
        if (radius < 1) {
            throw new IllegalArgumentException("Radius must be >= 1");
        }

        float[] data = new float[radius * 2 + 1];

        float sigma          = radius / 3.0f;
        float twoSigmaSquare = 2.0f * sigma * sigma;
        float sigmaRoot      = (float) Math.sqrt(twoSigmaSquare * Math.PI);
        float total          = 0.0f;

        for (int i = -radius; i <= radius; i++) {
            float distance = i * i;
            int   index    = i + radius;

            data[index] =  (float) Math.exp(-distance / twoSigmaSquare) / sigmaRoot;
            total       += data[index];
        }

        for (int i = 0; i < data.length; i++) {
            data[i] /= total;
        }

        return data;
    }
868652
public static <T extends ImageGray<T>>
	DenseOpticalFlow<T> region( @Nullable ConfigOpticalFlowBlockPyramid config , Class<T> imageType )
	{
		if( config == null )
			config = new ConfigOpticalFlowBlockPyramid();

		DenseOpticalFlowBlockPyramid<T> alg;
		if( imageType == GrayU8.class )
			alg = (DenseOpticalFlowBlockPyramid)new DenseOpticalFlowBlockPyramid.U8(
					config.searchRadius,config.regionRadius,config.maxPerPixelError);
		else if( imageType == GrayF32.class )
			alg = (DenseOpticalFlowBlockPyramid)new DenseOpticalFlowBlockPyramid.F32(
					config.searchRadius,config.regionRadius,config.maxPerPixelError);
		else
			throw new IllegalArgumentException("Unsupported image type "+imageType);

		return new FlowBlock_to_DenseOpticalFlow<>(alg, config.pyramidScale, config.maxPyramidLayers, imageType);
	}
1348228
public static <T extends GrayF<T>, W extends ImageInterleaved>
	DiscreteFourierTransform<T,W> createTransform( ImageDataType type ) {
		switch( type ) {
			case F32: return (DiscreteFourierTransform)createTransformF32();
			case F64: return (DiscreteFourierTransform)createTransformF64();
		}
		throw new IllegalArgumentException("Unsupported image type "+type);
	}
2208
public T createImage( int width , int height ) {
		switch( family ) {
			case GRAY:
				return (T)GeneralizedImageOps.createSingleBand(getImageClass(),width,height);

			case INTERLEAVED:
				return (T)GeneralizedImageOps.createInterleaved(getImageClass(), width, height, numBands);

			case PLANAR:
				return (T)new Planar(getImageClass(),width,height,numBands);

			default:
				throw new IllegalArgumentException("Type not yet supported");
		}
	}
267127
def standardDeviation2d(img, ksize=5, blurred=None):
    '''
    
    '''
    if ksize not in (list, tuple):
        ksize = (ksize,ksize)

    if blurred is None:
        blurred = gaussian_filter(img, ksize)
    else:
        assert blurred.shape == img.shape
    
    std = np.empty_like(img)
    
    _calc(img, ksize[0], ksize[1], blurred, std)
    
    return std
932233
public Object lookup(String type, String url)
        throws IOException
    {
        return new HessianRemote(type, url);
    }