nikki
|
|
« on: August 27, 2010, 07:26:30 AM » |
|
I am thinking of these Mondrian paintings (the early stuff) and was wondering which algorithm one would use to try to generate these babies procedurally ? any pointers ?
|
|
|
Logged
|
|
|
|
benbradley
Guest
|
|
« Reply #1 on: August 27, 2010, 08:37:43 AM » |
|
It might not give a perfect result but you could generate something very similar by recursively dividing rectangles, like a binary tree. Start with a whole square Randomly pick a direction to divide, either X or Y Pick a value from 0 up to the width or height of your square Divide the square along this line (eg. X=10) Maybe plot a black line at this point. Then apply this to all the sub-rectangles. Repeat down to say 5 levels. At the end of dividing all the rectangles, pick a random color and flood fill each part.
|
|
|
Logged
|
|
|
|
|
Guillaume
|
|
« Reply #3 on: August 27, 2010, 11:12:55 AM » |
|
That technique seems to work pretty well! However, you'd need to limit the minimum width for a rectangle- this screenshot has rectangles that are way too thin.
|
|
|
Logged
|
|
|
|
slembcke
|
|
« Reply #4 on: August 27, 2010, 12:55:31 PM » |
|
Looks a lot like a k-d tree.
|
|
|
Logged
|
|
|
|
|
benbradley
Guest
|
|
« Reply #6 on: August 27, 2010, 06:01:29 PM » |
|
Yeah, the second set look really cool. Another way to tweak it might be to pick a rectangle to divide from all existing rectangles, using relative areas as the probability. But that's already pretty close.
|
|
|
Logged
|
|
|
|
nikki
|
|
« Reply #7 on: August 27, 2010, 11:29:57 PM » |
|
WOW, i had to be go out for a day, and found this post filled with goodness ! Wow thanks Solved for your code, mucho mucho appreciated.
Your already there for the 85% i guess, only thing i spot that's different is something that a post-processing loop could fix, to make the black lines 'even-out' in other words to adjust the shapes slightly after all the randomness to make it so that the black lines are as horizontal/vertical as possible (no small corners)
|
|
|
Logged
|
|
|
|
|
Nix
Guest
|
|
« Reply #9 on: August 29, 2010, 07:22:30 PM » |
|
|
|
|
Logged
|
|
|
|
mcc
|
|
« Reply #10 on: August 29, 2010, 10:03:09 PM » |
|
Pretty. I wonder-- As I remember Mondrian was obsessed with the golden ratio and had the different areas in his paintings relate to each other via golden ratios as often as possible. If you had your program enforce golden ratios, would the images look more Mondriany?
|
|
|
Logged
|
|
|
|
nikki
|
|
« Reply #11 on: August 29, 2010, 11:30:09 PM » |
|
if i remember correctly Mondrian was against mathemathically constructing his works, it was much moire intuitive, alot of people claim there are golden ratio's in there, sometimes there are a few, but that's just a coincidence i think. or have you found anything in particular to proof this claim? offcourse a few golden ratio's here and there in a procedure like this , does make things nicer for the eye...
|
|
|
Logged
|
|
|
|
Solved
|
|
« Reply #12 on: August 30, 2010, 02:38:06 AM » |
|
Really awesome, the generated pictures look like cities from above.
|
|
|
Logged
|
|
|
|
Nix
Guest
|
|
« Reply #13 on: August 30, 2010, 05:29:49 AM » |
|
So it looks like the general consensus here is to use a recursive BSP approach to generating those patterns, but I don't really think those results match Mondrian's paintings. To make it a bit clearer what I mean, here is a bare-bones Mondrian pattern that has all the essential bits and pieces of most other Mondrian paintings: Here's my idea for a more "Mondrian-y" algorithm: 1) Create a bunch of vertical and horizontal lines that span the entire image, randomly spaced. 2) Create a bunch of vertical and horizontal lines that only stretch part of image such that their end-points are touching already-existing lines. 3) Flood fill random squares with random colors, leave some empty. I suspect this may spit out images with a bit more similarity to actual Mondrian paintings.
|
|
|
Logged
|
|
|
|
Solved
|
|
« Reply #14 on: August 30, 2010, 06:47:51 AM » |
|
Yeah, that could be a better method, I seem to have become very interested in this sort of stuff recently so I will probably implement a version of your method and see how it works.
Obviously the colours in my version of the subdividing one are completely off and those could be changed as well.
I had an idea for another method that creates slices, with knowledge of only the previous slice, so you could create an infinite mondrian painting one slice at a time.
|
|
« Last Edit: August 30, 2010, 09:17:55 AM by Solved »
|
Logged
|
|
|
|
|
Nix
Guest
|
|
« Reply #16 on: August 30, 2010, 09:08:28 AM » |
|
I seem to have become very interested in this sort of stuff recently...
Have you played with Processing? I hear it's very good for computer art. I had an idea for another method that creates slices, with knowledge of only the previous slice, so you could create an infinite mondrian painting one slice at a time.
That could very cool. Then you could have a sort of fractal Mondrian painting that you can keep zooming into? The only thing is that Mondrian has lines that span multiple "slices", which is really the thing that the BSP method was missing. I think you should figure out how to have some consistency among adjacent slices like that. Bookmarked
|
|
|
Logged
|
|
|
|
Solved
|
|
« Reply #17 on: August 30, 2010, 09:17:52 AM » |
|
I have edited the subdivide method to create more mondrian like pictures, by making it more likely to choose white. I shouldn't need to post updated code for that. Screenshot 1Screenshot 2Screenshot 3Also I have coded up Nix's algorithm, it produces quite nice mondrian pictures. My code is really ugly and has magic numbers everywhere, because of rushing. Also doesn't prevent rectangles from being too small. Will fix these problems later. CodeScreenshot 1Screenshot 2Screenshot 3The lines that span multiple slices will work as the algorithm would know the previous slice, so it could carry on a line from the previous slice. This way the lines could span more than one slice. The main problem would be, the way I'm thinking of doing the slices, it could be infinite, but only in one direction, the other would have to be finite.
|
|
« Last Edit: August 30, 2010, 09:23:29 AM by Solved »
|
Logged
|
|
|
|
nikki
|
|
« Reply #18 on: August 31, 2010, 03:09:45 AM » |
|
You should read about A. Michael Noll .. great link! I've found this pdf by him too, wich is about generating Mondrians procedurally (in 1964) thanks again oh and i like your new screenshots very much Solved, i think they look more like the specific originals (the very early not so famous Mondrians) especcially when they all would be colored in that simple pallet that is I'm trying some things myself too, but its not yet in a showable stateedit:
|
|
« Last Edit: August 31, 2010, 05:22:12 AM by nikki »
|
Logged
|
|
|
|
Sigma
|
|
« Reply #19 on: September 05, 2010, 09:13:25 PM » |
|
try quadtree
|
|
|
Logged
|
|
|
|
|