|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
dlife.vision.filter.Filter
dlife.vision.filter.ConvolutionFilter
public class ConvolutionFilter
Filters an image by convolving a kernel over the image. A new value for each pixel is computed by placing the convolution kernel over the image with the pixel at the center. The values in the convolution kernel are then used to compute a weighted sum of the pixels covered by the kernel. The value of the pixel at the center of the kernel is then set to the weighted sum.
The ConvolutionFilter GUI (shown below) allows the user to enter
values for a convolution kernel of up to 7x7. The 1x1 kernel below will make
the image 1/2 as bright.

The convolution operation forms the basis for a wide variety of image
filters. For example the GaussianFilter and
LaplacianFilter are both sub-classes of the
ConvolutionFilter. More information and a brief introduction to
Convolution
Matrices (filters) can be found in the gimp manual (Note: the writing on
this page is a little rough, but it provides a good feel for convolution
filters).
| Nested Class Summary | |
|---|---|
protected class |
ConvolutionFilter.ConvolutionFilterGUI
GUI for a ConvolutionFilter. |
| Constructor Summary | |
|---|---|
ConvolutionFilter()
Construct a new ConvolutionFilter. |
|
ConvolutionFilter(float[][] kernel,
int pixelRow,
int pixelCol)
Construct a new ConvolutionFilter using the specified kernel. |
|
| Method Summary | |
|---|---|
protected FilterGUI |
createGUIObject()
Get the GUI for this ConvolutionFilter. |
BufferedImage |
filter(BufferedImage frame)
Apply the convolution kernel to the image in frame and return the result. |
String |
getCode(String name)
Get a String containing the Java code that would be necessary to create this Filter in its current state and add it to the specified VisionClient. |
float[][] |
getKernel()
Get the convolution kernel from this ConvolutionFilter. |
static void |
main(String[] args)
Main method that pops up a GUI for the ConvolutionFilter to allow it to be tested. |
void |
setKernel(float[][] newKernel,
int pixelRow,
int pixelCol)
Set the convolution kernel for this ConvolutionFilter. |
void |
setKernelCell(int row,
int col,
float value)
Set the value of one of the cells in the convolution kernel for this ConvolutionFilter. |
| Methods inherited from class dlife.vision.filter.Filter |
|---|
getGUI, getID, isOn, turnOn |
| Methods inherited from class java.util.Observable |
|---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConvolutionFilter()
public ConvolutionFilter(float[][] kernel,
int pixelRow,
int pixelCol)
kernel - the convolution kernel.pixelRow - the index of the element of kernel that is over the pixel
currently being processed.pixelCol - the index of the element of kernel that is over the pixel
currently being processed.| Method Detail |
|---|
protected FilterGUI createGUIObject()
createGUIObject in class Filterpublic float[][] getKernel()
public void setKernel(float[][] newKernel,
int pixelRow,
int pixelCol)
newKernel - the new kernel.pixelRow - the index of the element of kernel that is over the pixel
currently being processed.pixelCol - the index of the element of kernel that is over the pixel
currently being processed.
public void setKernelCell(int row,
int col,
float value)
row - the row of the cell to set.col - the column of the cell to set.value - the value to place in the cell.public BufferedImage filter(BufferedImage frame)
filter in class Filterframe - the image to be filtered.
public String getCode(String name)
getCode in class Filtername - the name of the Camera device to which the generated code
should add the Filter.
public static void main(String[] args)
throws Exception
args - none
Exception
|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||