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 ?

  • $\begingroup$ Considering I often underestimate Mathematica you can imagine how content I am with the product. $\endgroup$ – nilo de roock 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

partitioned image

See the docs for more details.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.