当前位置: 首页>>代码示例>>Java>>正文


Java ConvolveOp类代码示例

本文整理汇总了Java中java.awt.image.ConvolveOp的典型用法代码示例。如果您正苦于以下问题:Java ConvolveOp类的具体用法?Java ConvolveOp怎么用?Java ConvolveOp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConvolveOp类属于java.awt.image包,在下文中一共展示了ConvolveOp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: HeapView

import java.awt.image.ConvolveOp; //导入依赖的package包/类
public HeapView() {
    // Configure structures needed for rendering drop shadow.
    int kw = KERNEL_SIZE, kh = KERNEL_SIZE;
    float blurFactor = BLUR_FACTOR;
    float[] kernelData = new float[kw * kh];
    for (int i = 0; i < kernelData.length; i++) {
        kernelData[i] = blurFactor;
    }
    blur = new ConvolveOp(new Kernel(kw, kh, kernelData));
    format = new MessageFormat("{0,choice,0#{0,number,0.0}|999<{0,number,0}}/{1,choice,0#{1,number,0.0}|999<{1,number,0}}MB");
    heapSizeText = "";
    // Enable mouse events. This is the equivalent to adding a mouse
    // listener.
    enableEvents(AWTEvent.MOUSE_EVENT_MASK);
    setToolTipText(NbBundle.getMessage(GarbageCollectAction.class, "CTL_GC"));
    updateUI();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:HeapView.java

示例2: apply

import java.awt.image.ConvolveOp; //导入依赖的package包/类
@Override
public final BufferedImage apply(BufferedImage img) {
	
	float[][] matrix = getMatrix();
	float[] data = getKernelData(matrix);
	if(normalize)
		normalize(data); 
	scale(data);
	if(isZero(data))
		return new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
	
	Kernel k = new Kernel(matrix[0].length, matrix.length, data);
	ConvolveOp op = new ConvolveOp(k, ConvolveOp.EDGE_NO_OP, null);
	
	BufferedImage img2 = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
	img2.getGraphics().drawImage(img, 0, 0, null);
	
	return op.filter(img2, null);
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:20,代码来源:ConvolutionFilter.java

示例3: enableConvolveOp

import java.awt.image.ConvolveOp; //导入依赖的package包/类
private static void enableConvolveOp(RenderQueue rq,
                                     SurfaceData srcData,
                                     ConvolveOp cop)
{
    // assert rq.lock.isHeldByCurrentThread();
    boolean edgeZero =
        cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL;
    Kernel kernel = cop.getKernel();
    int kernelWidth = kernel.getWidth();
    int kernelHeight = kernel.getHeight();
    int kernelSize = kernelWidth * kernelHeight;
    int sizeofFloat = 4;
    int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat);

    RenderBuffer buf = rq.getBuffer();
    rq.ensureCapacityAndAlignment(totalBytesRequired, 4);
    buf.putInt(ENABLE_CONVOLVE_OP);
    buf.putLong(srcData.getNativeOps());
    buf.putInt(edgeZero ? 1 : 0);
    buf.putInt(kernelWidth);
    buf.putInt(kernelHeight);
    buf.put(kernel.getKernelData(null));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:BufferedBufImgOps.java

示例4: blur

import java.awt.image.ConvolveOp; //导入依赖的package包/类
public static BufferedImage blur(BufferedImage src) {
    BufferedImage bufferedImage = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_BYTE_INDEXED);

    int s1 = 7;
    int s2 = 7;
    float level = .1f / 9f;

    float[] filter = new float[s1 * s2];

    for (int i = 0; i < s1 * s2; i++) {
        filter[i] = level;
    }

    Kernel kernel = new Kernel(s1, s2, filter);
    BufferedImageOp op = new ConvolveOp(kernel);
    bufferedImage = op.filter(src, null);

    return bufferedImage;
}
 
开发者ID:mhusam,项目名称:ChessBot,代码行数:20,代码来源:ChessBoardUtils.java

示例5: crashTest

import java.awt.image.ConvolveOp; //导入依赖的package包/类
private static void crashTest() {
    Raster src = createSrcRaster();
    WritableRaster dst = createDstRaster();
    ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP);
    try {
        op.filter(src, dst);
    } catch (ImagingOpException e) {
        /*
         * The test pair of source and destination rasters
         * may cause failure of the medialib convolution routine,
         * so this exception is expected.
         *
         * The JVM crash is the only manifestation of this
         * test failure.
         */
    }
    System.out.println("Test PASSED.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:EdgeNoOpCrash.java

示例6: effect_blur

import java.awt.image.ConvolveOp; //导入依赖的package包/类
/**
 * Blur the image
 * @param amount
 */
public void effect_blur(int amount) { // TODO
	int radius = amount;
	int size = radius * 2 + 1;
	float weight = 1.0f / (size * size);
	float[] data = new float[size * size];

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

	Kernel kernel = new Kernel(size, size, data);
	ConvolveOp op = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
	image = op.filter(image, null);
	
}
 
开发者ID:winspeednl,项目名称:LibZ,代码行数:20,代码来源:Sprite.java

示例7: getBlurredImg

import java.awt.image.ConvolveOp; //导入依赖的package包/类
public static Image getBlurredImg(BufferedImage img) {
    final int kernel_size = 15;
    float[] blurKernel = new float[kernel_size * kernel_size];
    final float blurPeakHeight = 0.35f;
    double[][] sigma = new double[2][2];
    sigma[0] = new double[]{1.2, 0.0};
    sigma[1] = new double[]{0.0, 1.2};

    double mid = (kernel_size / 2.0);
    float cent = (float) MultiNormalDist.density(new double[]{mid, mid}, sigma, new double[]{mid, mid});

    for (int i = 0; i < blurKernel.length; i++) {
        int x = i / kernel_size;
        int y = i % kernel_size;
        blurKernel[i] = blurPeakHeight * (float) MultiNormalDist.density(new double[]{mid, mid}, sigma, new double[]{x, y}) / cent;
    }

    ConvolveOp op = new ConvolveOp(new Kernel(kernel_size, kernel_size, blurKernel));

    return op.filter(img, null);

}
 
开发者ID:nolanlab,项目名称:vortex,代码行数:23,代码来源:GaussianBlur.java

示例8: toSVG

import java.awt.image.ConvolveOp; //导入依赖的package包/类
/**
 * @param op BufferedImageOp to be converted to SVG
 * @param filterRect Rectangle, in device space, that defines the area
 *        to which filtering applies. May be null, meaning that the
 *        area is undefined.
 * @return an SVGFilterDescriptor representing the SVG filter
 *         equivalent of the input BufferedImageOp
 */
public SVGFilterDescriptor toSVG(BufferedImageOp op,
                                 Rectangle filterRect){
    SVGFilterDescriptor filterDesc =
        svgCustomBufferedImageOp.toSVG(op, filterRect);

    if(filterDesc == null){
        if(op instanceof LookupOp)
            filterDesc = svgLookupOp.toSVG(op, filterRect);
        else if(op instanceof RescaleOp)
            filterDesc = svgRescaleOp.toSVG(op, filterRect);
        else if(op instanceof ConvolveOp)
            filterDesc = svgConvolveOp.toSVG(op, filterRect);
    }

    return filterDesc;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:25,代码来源:SVGBufferedImageOp.java

示例9: main

import java.awt.image.ConvolveOp; //导入依赖的package包/类
public static void main(final String[] _args) {
   String fileName = _args.length == 1 ? _args[0] : "Leo720p.wmv";

   float[] convMatrix3x3 = new float[] {
         0f,
         -10f,
         0f,
         -10f,
         41f,
         -10f,
         0f,
         -10f,
         0f
   };

   new JJMPEGPlayer("lab_6.alternate", fileName, convMatrix3x3){

      @Override protected void processFrame(Graphics2D _gc, float[] _convMatrix3x3, BufferedImage _in, BufferedImage _out) {
         java.awt.image.Kernel conv = new java.awt.image.Kernel(3, 3, _convMatrix3x3);
         ConvolveOp convOp = new ConvolveOp(conv, ConvolveOp.EDGE_NO_OP, null);
         convOp.filter(_in, _out);
      }
   };

}
 
开发者ID:Syncleus,项目名称:aparapi-examples,代码行数:26,代码来源:PureJavaSolution.java

示例10: blurImage

import java.awt.image.ConvolveOp; //导入依赖的package包/类
public static BufferedImage blurImage(BufferedImage image) 
{
	float ninth = 1.0f/9.0f;
	float[] blurKernel = {
			ninth, ninth, ninth,
			ninth, ninth, ninth,
			ninth, ninth, ninth
	};

	Map<RenderingHints.Key, Object> map = new HashMap<RenderingHints.Key, Object>();
	map.put(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
	map.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
	map.put(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
	RenderingHints hints = new RenderingHints(map);
	BufferedImageOp op = new ConvolveOp(new Kernel(3, 3, blurKernel), ConvolveOp.EDGE_NO_OP, hints);
	
	return op.filter(image, null);
}
 
开发者ID:oopcell,项目名称:AvoinApotti,代码行数:19,代码来源:Logic.java

示例11: lock

import java.awt.image.ConvolveOp; //导入依赖的package包/类
/**
 * @param time
 */
public void lock(final int time) {
    frame.getGlassPane().setVisible(false);
    screen = createScreenShot();
    frame.getGlassPane().setVisible(true);
    if (screen != null) {
        gray = ImageProvider.convertToGrayScale(screen);

        final float data[] = { 0.0625f, 0.125f, 0.0625f, 0.125f, 0.25f, 0.125f, 0.0625f, 0.125f, 0.0625f };
        final Kernel kernel = new Kernel(3, 3, data);
        final ConvolveOp convolve = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
        final BufferedImage dest = new BufferedImage(gray.getWidth(), gray.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
        gray = convolve.filter(gray, dest);
        frame.setGlassPane(this);

        frame.getGlassPane().setVisible(true);

        fadeIn(time);
    }

}
 
开发者ID:friedlwo,项目名称:AppWoksUtils,代码行数:24,代码来源:LockPanel.java

示例12: getBlurFilter

import java.awt.image.ConvolveOp; //导入依赖的package包/类
public static ConvolveOp getBlurFilter(int radius) {
    if (radius < 1) {
        throw new IllegalArgumentException("Radius must be >= 1");
    }
    
    int size = radius * 2 + 1;
    float weight = 1.0f / (size * size);
    float[] data = new float[size * size];
    
    for (int i = 0; i < data.length; i++) {
        data[i] = weight;
    }
    
    Kernel kernel = new Kernel(size, size, data);
    return new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
}
 
开发者ID:romainguy,项目名称:filthy-rich-clients,代码行数:17,代码来源:BoxBlurDemo.java

示例13: processImage

import java.awt.image.ConvolveOp; //导入依赖的package包/类
/**
 * Uses a blur filter on an image in an attempt to make it readable by the
 * QRCodeReader.
 * 
 * @param image
 *            the page in a BufferedImage object
 * @return another BufferedImage object with the filters applied to it
 */
private BufferedImage processImage(BufferedImage image) {

	// default: 3x3 filter for a 72 DPI image
	double DEFAULT_SIZE = 9.0;

	// calculate filtering matrix size based on the image resolution
	int dimension = (int) Math.sqrt(DEFAULT_SIZE
			/ (double) DEFAULT_RESOLUTION * RETAKE_RESOLUTION);
	int size = dimension * dimension;

	float[] matrix = new float[size];
	for (int i = 0; i < size; i++)
		matrix[i] = 1.0f / (float) size;

	BufferedImageOp op = new ConvolveOp(new Kernel(dimension, dimension,
			matrix), ConvolveOp.EDGE_NO_OP, null);
	return op.filter(image, null);

}
 
开发者ID:karoliina,项目名称:qr-code-reader,代码行数:28,代码来源:QRDecoder.java

示例14: getDropShadowImage

import java.awt.image.ConvolveOp; //导入依赖的package包/类
/**
 * Returns a drop shadow for the given rectangle specified by the given width and height.
 * @param gc the graphics configuration
 * @param w the rectangle width
 * @param h the rectangle height
 * @param sw the 
 * @param color the shadow color
 * @return BufferedImage
 */
public static final BufferedImage getDropShadowImage(GraphicsConfiguration gc, int w, int h, int sw, Color color) {
	// create a new image of the right size
	BufferedImage image = gc.createCompatibleImage(w + 2 * sw, h + 2 * sw, Transparency.TRANSLUCENT);
				
	Graphics2D ig2d = image.createGraphics();
	ig2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	ig2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
	
	// render the shadow rectangle
	ig2d.setColor(color);
	ig2d.fillRect(sw, sw, w, h);
	ig2d.dispose();
	
	// perform the linear blur
	ConvolveOp op = ImageUtilities.getLinearBlurOp(sw);
	return op.filter(image, null);
}
 
开发者ID:wnbittle,项目名称:praisenter,代码行数:27,代码来源:ImageUtilities.java

示例15: getConvolveOp

import java.awt.image.ConvolveOp; //导入依赖的package包/类
private ConvolveOp getConvolveOp(int blurRadius, double dpiFactor) {
	blurRadius = (int) (blurRadius * dpiFactor);
	final int blurRadius2 = blurRadius * blurRadius;
	final float blurRadius2F = blurRadius2;
	// final float weight = (float) (1.0 / blurRadius2F / dpiFactor);
	final float weight = (float) (1.0 / blurRadius2F);
	final float[] elements = new float[blurRadius2];
	for (int k = 0; k < blurRadius2; k++) {
		elements[k] = weight;
	}
	final Kernel myKernel = new Kernel(blurRadius, blurRadius, elements);

	// if EDGE_NO_OP is not selected, EDGE_ZERO_FILL is the default which
	// creates a black border
	return new ConvolveOp(myKernel, ConvolveOp.EDGE_NO_OP, null);
}
 
开发者ID:Banno,项目名称:sbt-plantuml-plugin,代码行数:17,代码来源:DriverShadowedG2d.java


注:本文中的java.awt.image.ConvolveOp类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。