Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   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
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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

>



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.