當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。