gaborPatch: Draw a gray-scale Gabor Patch

Description Usage Arguments Details Value Note References Examples

View source: R/gaborPatch.R

Description

Draw a gray-scale Gabor Patch

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
gaborPatch(sf, 
    theta = 0, 
    rad = (theta * pi)/180, 
    pc = 1, 
    sigma = 1/6, 
    psi = 0, 
    grating = c("cosine", "sine"), 
    npoints = 100, 
    trim = 0, 
    trim.col = .5,
    ...)

Arguments

sf

number of cycles per image.

theta

orientation in degree. See ‘Details’

rad

orientation in radian

pc

a fraction (0 to 1) specifying the peak contrast of the Gabor

sigma

the standard deviation of the Gaussian mask. Either a single numeric or a numeric vector of length 2.

psi

phase offset in radian

grating

type of grating to be used. Default to ‘cosine’.

npoints

number of points per line used to draw the patch.

trim

Gaussian values smaller than the specified value should be trimmed.

trim.col

gray level of the trimmed part of the image, between 0 (‘black’) and 1 (‘white’). Default to .5 (‘gray’) Setting it to any other value or NA makes the trimmed part transparent.

...

additional parameters for image may be passed as arguments to this function.

Details

The arguments theta and rad is the same thing but in different units. If both are supplied, rad takes the precedence.

Value

invisibly returns the matrix of the plotted values.

Note

This function is written just for fun; it is not optimized for speed or for performance.

References

Fredericksen, R. E., Bex, P. J., & Verstraten, F. A. J. (1997). How Big is a Gabor and Why Should We Care? Journal of the Optical Society of America A. 14, 1–12.

Gabor Filter. (2010, June 5). In Wikipedia, the free encyclopedia. Retrieved July 7, 2010, from http://en.wikipedia.org/wiki/Gabor_filter

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# An imitation of Fredericksen et al.'s (1997) Fig 1.
# that demonstrate the relation between peak contrast
# and perceived size of the Gabor

op <- par(mfcol = c(3, 3), pty = "m", mai = c(0,0,0,0))
for(i in c(.85, .21, .06)){
    for(j in c(1/6, 1/7, 1/8)){
        gaborPatch(20, pc = i, sigma = j)
    }
}
par(op)

## Not run: 
# a typical plot of the stimuli and category structure
# often seen in artificial category-learning literatures.
m  <-  list(c(268, 157), c(332, 93))
covs  <-  matrix(c(4538, 4351, 4351, 4538), ncol = 2)
II <- grtrnorm(n = 40, np = 2, means = m, covs = covs,
   clip.sd = 4, seed = 1234)
II$sf <- .25+(II$x1/50)
II$theta <- II$x2*(18/50)

plot(II[,2:3], xlim = c(-100,600), ylim = c(-200,500), 
    pch = 21, bg = c("white","gray")[II$category])
abline(a = -175, b = 1)

library(Hmisc)
idx <- c(20, 31, 35, 49, 62)
xpos <- c(0, 100, 300, 350, 550)
ypos <- c(50, 300, 420, -120, 50)
for(i in 1:5)
{
    j = idx[i]
    segments(x0=II[j,"x1"], y0=II[j,"x2"], x1=xpos[i], y1=ypos[i])
    subplot(gaborPatch(sf=II[j,"sf"], theta=II[j,"theta"]), x=xpos[i], y=ypos[i])
}

## End(Not run)

matsukik/grt documentation built on May 21, 2019, 12:57 p.m.