Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Invert Black/White Colors of Binary Images
Replies: 5   Last Post: Mar 5, 2012 1:58 PM

 Messages: [ Previous | Next ]
 dh Posts: 1,273 Registered: 2/23/05
Re: Invert Black/White Colors of Binary Images
Posted: Dec 12, 2007 7:58 PM

Hi Tara,

simpliy replace 0 by 1 and vice versa:

image = image /. {1 -> 0, 0 -> 1}

hope this helps, Daniel

Anonymous wrote:

> Hi,

>

> I am using the following code to create black and white images with

> 5% black pixels and 95% white pixels:

>

> blackcolor = Table[1, {45}];

> whitecolor = Table[0, {855}];

> arrayvalues = Join[blackcolor, whitecolor];

> randompermutation := RandomSample[Range[1, 900]];

> image := Partition[arrayvalues[[randompermutation]], 30];

> t1 = Graphics[Raster[image]]

>

> How can I invert the coloring to have 5% white and 95% black??

>

> Thank you,

> Tara

>

Date Subject Author
12/12/07 Guest
3/5/12 szhorvat@gmail.com
3/5/12 Jens-Peer Kuska
3/5/12 dh
12/14/07 szhorvat@gmail.com
3/5/12 Dana DeLouis