# How do I slice an image of size “width × height” in n² pieces of size “width / n × height / n”?

Background: What I want is to make a jigsaw from an image. (A simple one where the pieces are polygons.) I have the following strategy in mind. Create a set of polygons and assign images (or just the original image) to them as a texture and set the texture coordinates. I know from the documentation (Lena example) how to use an image as a texture. Is chopping up the image in parts and assign these parts as textures a feasible strategy? If so, then I have the following question:

Question: Given an image of size width × height, how do I slice it in n² pieces of size width / n × height / n ?

-
Considering I often underestimate Mathematica you can imagine how content I am with the product. –  ndroock1 Jun 24 '12 at 15:04

ImagePartition[] is the function you need:

With[{n = 4, img = ExampleData[{"TestImage", "Mandrill"}]},
ImagePartition[img, Scaled[{1/n, 1/n}]]] // GraphicsGrid


See the docs for more details.

-
I prefer Lena .. –  belisarius Jun 25 '12 at 0:51
@bel: Well, I could've used Lena, but I'm told she was tired at the time... –  Ｊ. Ｍ. Jun 25 '12 at 4:15
Of course: cs.cmu.edu/~chuck/lennapg/lenna.shtml –  belisarius Jun 25 '12 at 4:27
@bel: more precisely, I made use of her picture already as an answer to another image-related question... –  Ｊ. Ｍ. Jun 25 '12 at 11:34