Today I've been thinking more about the galaxy generation, so I came up with an algorithm and implemented it. Here is how the algorithm works:
Load a target image of a galaxy
Divide the image into n by m cells
For each cell:
Sum the red, green and blue components of each pixel
Calculate the average
Divide by the maximum possible value (255 * width of n * height of m)
Store this value for this cell -> v
Calculate the rgb value for this cell with 255 * v
Generate a certain number of randomly placed pixels with the rgb value found in step 3.5, the number of pixels is a user specified number multiplied by v
No comments:
Post a Comment