1
$\begingroup$

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.

$\endgroup$
13
  • $\begingroup$ ImageTransformation includes translation too. What have you tried until now? $\endgroup$ Mar 7, 2023 at 8:32
  • $\begingroup$ 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. $\endgroup$
    – rani
    Mar 7, 2023 at 16:27
  • $\begingroup$ 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]; $\endgroup$
    – rani
    Mar 7, 2023 at 16:42
  • $\begingroup$ Just show the two examplary images in your question, to be able to copy the images to Mathematica $\endgroup$ Mar 7, 2023 at 16:42
  • $\begingroup$ (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]; $\endgroup$
    – rani
    Mar 7, 2023 at 16:44

1 Answer 1

2
$\begingroup$

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

enter image description here

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

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – rani
    Mar 10, 2023 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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