# How to get randomly arranged image in Mathematica?

I'm now thinking about randomly arrangement of the imported image. After importing 2 hand-written images, image1 and image2, I want to make each 5 copys and randomly arrange them in one graph, i.e. totally 10 images are in a single graph. It is much better if the 10 images are in random rotation angle, random enlargement(shrink), random places. I found ImageTransformation command and ImageResize command for rotation and enlargement, but I couldn't find the command for setting image coordinates to several images...

Is it possible to do such a thing in Mathematica? If someone know how to do this, or whether it is possible or not, please tell me.

• ImageTransformation includes translation too. What have you tried until now? Commented Mar 7, 2023 at 8:32
• Thank you for your kind comment. Since I don't know how to upload image here, I'd like to call imported images, as imA and imB.
– rani
Commented Mar 7, 2023 at 16:27
• im1 = Table[imA, 5] theta1 = RandomReal[{1, 360}, 5]; enlarge1 = RandomReal[{50, 100}, 5]; ir1 = ImageRotate[im1[[#]], theta1[[#]]] & /@ Range[5]; (After rotating, a strange Frame appear around each image, though...) size1 = ImageResize[ir1[[#]], enlarge1[[#]]] & /@ Range[5];
– rani
Commented Mar 7, 2023 at 16:42
• Just show the two examplary images in your question, to be able to copy the images to Mathematica Commented Mar 7, 2023 at 16:42
• (I also did same thing to imB,) im2 = Table[imB, 5] theta2 = RandomReal[{1, 360}, 5]; enlarge2 = RandomReal[{50, 100}, 5]; ir2 = ImageRotate[im2[[#]], theta2[[#]]] & /@ Range[5];
– rani
Commented Mar 7, 2023 at 16:44

As a startup:

Define a frame in which you want to compose some pictures

frame = Image[ConstantArray[1, {1000, 1000, 3}]];


In the next step choose examlary images

pic1=  Import["ExampleData/spikey.tiff"]


at several positions in the frame

pics = {pic1, pic1, pic1, pic1};
pos = RandomInteger[{1 , 1000}, {Length[pics], 2}]
ImageCompose[frame, pics, pos ]//Framed


The list picsmight contain rotated, translated and scaled images. Hope it helps!

• Thank you SO MUCH!!! This is the exact answer which I want :) Thanks to your very kind answer, I could make the desired image with my handwritten images (successfully with random sizes and random shapes). It's very nice of you... Thanks again.
– rani
Commented Mar 10, 2023 at 6:02