I’m looking to make an image that’s just noise, maybe something like this:

(source: loriswebs.com)
Ideally I’d like to be able to change the colour as well. Any ideas on how to generate this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s fairly straightforward to generate random noise. You can accomplish this pretty easily with some of PHP’s image libraries, including the GD functions. I’m sure it would be similar in ImageMagick.
If you wanted to generate completely random noise, you could use random values for every color and every pixel. That might look something like this with GD:
Generates this:
However, the example image that you posted clearly doesn’t look like completely random color noise. It seems more like an arbitrary choice between one of two colors, either a somewhat-grey pixel or a somewhat-colored pixel. You could accomplish that more like this:
Generates this:
Your example seems a bit more complex still, with the pixels seeming to appear in small groups to produce a blockier appearance. You could emulate that by adjusting the loop logic if you wanted, or coloring small squares instead of individual pixels.
An interesting thing about this type of generation is that you can actually see the breakdown of the
rand()function on Windows platforms if you use it instead ofmt_rand(). Discernible patterns can develop in the noise due to limitations in that function/platform combination.