ioam/imagen — pull request #23 by JoelChavas (2014-06-05 16:46:58+00:00)
Title: Small thickness lines disappear at some orientation

Motivation behind the changes
---------------------------------------
By generating stimuli for illusory contour experiments, I have observed that, when the lines have a small thickness, they disappear at some orientation (particularly 0 and pi/2). See the test code below. The fact that it is orientation-dependent may be annoying. I propose in the pattern generator Line to check the thickness with respect to the pixel size. This change guarantees that, even with a thickness of 0, you will get a line
After this change, I propose to get a little bit further, that is to guarantee that the line of the smallest width that you get is always 1 pixel. Again, in the current code, you get this feature at nearly all orientations except close to 0 and pi/2. To get this feature at all orientations, I propose in this pull request a change in patternfn.py/line.

Test code
------------
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from numpy import pi

import imagen
from dataviews.sheetviews.boundingregion import BoundingBox

bounds=BoundingBox(radius = 6)
xdensity = 20
ydensity = 20

fig = plt.figure()

def plot(image):
im = plt.imshow(image,cmap=cm.Greys, interpolation='none', aspect='auto', extent=[-6,6,-6,6])

def one_line(orientation=pi/4):
ima = imagen.Line(scale=-1,offset=1,orientation=orientation,thickness=0.03,x=0., y=0., smoothing=0.0, xdensity=xdensity, ydensity=ydensity,bounds=bounds)
return ima()

plt.ylim([0,1])

for i in xrange(1,7):
ax=plt.subplot(2,3,i)
angle=(i-1)/10.
ax.set_title('angle='+str(angle)+'pi')
plot(one_line(orientation=(angle*pi)))

plt.show()

![minimal_thickness__one_pixel_ok](https://cloud.githubusercontent.com/assets/5656774/3190632/fb1f1f64-ecd0-11e3-8b94-7e9204b04a08.png)