Sunday, August 15, 2010

Attneave shapes

Fred Attneave and Malcolm Arnoult did some classic studies in the 1950s which used 'nonsense shapes' as stimuli.  The term 'nonsense shape' is sort of a silly term, and says a lot about the research of the day, where in order to gain scientific rigor, researchers attempted to get rid of all the idiosyncratic associations between psychological stimuli and an Ss experience (even referring to a "participant" as "an ess"), and so created 'nonsense syllables' or CVCs (see Brown and Peterson and Peterson), and their use of the term 'nonsense shape' seems inspired by this work.  They give about nine different methods for generating 'nonsense' shapes of various sorts.  I'll focus here on their Method 1, although there are a lot of clever ideas in that paper.  Here is a Figure from  Attneave & Arnoult's (1956) paper, showing how to create a shape:



The recipe is as follows:
  1. Pick random points on a 2D  grid
  2. Find the 'convex hull' of the points.
  3. Pick an interior point, and connect it to a random edge, as long as it does not intersect another edge
  4. Repeat #3 until all points are assigned.

There are a number of criteria described implicitly or explicitly by A&A about whether a shape should be legitimate.  Things like 'do lines cross' is trivial for a research assistant to identify when doing this by hand on graph paper, but not exactly trivial when doing this algorithmically.  A MATLAB routine for constructing these shapes was published more recently by Collin & McCullen (2002), and they worked through many of these issues.  I have borrowed heavily from their examples, and come up with a MakeAttneave() function that creates points for an Attneave shape that satisfies a number of criteria.


MakeAttneave is called with the following arguments:

MakeAttneave(size,numpoints,minangle, maxangle)

size indicates the diameter of a circle within which the polygon will be embedded.  Originally, A&A sampled random points in a grid; I (and maybe C&M) require that it fits within a circle.   This is important because so that there are no horizontal or vertical constraints that can accidentally give a cue to which of two figures was the 'original' and which is a 'comparison'. Without trimming to a circle, the shapes will tend to have four corners, and if you try to rotate them, those peaks will rotate too.

There are a number of ways to randomly sample points uniformly within a circle.   One way NOT to do it is to chose a random radius and angle, then compute the point via rSin(theta) and rCos(theta).  This will will not be uniformly distributed within the circle, and the point will be more likely to live close to the center than the exterior.  I remember from long ago that there is probably some clever way to sample uniformly from the area of a circle, but it was faster for me to use a sample-and-reject method.  Simply choose uniform points from the square within which the circle is inscribed, and then reject and try again when it lies outside the circle.  Here is a set of the final figures, showing the circles they live within:







numpoints is the number of points (and edges) that will ultimately be in the figure.  Note that it doesn't say how many exterior points there will be--they are sometimes all exterior points, and at least three must be exterior points.

minangle and maxangle and are two criteria that help determine whether a shape is "valid".  They are specified in degrees, and should be something like 10 and 170.  If they are smaller, you can get really long sharp spikes, which can be very sensitive to where the pixels happen to be; if angles are larger, you won't be able to tell the edge is even there, and you lose some of the specified complexity of the polygon.


MakeAttneave works by first finding the convex hull, just like the recipe above.  As a side effect, we now have a ConvexHull function available in PEBL, which can be useful for other purposes. After the convex hull is found, we just take the remaining shapes, and try to add them in random positions in the current shape, one at a time.  At each point, we pick a random edge, and then create candidate edges between the two endpoint of that edge and the new point.  Then, check to see if the new edges cross any other edges, and whether the angles are valid.  It should always be possible to find a pair of points between which you can fit any interior point, but sometimes it won't be possible to find one that doesn't violate the edge constraints.   When this happens, I have an 'emergency out: I simply call the MakeAttneave function recursively.  In its current form, I don't do any checks, so it is possible to create constraints that make it impossible to find a legal figure, and the function will recurse until its stack depth or the machine memory runs out, and the system crashes.  So take care when you use it.

What does the output look like?  First, let me try two sets with fairly high minimum angles (20 degrees):


10 points, angles 20-175 degrees

20 points, angles 20-175 degrees


Lets decrease the minimum angle from 20 degrees to 5, for each number of points:

10 points, 5-175 degrees

20 points, 5-175 degrees


These didn't take as long to make, which is nice, but you get those spikes, which may not be ideal.

Trying to push the parameters further leads to some problems.  With 10 points, you can set the minimum angle as high as 50 degrees, without the search taking too extremely long.  And it creates nice full polygons.

10 points, 50-175 degrees

Don't try doing this with 20-point polygons.  With 20 points, there just aren't good ways to connect all the points without having a few very small angles, and it rarely finds a legal polygon.  And even without raising the lower angle limit, as you add more points, legal polygons become difficult to find.  I can create 25-sided polygons if I set the lower limit to 1 degree, but larger than that gets very slow and difficult to find solutions for.  For polygons this large, there may be other approaches that are better than this one--you might just want to find an approximate solution for the traveling salesman problem on the points (as described in the trail-making task) and then check for overlapping edges, and ignore angle restrictions. Here is a set of 25-sided  and 30-sided Attneave shapes:


25 points, .1-179 degrees



30 points, .1-179 degrees


These get quit complex, and start filling in more of the circle-mashing together to fit enough vertices in the constrained shape. They share a resemblance even if they aren't similar in shape.  In the future,  when I blog about the object judgment task,  I'll describe how to create (and validate) shape families--shapes that have a family resemblance, yet are still valid according to the testing criteria.



References:

Attneave, F., & Arnoult, M. D. (1956). The quantitative study of shape and pattern perception. Psychological Bulletin, 53(6), 452-471.

Collin, C. A., & Mcmullen, P. A. (2002). Using Matlab to generate families of similar Attneave shapes. Behavior Research Methods Instruments and Computers, 34(1), 55-68.
Post a Comment