Java 8 Kernel - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Kernel class.

This code example shows how to use the following methods:getHeight, getKernelData, getWidth, getXOrigin, getYOrigin
     * 
     * @throws NullPointerException if k is null. 
     */ 
    public KernelJAI(Kernel k) {
        // XXX - NullPointerException (inconsistent style) 
        this(k.getWidth(), k.getHeight(),
             k.getXOrigin(), k.getYOrigin(), k.getKernelData(null));
    } 
 
    /** Returns the width of the kernel. */ 
    public int getWidth() { 
	return width;
    } 
 
    /** Returns the height of the kernel. */ 
    public int getHeight() { 
	return height;
    } 
 
    /** Returns the X coordinate of the key kernel element. */ 
6
CodeRank
This code example shows how to use the following methods:getHeight, getWidth
     * @param height the height 
     * @param alpha include alpha channel 
     * @param edgeAction what to do at the edges 
     */ 
	public static void convolve(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction) {
		if (kernel.getHeight() == 1)
			convolveH(kernel, inPixels, outPixels, width, height, alpha, edgeAction);
		else if (kernel.getWidth() == 1)
			convolveV(kernel, inPixels, outPixels, width, height, alpha, edgeAction);
		else 
			convolveHV(kernel, inPixels, outPixels, width, height, alpha, edgeAction);
	} 
	 
	/** 
	 * Convolve with a 2D kernel. 
     * @param kernel the kernel 
     * @param inPixels the input pixels 
     * @param outPixels the output pixels 
     * @param width the width 
     * @param height the height 
6
CodeRank
This code example shows how to use the following methods:getHeight, getWidth
        convolve ( kernel, inPixels, outPixels, width, height, true, edgeAction );
    } 
 
    public static void convolve ( Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction )
    { 
        if ( kernel.getHeight () == 1 )
        { 
            convolveH ( kernel, inPixels, outPixels, width, height, alpha, edgeAction );
        } 
        else if ( kernel.getWidth () == 1 )
        { 
            convolveV ( kernel, inPixels, outPixels, width, height, alpha, edgeAction );
        } 
        else 
        { 
            convolveHV ( kernel, inPixels, outPixels, width, height, alpha, edgeAction );
        } 
    } 
 
    /** 
     * Convolve with a 2D kernel 
5
CodeRank
This code example shows how to use the following methods:
			data=toFloatArray(pc,Caster.toNativeArray(oData)); 
		} 
		else  
			throw new FunctionException(pc, "", 3, "data", "cannot cast data to a float array"); 
		 
		return new Kernel(Caster.toIntValue(width),Caster.toIntValue(height),data); 
	} 
 
	private static float[] toFloatArray(PageContext pc,Object oData) throws PageException { 
		float[] data=null; 
		// Object[] 
		if(oData instanceof Object[]) { 
			Object[] arr = ((Object[])oData); 
			data=new float[arr.length]; 
			for(int i=0;i<arr.length;i++){ 
				data[i]=Caster.toFloatValue(arr[i]); 
			} 
		} 
		// boolean[] 
		else if(oData instanceof boolean[]) { 
5
CodeRank
This code example shows how to use the following methods:
		return radius;
	} 
 
    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 );
5
CodeRank
This code example shows how to use the following methods:
        t.shear(-0.3, 0);
        vg.drawImage(image, t, this);
 
        float[] SHARPEN3x3 = new float[] { 0.f, -1.f, 0.f, -1.f, 5.0f, -1.f,
                0.f, -1.f, 0.f }; 
        Kernel kernel = new Kernel(3, 3, SHARPEN3x3);
        BufferedImageOp cop = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP,
                null); 
        vg.drawImage(image2, cop, 300, -80);
 
        vg.setTransform(transform);
    } 
 
    public static void main(String[] args) throws Exception {
        new TestImage2D(args).runTest();
    } 
} 
4
CodeRank
This code example shows how to use the following methods:
    } 
 
    private BufferedImageOp op;
 
    public OpCompatibleImageTest() { 
        final Kernel kernel = new Kernel(3, 3,
                new float[] { 
            1f/9f, 1f/9f, 1f/9f, 
            1f/9f, 1f/9f, 1f/9f, 
            1f/9f, 1f/9f, 1f/9f}); 
        op = new ConvolveOp(kernel);
    } 
 
    public void doTest(int type) {
        System.out.println("Test for type " + describeType(type));
 
        BufferedImage src = createTestImage(type);
 
        BufferedImage res = null;
 
4
CodeRank
This code example shows how to use the following methods:
  
        float[] transform = {0     , factor    , 0     , 
                             factor, 1-factor*4, factor, 
                             0     , factor    , 0    };
         
        Kernel kernel = new Kernel(3, 3, transform);
         
        return new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
         
    } 
     
    public static Color appendAlpha(Color c, double opacity) {
        return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) Math.round(opacity*255));
    } 
     
    /** 
     * Simplifies a paint to a colour.  If the paint is already a colour 
     * then simply cast.  If it is a gradient then return the second point. 
     * If unknown then return transparent.  
     * <p> 
4
CodeRank
This code example shows how to use the following methods:
 
        bg.setClip(new RoundRectangle2D.Float(inset + vHighlightInset, inset + vHighlightInset, vButtonHighlightWidth, vButtonHighlightHeight / 2, vButtonHighlightHeight / 3, vButtonHighlightHeight / 3));
       // bg.fillRoundRect(inset + vHighlightInset, inset + vHighlightInset, vButtonHighlightWidth, vButtonHighlightHeight, vHighlightArcSize, vHighlightArcSize); 
 
        // Blur the button 
        ConvolveOp vBlurOp = new ConvolveOp(new Kernel(3, 3, BLUR));
        BufferedImage vBlurredBase = vBlurOp.filter(vBuffer, null);
 
        // Draw our aqua button 
        g2.drawImage(vBlurredBase, 0, 0, null);
 
        // Draw the text (if any) 
        if (text != null) {
            g2.setColor(foregroundColor);
 
            Font vFont = g2.getFont().deriveFont((float)(((float)vButtonHeight) * .6));
            g2.setFont(vFont);
 
            FontMetrics vMetrics = g2.getFontMetrics();
            Rectangle2D vStringBounds = vMetrics.getStringBounds(text, g2);
3
CodeRank
This code example shows how to use the following methods:
 */ 
 
public class BlurFilter extends IndentFilter { 
    @Override 
    public BufferedImage apply(BufferedImage image) {
        Kernel kernel = new Kernel(3, 3,
                new float[]{ 
                        1f / 9f, 1f / 9f, 1f / 9f, 
                        1f / 9f, 1f / 9f, 1f / 9f, 
                        1f / 9f, 1f / 9f, 1f / 9f} 
        ); 
 
        BufferedImageOp blurOp = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
        return blurOp.filter(image, null);
    } 
} 
3
CodeRank
See Code Examples for Java 8 Kernel Methods: