The Math Forum

Search All of the Math Forum:

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

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

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 1,416
Registered: 4/8/06
Re: Invert Black/White Colors of Binary Images
Posted: Dec 12, 2007 5:17 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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??

Work with (1 - image) or use the ColorFunction option of Raster.


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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.