4

How how would i generate an image of certain resolution containing black and white noise. I want to generate a number of images with each images noise being different. Prefer if done in console of either linux or windows but coding is ok if really have to. Cheers

dmonarch
  • 55
  • 1
  • 8
  • This can be done in pretty much any image processing tool or library out there... – Piglet Mar 27 '17 at 11:35
  • First select a resoultion, then loop the height and width, generate a random number, if it is above some given threshold, assign that pixel white color, else black. Simple. – Vivek Kumar Mar 27 '17 at 11:38
  • may be this QA might be interesting for you [avr code not working i want to generate random numbers help please](http://stackoverflow.com/a/29296619/2521214) – Spektre Mar 29 '17 at 09:38

1 Answers1

8

Like this with ImageMagick which is installed on most Linux distros and is available for macOS and Windows:

convert -size 512x512 xc:gray +noise random -colorspace gray noise.jpg

enter image description here

Replace convert with magick if using v7+ of ImageMagick.

If you mean pure black and white without shades of grey, and maybe would like a different size and a PNG format, use:

convert -size 600x400 xc:gray +noise random -colorspace gray -threshold 50% noise.png

enter image description here

If you want a different distribution of noise (gaussian, poisson, binomial) or to attenuate the noise, have a look at my other answer here.

Community
  • 1
  • 1
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432