Sunday, November 7, 2010

Landolt Rings, Landolt Cs

A "Landolt Ring" or Landolt C has been used as a visual stimulus in a number of contexts.  It is especially useful as a visual of visual acuity for subjects who don't know their letters, or in situations where you can't get verbal responses.  They are a ring with a gap, and the gap is at a specific angle.  Typically this angle is one of the canonical 4 directions. 

For the latest in my occasional series about "stimuli named after people" (see also Gabor patches and Attneave Shapes), I wanted to create a PEBL function that generates this stimulus.



Creating them is really quite simple.  You just need (1) an outer circle that is black; (2) an inner circle inside that outer circle, the same color as your background, and (3) a rectangle of the correct width in the appropriate angle.  I used the Thickline function for this last element and circles for the first two, adding them all to an appropriately-sized canvas.  This essentially creates an image which can be moved around wherever you want.

The function, shown below, allows you to specify the outer and inner diameter, the angle of the gap (0 is straight 'east', 90 is 'north', etc.), the gap size, and the ring/background colors.


define LandoltRing(outer,inner, angle, lgap, color, bgcolor)
{
    degree <- DegtoRad(angle)

    centerX <- Ceiling(outer/2+1)
    centerY <- Ceiling(outer/2+1)

     back <- MakeCanvas(outer+2,outer+2,bgcolor)    
     circ <-    Circle(centerX, centerY,Floor(outer/2),color,1)
     AddObject(circ,back)
     Draw(back)

     circ.r <- inner/2
     circ.color <- bgcolor


     x <- outer * Cos(degree)
     y <- outer * Sin(degree)
     line <- ThickLine(centerX,centerY, centerx+x,centery+y,lgap,bgcolor)
     AddObject(line,back)
     Draw(back)
     RemoveObject(circ,back)
     RemoveObject(line,back)
     return back
}

This should work for ANY angle, not just the cardinal directions. Also, according to the wikipedia, the 'standard' C is apparently has a stroke 1/5 of its diameter, with a gap the same size.  To do this, you could call LandoltRing as follows:

LandoltRing(outer, outer*.8, angle, outer*.2, color, bgcolor)


This will be available in PEBL 0.12, but it should work in 0.11 as well, so copy it in to an experiment if you want to use it.

No comments: