# Grating cell operator for image processing and computer vision

M. Hol, F.E. Kalsbeek and N. Petkov, University of Groningen,
Department of Computing Science, Intelligent Systems

## Examples

### 1) Gabor filter output

The grating cell operator makes use of the Gabor filter to detect lines of a given orientation. The response of a Gabor filter to such lines is used to detect gratings of lines. To facilitate understanding of the model, we first illustrate its first step - the computation of a Gabor filter output to an input image in which lines, line gratings and edges are present.
Select the following
parameter values:
• Input image = synthetic1.png
• Output image = Gabor filter output
• Wavelength = 12 ; Orientation(s) (deg.) = 0 ; Phase offset(s) (deg.) = 0,180 ; Aspect Ratio = 0.5 ; Bandwidth = 1 ; Number of orientations = 1
• Enable HWR = checked
• HWR Threshold = 40%
• Superposition of phases = L-infinity norm (or L1 or L2 norm)
• Rho = 0.6 (not used for Gabor filtering)
• Minimum number of bars = 3 (not used for Gabor filtering)
• Beta = 5 (not used for Gabor filtering)
• Padding to grating = checked (not used for Gabor filtering)
Two Gabor filters are applied - one with a phase offset 180 deg that detects black bars on a bright background, and the other with a phase offset 0 deg that detects white bars on a black background. (These two filters correspond to computational models of center-off and center-on simple cells, respectively.) Note that the the vertical bar grating consists of alternating black and (wider) white bars so that both filters will generate response. The output window shows the superpositon of the outputs of two filters in which their responses to black and white bars, respectively, are interleaved. You can observe these responses separately by eliminating one of the phase offset values in the input list. The center-off (180 deg offset) filter responds also to the long vertical bar in the center of the image. This response is surrounded by two flanking responses produced by the center-on (0 deg offset) filter. This response pattern (one central line surrounded by two flanking lines) is characteristic of an isolated bar that does not make part of a grating. A bar grating in the input gives rise to a larger number (larger than 3) of parallel line responses in the Gabor filter output.

### 2) Grating subunits output

The second step is the calculation of grating subunits from the Gabor filter output image.
Select the following
parameter values:
• Input image = synthetic1.png
• Output image = Grating subunits output
• Wavelength = 12 ; Orientation(s) (deg.) = 0 ; Phase offset(s) (deg.) = 0,180 ; Aspect Ratio = 0.5 ; Bandwidth = 1 ; Number of orientations = 1
• Enable HWR = checked
• HWR Threshold = 0%
• Superposition of phases = L-infinity norm (or L1 or L2 norm)
• Rho = 0.6
• Minimum number of bars = 3
• Beta = 5
• Padding to grating = unchecked
A grating subunit is activated by a set of nrsimplecells/2 bars from the input image, which is, in this case, 4 (black or white) bars.
Since the Gabor filter output image contains both center-off and center-on responses (see example 1), a grating subunit is activated by "nrsimplecells" bars from the Gabor filter output image.
In this example, number of simple cells = 6.
Recall from the explanations page that a grating subunit (q) will get the value 1 if these 6 simple cells have nearly the same intensities (within the margin of rho). This is the case for our example.
The 6 leftmost bars of the Gabor filter output image fill 6*(wavelength/2) pixels. (Note: wavelength/2, because in the input image, one black bar next to a white bar is one lambda (=wavelength))
In this example, wavelength is 12, so 6 bars in the Gabor filter output image fill 6*6 = 36 pixels. Since, by the definition of a grating subunit, these pixels count as grating and the middle pixel of them will get the value 1 (this middle pixel is 18 if the grating starts at pixel 1).
This process is repeated for all pixels on a row, and for all rows of the image.
It is now clear to see why the 4 leftmost and rightmost bars of the Gabor filter output image are not detected as grating when padding to grating is disabled.

Observe that the blurring effect of the Gabor filter in the vertical direction (see previous example) causes some grating to be detected above and below the vertical bars of the original input image. This is not the case for the horizontal middle of the output picture. This is caused by the large intensity difference with the large bar in the middle. When rho is set lower, the intensity difference is accepted and grating will be found also in the middle of the picture.

Note that the 3 vertical bars in the upper half Gabor filter output image are not detected by the grating subunits.

### 3) Grating filter output

Select the following
parameter values:
• Input image = synthetic1.png
• Output image = Grating filter output
• Wavelength = 12 ; Orientation(s) (deg.) = 0 ; Phase offset(s) (deg.) = 0,180 ; Aspect Ratio = 0.5 ; Bandwidth = 1 ; Number of orientations = 1
• Enable HWR = checked
• HWR Threshold = 0%
• Superposition of phases = L2 norm
• Rho = 0.6
• Minimum number of bars = 3
• Beta = 5
• Padding to grating = unchecked
Selecting as output the Grating filter output will show the gratingcells as explained in explanations page. Notice that the parameters except the Output image are the same as used in example 2. The output image is set to Grating filter output. On grating subunits from example 2 a convolution is performed with a gaussian kernel. The convolution is a weighted summation (formula 5) observe that the gratingfilter output is a blurred version of the grating subunits. The parameter beta determines the size over wich effective summation takes place, one can increase or decrease the value and see how this effects the grating filter output. An increase in beta results in a more blurred output where a decrease in beta results in an output wich more resembles the grating subunits.

### 4) Nearly exact grating detection

Select the following
parameter values:
• Input image = synthetic1.png
• Output image = Grating filter output
• Wavelength = 12 ; Orientation(s) (deg.) = 0 ; Phase offset(s) (deg.) = 0,180 ; Aspect Ratio = 0.5 ; Bandwidth = 1 ; Number of orientations = 1
• Enable HWR = checked
• HWR Threshold = 50%
• Superposition of phases = L2 norm
• Rho = 0.5
• Minimum number of bars = 4
• Beta = 5
• Padding to grating = checked
With these settings the grating filter output gives a quite precise representation of the actual grating in the input image.
How this is achieved is explained here:

In the Gabor filter output image of example 1, the vertical bars are longer than the original vertical bars from the input image. This is caused by the blurring effect of the Gabor filter.
For an understanding of this: please select as output image: Gabor function.
The strongest response of this Gabor function occurs when it is fully covered by a bar (from the top to the bottom of this Gabor funtion).
If only the lower half of the Gabor function covers a bar, and the upper half covers the background, the response at that point is 50%. This is the reason that when HWR Threshold is set to 50%, the Gabor filter output image shows the same vertical lenght of the bars as the input image.

Now, please select as output image: Grating subunits output.
With HWR set to 50%, the vertical length of the detected grating is nearly the same as the vertical length of the original bars in the input image. Since padding to grating is enabled, the width of the grating corresponds also well to the grating of the input image.

### 5) Grating detection on a natural image

Select the following
parameter values:
• Input image = tafelkleed.png
• Output image = Grating filter output
• Wavelength = 5 ; Orientation(s) (deg.) = 10 ; Phase offset(s) (deg.) = 0,180 ; Aspect Ratio = 0.5 ; Bandwidth = 1 ; Number of orientations = 1
• Enable HWR = checked
• HWR Threshold = 10%
• Superposition of phases = L2 norm
• Rho = 0.4
• Minimum number of bars= 4
• Beta = 5
• Padding to grating = checked

The input image shows a bottle placed on a wrinkled cloth with bar shaped texture under an orientation of about 10 degrees. The wavelength of the grating is about 5 pixels. Selecting the Gabor filter output one can see that the edges of the bottle and the bar grating is mostly preserved. Yet after applying the grating filter with apropriate paremeters only the bar shaped texture is preserved.
Last changed: 2008-07-03