java.awt.image

Class Kernel

Implemented Interfaces:
Cloneable

public class Kernel
extends Object
implements Cloneable

The Kernel class defines a matrix that describes how a specified pixel and its surrounding pixels affect the value computed for the pixel's position in the output image of a filtering operation. The X origin and Y origin indicate the kernel matrix element that corresponds to the pixel position for which an output value is being computed.
See Also:
ConvolveOp

Constructor Summary

Kernel(int width, int height, data[] )
Constructs a Kernel object from an array of floats.

Method Summary

Object
clone()
Clones this object.
int
getHeight()
Returns the height of this Kernel.
float[]
getKernelData(float[] data)
Returns the kernel data in row major order.
int
getWidth()
Returns the width of this Kernel.
int
getXOrigin()
Returns the X origin of this Kernel.
int
getYOrigin()
Returns the Y origin of this Kernel.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Kernel

public Kernel(int width,
              int height,
              data[] )
Constructs a Kernel object from an array of floats. The first width*height elements of the data array are copied. If the length of the data array is less than width*height, an IllegalArgumentException is thrown. The X origin is (width-1)/2 and the Y origin is (height-1)/2.
Parameters:
width - width of the kernel
height - height of the kernel
Throws:
IllegalArgumentException - if the length of data is less than the product of width and height
Usages and Demos :

View More Examples of Kernel(int width,int height,data[] )
   1:   };
   2:   private static final ConvolveOp OP = new ConvolveOp(new Kernel(3,3, ELEMENTS), ConvolveOp.EDGE_NO_OP, null);
   3: 
   4: 
   5:   public void restore(ESISNode n, Map<String,Object> attr, Layer layer) {

View Full Code Here
   1:   };
   2:   private static final ConvolveOp OP = new ConvolveOp(new Kernel(3,3, ELEMENTS), ConvolveOp.EDGE_NO_OP, null);
   3: 
   4: 
   5:   public void restore(ESISNode n, Map<String,Object> attr, Layer layer) {

View Full Code Here
   1:             0.10f, 0.10f, 0.10f };
   2:         ConvolveOp op = new ConvolveOp(new Kernel(3,3, my_kernel));
   3:         BufferedImage buf = new BufferedImage(getWidth(),getHeight(),
   4:             BufferedImage.TYPE_INT_RGB);
   5:         super.paintComponent(buf.getGraphics());

View Full Code Here
   1:   };
   2:   private static final ConvolveOp OP = new ConvolveOp(new Kernel(3,3, ELEMENTS), ConvolveOp.EDGE_NO_OP, null);
   3: 
   4: 
   5:   public void restore(ESISNode n, Map<String,Object> attr, Layer layer) {

View Full Code Here
   1: 
   2:         return new Kernel(blurSize, blurSize, kernelData);            
   3:     }
   4: 
   5:     protected void paintSpotlights(Graphics g)

View Full Code Here

Method Details

clone

public Object clone()
Clones this object.
Overrides:
clone in interface Object
Returns:
a clone of this object.

getHeight

public final int getHeight()
Returns the height of this Kernel.
Returns:
the height of this Kernel.
Usages and Demos :

View More Examples of getHeight()
   1: import java.awt.image.ConvolveOp;
   2: import java.awt.image.Kernel;
   3: 
   4:         ...
   5:         if (filterDesc == null) {
   6:             Kernel kernel = convolveOp.getKernel();
   7:             Element filterDef =
   8:         ...
   9:                                              kernel.getWidth() + SPACE +
  10:                                              kernel.getHeight());

View Full Code Here
   1: 
   2:     protected Kernel kernel = null;
   3:     protected boolean alpha = true;
   4:         ...
   5:     public ConvolveFilter(float[] matrix) {
   6:         this(new Kernel(3, 3, matrix));
   7:     }
   8:         ...
   9:         int width = src.getWidth();
  10:         int height = src.getHeight();
  11: 
  12:         ...
  13:             dstCM = src.getColorModel();
  14:         return new BufferedImage(dstCM, dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dstCM.isAlphaPremultiplied(), null);

View Full Code Here
   1: import java.awt.image.DirectColorModel;
   2: import java.awt.image.Kernel;
   3: import java.awt.image.Raster;
   4:         ...
   5: 
   6:     Kernel kernel;
   7:     Point  target;
   8:         ...
   9:         final int pixels[] = db.getBankData()[0];
  10:         for (int y=0; y<wr.getHeight(); y++) {
  11:             int sp = base + y*scanStride;
  12:         ...
  13:         int y0=wr.getMinY();
  14:         int y1=y0 + wr.getHeight()-1;

View Full Code Here

getKernelData

public final float[] getKernelData(float[] data)
Returns the kernel data in row major order. The data array is returned. If data is null, a new array is allocated.
Parameters:
data - if non-null, contains the returned kernel data
Returns:
the data array containing the kernel data in row major order or, if data is null, a newly allocated array containing the kernel data in row major order
Throws:
IllegalArgumentException - if data is less than the size of this Kernel

getWidth

public final int getWidth()
Returns the width of this Kernel.
Returns:
the width of this Kernel.
Usages and Demos :

View More Examples of getWidth()
   1: import java.awt.image.ConvolveOp;
   2: import java.awt.image.Kernel;
   3: 
   4:         ...
   5:         if (filterDesc == null) {
   6:             Kernel kernel = convolveOp.getKernel();
   7:             Element filterDef =
   8:         ...
   9:             feConvolveMatrixDef.setAttributeNS(null, SVG_ORDER_ATTRIBUTE,
  10:                                              kernel.getWidth() + SPACE +
  11:                                              kernel.getHeight());

View Full Code Here
   1: import java.awt.image.DirectColorModel;
   2: import java.awt.image.Kernel;
   3: import java.awt.image.Raster;
   4:         ...
   5: 
   6:     Kernel kernel;
   7:     Point  target;
   8:         ...
   9: 
  10:         final int width = wr.getWidth();
  11: 
  12:         ...
  13:         int x0=wr.getMinX();
  14:         int w =wr.getWidth();

View Full Code Here

getXOrigin

public final int getXOrigin()
Returns the X origin of this Kernel.
Returns:
the X origin.
Usages and Demos :

View More Examples of getXOrigin()
   1: import java.awt.image.DirectColorModel;
   2: import java.awt.image.Kernel;
   3: import java.awt.image.Raster;
   4:         ...
   5: 
   6:     Kernel kernel;
   7:     Point  target;
   8:         ...
   9: 
  10:         int phaseShiftX = target.x - kernel.getXOrigin();
  11:         int phaseShiftY = target.y - kernel.getYOrigin();

View Full Code Here

getYOrigin

public final int getYOrigin()
Returns the Y origin of this Kernel.
Returns:
the Y origin.
Usages and Demos :

View More Examples of getYOrigin()
   1: import java.awt.image.DirectColorModel;
   2: import java.awt.image.Kernel;
   3: import java.awt.image.Raster;
   4:         ...
   5: 
   6:     Kernel kernel;
   7:     Point  target;
   8:         ...
   9:         int phaseShiftX = target.x - kernel.getXOrigin();
  10:         int phaseShiftY = target.y - kernel.getYOrigin();
  11:         int destX = (int)(r.getX() + phaseShiftX);

View Full Code Here