Re: Create random binary images

*To*: mathgroup at smc.vnet.net*Subject*: [mg83714] Re: [mg83637] Create random binary images*From*: "Maarten van der Burgt" <maarten.vanderburgt at icos.be>*Date*: Wed, 28 Nov 2007 05:51:29 -0500 (EST)

Tara, Try this whites = Table[1,{9*5}]; blacks = Table[0, {9*95}]; arrayvalues= Join[blacks, whites]; randompermutation := RandomSample[Range[1,900]]; image :=Partition[arrayvalues[[randompermutation]],30]; Graphics[Raster[image]] Each time you evaluate the last line you get a random 30x30 image with exactly 5% white pixels. Maarten Tara.Ann.Lorenz @gmail.com To: mathgroup at smc.vnet.net cc: 27/11/2007 Subject: [mg83637] Create random binary images 12:05 Hello, I am trying to create several random binary images of 30x30. I want the outputs to be 1's and 0's, with 5% of the outputs being 1's. Any ideas on how to code this in Mathematica? Thanks! Tara