From: Daniel Carrera Date: 2003-05-04T12:26:39+09:00 Subject: Re: "Collage" of images -- more pychological randomness > > Is there any reason why you want the position of the 4x4 image randomized? > > Why can't it be (0,0) every time? > > The whole point (in my mind) is to generate a > "random-looking" collage that will be pleasing > to the eye. The randomness should be apparent > both in space and time (e.g., suppose the > collage is re-generated every day). Yeah, I didn't realize the random-looking scenario. You see, the optimal solution is the least random. For instance, in this case the optimal solution is: 1 1 1 1 1 1 + + # # # x x x + + # # # x x x * * # # # x x x * * @ @ @ @ * * + + @ @ @ @ * * + + @ @ @ @ + + * * @ @ @ @ + + * * But that's very non-random-looking. Humans have a poor intuition as to what random looks like. Humans subconciously tend to equate random with "almost balanced but not quite". So, to make it "look nice", we should put the big square near the center, but a bit off, and try to balance the distribution of images. For instance: + + 1 * * 1 + + + + 1 * * 1 + + 1 @ @ @ @ * * 1 1 @ @ @ @ * * 1 1 @ @ @ @ x x x 1 @ @ @ @ x x x + + * * 1 x x x + + * * 1 1 1 1 As you can see, this has only 1 3-box. Perhaps we should try a different set of constraints (given from highest priority to lowest): - Bigger boxes closer to the center, but not smack in the middle. - Avoid putting boxes of the same size together. - Aim for balance. This is not random, but it *looks* random. Here is one solution: + + 1 * * x x x + + 1 * * x x x 1 @ @ @ @ x x x 1 @ @ @ @ * * 1 1 @ @ @ @ x x x 1 @ @ @ @ x x x + + 1 * * x x x + + 1 * * 1 1 1 Such algorithm would be difficult to write and slow, and in your case I expect that all solutions are reflections of the one above. Perhaps you will be satisfied with hard-coding the above arrangement and simply randomly selecting one of the 4 possible reflections. To give you more variety, here are two variations (I'll only show the bottom two lines, since that's what I'm changing): 1 + + * * x x x 1 + + * * 1 1 1 + + * * 1 x x x + + * * 1 1 1 1 You can add those so that you get a total of 3*4 = 12 possible choices. Then use our beloved weighted-random function to give preference to the 4 reflections arrangement above. Yes, I realize that hard-coding all this is very bad form, but it might give you the best results for your purposes. -- Daniel Carrera Graduate Teaching Assistant. Math Dept. University of Maryland. (301) 405-5137