GaussianFilter filter = new GaussianFilter(size); g2d.dispose(); imgBlur = filter.filter(imgBlur, null);
int height = src.getHeight(); ProgressTracker pt = createProgressTracker(width + height); dst = createCompatibleDestImage(src, null); getRGB(src, 0, 0, width, height, inPixels); convolveAndTranspose(kernel, inPixels, outPixels, width, height, alpha, alpha && premultiplyAlpha, false, CLAMP_EDGES, pt); convolveAndTranspose(kernel, outPixels, inPixels, height, width, alpha, false, alpha && premultiplyAlpha, CLAMP_EDGES, pt); setRGB(dst, 0, 0, width, height, inPixels); finishProgressTracker();
/** * Set the radius of the kernel, and hence the amount of blur. The bigger the radius, the longer this filter will take. * * @param radius the radius of the blur in pixels. * @min-value 0 * @max-value 100+ * @see #getRadius */ public void setRadius(float radius) { this.radius = radius; kernel = makeKernel(radius); }
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); //Find the bitmap's width height int width = AndroidUtils.getBitmapOfWidth(getResources(), R.drawable.ic_launcher); int height = AndroidUtils.getBitmapOfHeight(getResources(), R.drawable.ic_launcher); //Create a filter object. GaussianFilter filter = new GaussianFilter(); //set???? function to specify the various settings. filter.setRadius(8.5f); //Change int Array into a bitmap int[] src = AndroidUtils.bitmapToIntArray(bitmap); //Applies a filter. filter.filter(src, width, height); //Change the Bitmap int Array (Supports only ARGB_8888) Bitmap dstBitmap = Bitmap.createBitmap(src, width, height, Config.ARGB_8888);
@Override public BufferedImage doTransform(BufferedImage src, BufferedImage dest) { if (radius.getValue() == 0) { return src; } if (filter == null) { filter = new GaussianFilter(NAME); } filter.setRadius(radius.getValueAsFloat()); filter.setPremultiplyAlpha(false); dest = filter.filter(src, dest); if (hpSharpening.isChecked()) { dest = ImageUtils.getHighPassSharpenedImage(src, dest); } return dest; }
setRadius(radius); kernel = makeKernel(radius); src.getRGB( 0, 0, width, height, inPixels, 0, width ); convolveAndTranspose(kernel, inPixels, outPixels, width, height, alpha, CLAMP_EDGES); convolveAndTranspose(kernel, outPixels, inPixels, height, width, alpha, CLAMP_EDGES);
Kernel kernel = GaussianFilter.makeKernel( bumpSoftness ); GaussianFilter.convolveAndTranspose( kernel, bumpPixels, tmpPixels, bumpWidth, bumpHeight, true, false, false, GaussianFilter.WRAP_EDGES ); GaussianFilter.convolveAndTranspose( kernel, tmpPixels, softPixels, bumpHeight, bumpWidth, true, false, false, GaussianFilter.WRAP_EDGES ); bump = new ImageFunction2D(softPixels, bumpWidth, bumpHeight, ImageFunction2D.CLAMP, bumpSource == BUMPS_FROM_IMAGE_ALPHA); final Function2D bbump = bump;
GaussianFilter gf = new GaussianFilter(blur, filterName); gf.setProgressTracker(pt); mask = gf.filter(mask, null);
public BufferedImage filter( BufferedImage src, BufferedImage dst ) { int width = src.getWidth(); int height = src.getHeight(); if ( dst == null ) dst = createCompatibleDestImage( src, null ); int[] inPixels = new int[width*height]; int[] outPixels = new int[width*height]; src.getRGB( 0, 0, width, height, inPixels, 0, width ); if ( radius > 0 ) { convolveAndTranspose(kernel, inPixels, outPixels, width, height, alpha, alpha && premultiplyAlpha, false, CLAMP_EDGES); convolveAndTranspose(kernel, outPixels, inPixels, height, width, alpha, false, alpha && premultiplyAlpha, CLAMP_EDGES); } dst.setRGB( 0, 0, width, height, inPixels, 0, width ); return dst; }
private void drawContainer(Graphics g, int vx, int vy, int vw, int vh) { if (vw <= 0 || vh <= 0 || vx < cachedBackground.getMinX() || vx + vw > cachedBackground.getMinX() + cachedBackground.getWidth() || vy < cachedBackground.getMinY() || vy + vh > cachedBackground.getMinY() + cachedBackground.getHeight()) { return; } BufferedImage result = new BufferedImage(vw, vh, TYPE_INT_ARGB); filter20.filter(cachedBackground.getSubimage(vx, vy, vw, vh), result); g.drawImage(result, vx, vy, null); }
/** * Construct a Gaussian filter. * @param radius blur radius in pixels */ public GaussianFilter(float radius) { setRadius(radius); }
GaussianFilter filter = new GaussianFilter(size); GaussianFilter filter = new GaussianFilter(size);
/** * Blur and transpose a block of ARGB pixels. * * @param kernel the blur kernel * @param inPixels the input pixels * @param outPixels the output pixels * @param width the width of the pixel array * @param height the height of the pixel array * @param alpha whether to blur the alpha channel * @param edgeAction what to do at the edges */ public static void convolveAndTranspose(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, boolean premultiply, boolean unpremultiply, int edgeAction, ProgressTracker pt) { float[] matrix = kernel.getKernelData(null); int cols = kernel.getWidth(); int cols2 = cols / 2; Future<?>[] resultLines = new Future[height]; for (int y = 0; y < height; y++) { int finalY = y; Runnable lineTask = () -> convolveAndTransposeLine(inPixels, outPixels, width, height, alpha, premultiply, unpremultiply, edgeAction, matrix, cols2, finalY); resultLines[y] = ThreadPool.submit(lineTask); } ThreadPool.waitToFinish(resultLines, pt); }
bumpPixels = if2d.getPixels(); Kernel kernel = GaussianFilter.makeKernel( bumpSoftness ); int [] tmpPixels = new int[bumpWidth * bumpHeight]; int [] softPixels = new int[bumpWidth * bumpHeight]; GaussianFilter.convolveAndTranspose( kernel, bumpPixels, tmpPixels, bumpWidth, bumpHeight, true, false, false, ConvolveFilter.CLAMP_EDGES); GaussianFilter.convolveAndTranspose( kernel, tmpPixels, softPixels, bumpHeight, bumpWidth, true, false, false, ConvolveFilter.CLAMP_EDGES); bump = new ImageFunction2D(softPixels, bumpWidth, bumpHeight, ImageFunction2D.CLAMP, bumpSource == BUMPS_FROM_IMAGE_ALPHA); } else
filter10.filter( cachedBackground.getSubimage(commandsX, commandsY, boxWidth, boxHeight), result); g.drawImage(result, commandsX, commandsY, null);
/** * Construct a Gaussian filter. * * @param radius blur radius in pixels */ public GaussianFilter(float radius, String filterName) { super(filterName); setRadius(radius); }
GaussianFilter filter = new GaussianFilter(size); g2d.dispose(); imgBlur = filter.filter(imgBlur, null);
/** * Set the radius of the kernel, and hence the amount of blur. The bigger the radius, the longer this filter will take. * @param radius the radius of the blur in pixels. * @min-value 0 * @max-value 100+ * @see #getRadius */ public void setRadius(float radius) { this.radius = radius; kernel = makeKernel(radius); }
GaussianFilter gf = new GaussianFilter(10); imgBG = gf.filter(imgBG, null);
public BufferedImage filter( BufferedImage src, BufferedImage dst ) { int width = src.getWidth(); int height = src.getHeight(); if ( dst == null ) dst = createCompatibleDestImage( src, null ); int[] inPixels = new int[width*height]; int[] outPixels = new int[width*height]; getRGB( src, 0, 0, width, height, inPixels ); Kernel kernel = GaussianFilter.makeKernel(hRadius); thresholdBlur( kernel, inPixels, outPixels, width, height, true ); thresholdBlur( kernel, outPixels, inPixels, height, width, true ); setRGB( dst, 0, 0, width, height, inPixels ); return dst; }