kernfilter
Filter a cube through a kernel
Group=Kernel
Samples=2
Lines=1
Weight=1
Data= (1, -1)
EndGroup
The "group" keyword should equal Kernel (Group=Kernel). This lets the
program know that it is the users intent that the text file is used as a
kernel.
The "lines" and "samples" keywords should match the amount of data that
is supplied in the data keyword. In this example, there are 2 samples
worth of data and 1 line worth. The keywords above thus reflect these
values.
The "weight" is applied to all of the values in the kernel. It is
often set to a fraction that allows for averaging, but it is a value
that is used differently by each type of filter simulated by the
kernel. Since the above filter uses no averaging, the weight is simply 1.
The "data" defines a set of multiplicative constants. These multiplicative
constants are the weights that the kernfilter will use on the input image.
In our example, assume that the DNs being examined are 10 and 20. The
first DN (10) would be multiplied by the first weight (1). The second DN
(20) would be multiplied by the second weight (-1). The two products (10
and -20) would then be added together and the resultant sum (-10) would
be output. The set of data should be enclosed in parentheses. For
organizational purposes, one may insert as much or as little white space
as they desire but they must separate each constant with a comma.
Finally, the document should be finished with the keyword "EndGroup" to
signify that no more information is provided.
Categories
History
| Drew Davidson | 2004-07-26 | Original version |
| Drew Davidson | 2004-07-27 | Added application test |
| Drew Davidson | 2004-08-16 | Added examples |
| Elizabeth Miller | 2006-07-24 | Moved kernel files to the $base/templates/kernels folder |
| Mackenzie Boyd | 2009-07-27 | Added error checking for kernel input, modified special pixel handling to null resultant pixel, added example, added application test, changed pixel type to real. |
Parameters
Files
| Type | cube |
|---|---|
| File Mode | input |
| Filter | *.cub |
| Type | cube |
|---|---|
| File Mode | output |
| Pixel Type | real |
| Filter | *.cub |
| Type | filename |
|---|---|
| File Mode | input |
| Default Path | $ISISROOT/appdata/templates/kernels/ |
| Filter | *.txt |
Example 1
Using the highpassCircle5x5.txt kernel
0 -1 -1 -1 0
-1 -1 -1 -1 -1
-1 -1 24 -1 -1 x .04
-1 -1 -1 -1 -1
0 -1 -1 -1 0
Thus, the highpass filter is simulated. The center pixel will be
multiplied by 24. Then this value will be added to the values of its
surrounding pixels (all of these values will either have a sign change
since they were multiplied by -1 in this filter or they will be 0, since
0 and -1 are the only weight values that the filter holds, except for the
center pixel). Finally, after all of the addition has been done, the final
sum of all of the weights that were multiplied by either 24, or -1, or 0,
will be multiplied by .04, which equals 1/25. The reason all of the pixels
are multiplied by 1/25 is that there are 25 spots in the 5 by 5 kernel,
and thus the image will be normalized.
Command Line
kernfilter
from= peaks.cub to=highpass.cub kernel=highpassCircle5x5.txt
GUI Screenshot
Example GUI
kernfilter guiScreenshot of the GUI with parameters set to simulate the highpass filter with a 5 x 5 circular boxcar.
Input Image
Input image before kernfilter.
The image before the filter
Parameter Name:
FROM
This is the unfiltered image. Note the low frequency data (albedo) in the image. The highpass filter that this kernel mimics is intended to filter this type of data out.
Output Image
Output image after kernfilter
The image after the filter
Parameter Name:
TO
The filtered image. Just as an actual 5 x 5 circular highpass filter would do, this kernel has removed albedo, allowing the user to see more terrain. Since a 5x5 filter is considered relatively small, features which are considered relatively small will still be visible.
Example 2
Using the smoothPyramid5x5.txt kernel
1 2 3 2 1
2 4 6 4 2
3 6 9 6 3 x 1/81
2 4 6 4 2
1 2 3 2 1
The pixels in the boxcar are assigned weights that inversely reflect
their distance from the center of the boxcar. The pixel at the very
center will be multiplied by 9 and then added to all of the values that
were multiplied by the other weights in the boxcar. Note that all of the
weights add up to 81. This is why the final output is divided by 81; it
allows the center pixel to be an average of the weights. Thus, the blur
appears as though a smoothing algorithm applying weight in a pyramidal
fashion had been applied.
Command Line
kernfilter
from= peaks.cub to=smooth.cub
kernel=smoothPyramid5x5.txt
GUI Screenshot
Example GUI
kernfilter guiScreenshot of the GUI with parameters set to perform the smoothing filter with a 5 x 5 boxcar.
Input Image
Input image before kernfilter.
The image before the filter
Parameter Name:
FROM
This is the image as it was taken originally with no smoothing.
Output Image
Example 3
Using the derivativeNWtoSE2x2.txt kernel
1 0
0 -1 x 1.0
The top left pixel receives the value of itself minus the pixel down
right of itself. The other two pixesl do not matter. Anywhere where is
significant change from the top left to the bottom right then shows it
with brighter or darker pixels than the surrounding gray where there was
little difference and the DNs are at or close to zero.
Command Line
kernfilter
from=peaks.cub to=derivative.cub kernel=derivativeNWtoSE2x2.txt
GUI Screenshot
Example GUI
kernfilter guiScreenshot of the GUI with parameters set to perform the derivative from NW to SE with a 2x2 boxcar.
Input Image
Input image before kernfilter.
The image before the filter
Parameter Name:
FROM
This is the image as it was taken originally.

