Possible Duplicate:
how to repeat along two axis
Let’s suppose we have the following matrix/image:
x = array([[1, 0, 1],
[0, 1, 0],
[1, 0, 1]])
What I’d like to get is a 9×9 matrix that is a 3x magnified version of the above, having 3×3 ones in the top left corner, 3×3 0s in the middle top, etc.
The things I’ve already tried are:
scipy.ndimage.interpolation.zoom(x, 3, order=(anything)), for example order=0 returns this:
array([[1, 1, 0, 0, 0, 0, 1, 1, 1],
[1, 1, 0, 0, 0, 0, 1, 1, 1],
[0, 0, 1, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 1, 0, 0, 0],
[1, 1, 0, 0, 0, 0, 1, 1, 1],
[1, 1, 0, 0, 0, 0, 1, 1, 1],
[1, 1, 0, 0, 0, 0, 1, 1, 1]])
scipy.misc.imresize(x, (9,9), interp=”nearest”) (effectively from PIL), that comes up with a different creative (but wrong) solution.
Meanwhile, the MATLAB imresize solves the problem perfectly…
Any ideas? (note: all of these solutions should work, so before submitting, try it out :))
Kronecker product:
the result: