binary matrices with directional non-zero elements This question is in the context of image processing.

Assume I have a matrix of size 64 by 64. Assume even rows are all zero and odd rows are all one. I want to rotate the matrix d degrees. For example if I rotate it 90 degrees, then I will have a matrix with even columns equal to zero and odd columns equal to one. 
Is there an algorithm to do that easily? Given the matrix and d I want to rotate the elements. Matlab's imrotate won't work since after rotation I get some zeros at the corners. I know one way is to use repmat, rotate it and then crop it in the center. But that does not seem straightforward. Any smart ideas? For example, is it possible to define a formula to give the values of each element given d (and the fact that the matrix was originally 1 0 1 0...?
If you assume that your image origins from sampling a continuous-spatial-domain 2-dimensional function, you can perform the sampling of this function with the rotated coordinates. HAve a look at this example:

N = 32  # 32 for simplicity
N2 = N/2
x, y = np.meshgrid(np.arange(N), np.arange(N))

# exemplary rotation around 5 degrees
angle = 5*np.pi/180
# perform rotation around the image center
nx = np.cos(angle)*(x-N2) - np.sin(angle)*(y-N2) + N2
ny = np.sin(angle)*(x-N2) + np.cos(angle)*(y-N2) + N2

# three functions that fulfill your constraint of even-odd 1-0
I_func1 = lambda x, y: 0.5*(1-np.cos(np.pi*y))
I_func2 = lambda x, y: (abs((y%2)-1)&lt;=0.5).astype(float)
I_func3 = lambda x, y: (1-abs((y%2)-1)).astype(float)

# the original image
I = I_func1(x, y)

plt.figure()
t = np.linspace(0, N-1, 16*N)
t2 = np.arange(N)
plt.plot(t, I_func1(0, t))
plt.plot(t, I_func2(0, t))
plt.plot(t, I_func3(0,t))
plt.stem(t2, I_func(0, t2))
plt.xlim((0, 5))
plt.title('underlying continuous function')

plt.figure(figsize=(12,12))
plt.subplot(221)
plt.imshow(I, interpolation='none', cmap='gray')

plt.subplot(222)
plt.imshow(I_func1(nx, ny), interpolation='none', cmap='gray')
plt.title("Cos")

plt.subplot(223)
plt.imshow(I_func2(nx, ny), interpolation='none', cmap='gray')
plt.title("rect")

plt.subplot(224)
plt.imshow(I_func3(nx, ny), interpolation='none', cmap='gray')
plt.title("triang")


Output:




As you see, different functions yield different rotation results. Maybe this can help you to find an explicity formula?