Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 ?

share|improve this question
    
Considering I often underestimate Mathematica you can imagine how content I am with the product. –  ndroock1 Jun 24 '12 at 15:04
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
    
I prefer Lena .. –  belisarius Jun 25 '12 at 0:51
1  
@bel: Well, I could've used Lena, but I'm told she was tired at the time... –  J. M. Jun 25 '12 at 4:15
1  
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... –  J. M. Jun 25 '12 at 11:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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