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


Java Kernel类代码示例

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


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

示例1: HeapView

import java.awt.image.Kernel; //导入依赖的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.Kernel; //导入依赖的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.Kernel; //导入依赖的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.Kernel; //导入依赖的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: effect_blur

import java.awt.image.Kernel; //导入依赖的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

示例6: getBlurredImg

import java.awt.image.Kernel; //导入依赖的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

示例7: makeKernel

import java.awt.image.Kernel; //导入依赖的package包/类
/**
 * Make a Gaussian blur kernel.
 */
public static Kernel makeKernel(float radius) {
	int r = (int)Math.ceil(radius);
	int rows = r*2+1;
	float[] matrix = new float[rows];
	float sigma = radius/3;
	float sigma22 = 2*sigma*sigma;
	float sigmaPi2 = 2*ImageMath.PI*sigma;
	float sqrtSigmaPi2 = (float)Math.sqrt(sigmaPi2);
	float radius2 = radius*radius;
	float total = 0;
	int index = 0;
	for (int row = -r; row <= r; row++) {
		float distance = row*row;
		if (distance > radius2)
			matrix[index] = 0;
		else
			matrix[index] = (float)Math.exp(-(distance)/sigma22) / sqrtSigmaPi2;
		total += matrix[index];
		index++;
	}
	for (int i = 0; i < rows; i++)
		matrix[i] /= total;

	return new Kernel(rows, 1, matrix);
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:29,代码来源:GaussianFilter.java

示例8: filter

import java.awt.image.Kernel; //导入依赖的package包/类
@Override
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;
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:21,代码来源:SmartBlurFilter.java

示例9: getInts

import java.awt.image.Kernel; //导入依赖的package包/类
@Override
public int[] getInts(int xCoord, int zCoord, int sizeX, int sizeZ) {
	int margin = 10;
	
	xCoord -= margin;
	zCoord -= margin;
	sizeX += 2*margin;
	sizeZ += 2*margin;

	int[] inInts = this.parent.getInts(xCoord, zCoord, sizeX, sizeZ);
	int[] outInts = IntCache.getIntCache(inInts.length);
	
	Kernel kernel = makeKernel(radius);
	
	for (int i = 0; i < iterations; i++) {
		gaussBlurGrayScale(kernel, inInts, outInts, sizeX, sizeZ);
		gaussBlurGrayScale(kernel, outInts, inInts, sizeZ, sizeX);
	}
	
	return cutMargins(inInts, sizeX, sizeZ, margin);
}
 
开发者ID:tyronx,项目名称:vintagetg,代码行数:22,代码来源:GenLayerBlurAll.java

示例10: convolve

import java.awt.image.Kernel; //导入依赖的package包/类
/**
 * Convolve a block of pixels.
 * @param kernel the kernel
 * @param inPixels the input pixels
 * @param outPixels the output pixels
 * @param width the width
 * @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);
	}
}
 
开发者ID:andy-goryachev,项目名称:PasswordSafe,代码行数:26,代码来源:ConvolveFilter.java

示例11: blurImage

import java.awt.image.Kernel; //导入依赖的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

示例12: makeKernel

import java.awt.image.Kernel; //导入依赖的package包/类
/**
 * Make a Gaussian blur kernel.
    * @param radius the blur radius
    * @return the kernel
 */
public static Kernel makeKernel(float radius) {
	int r = (int)Math.ceil(radius);
	int rows = r*2+1;
	float[] matrix = new float[rows];
	float sigma = radius/3;
	float sigma22 = 2*sigma*sigma;
	float sigmaPi2 = 2*ImageMath.PI*sigma;
	float sqrtSigmaPi2 = (float)Math.sqrt(sigmaPi2);
	float radius2 = radius*radius;
	float total = 0;
	int index = 0;
	for (int row = -r; row <= r; row++) {
		float distance = row*row;
		if (distance > radius2)
			matrix[index] = 0;
		else
			matrix[index] = (float)Math.exp(-(distance)/sigma22) / sqrtSigmaPi2;
		total += matrix[index];
		index++;
	}
	for (int i = 0; i < rows; i++)
		matrix[i] /= total;

	return new Kernel(rows, 1, matrix);
}
 
开发者ID:lucee,项目名称:Lucee,代码行数:31,代码来源:GaussianFilter.java

示例13: filter

import java.awt.image.Kernel; //导入依赖的package包/类
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;
  }
 
开发者ID:lucee,项目名称:Lucee4,代码行数:19,代码来源:SmartBlurFilter.java

示例14: call

import java.awt.image.Kernel; //导入依赖的package包/类
public static Object call(PageContext pc, double width, double height, Object oData) throws PageException {
	
	float[] data=null;
	if(oData instanceof float[])
		data=(float[]) oData;
	else if(Decision.isNativeArray(oData)) {
		data=toFloatArray(pc,oData);
	}
	else if(Decision.isArray(oData)) {
		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);
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:17,代码来源:ImageFilterKernel.java

示例15: filter

import java.awt.image.Kernel; //导入依赖的package包/类
@Override
  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;
  }
 
开发者ID:WebcamStudio,项目名称:webcamstudio,代码行数:21,代码来源:SmartBlurFilter.java


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