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 ]
szhorvat@gmail.com

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.

--
Szabolcs



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.