Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Invert Black/White Colors of Binary Images

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84171] Re: Invert Black/White Colors of Binary Images
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Wed, 12 Dec 2007 05:14:27 -0500 (EST)
  • References: <fjnupg$fhc$1@smc.vnet.net>

Tara.Ann.Lorenz at gmail.com 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


  • Prev by Date: Re: Plotting of Sin(x)/x
  • Next by Date: NIntegrate bug in Mathematica 6?
  • Previous by thread: Invert Black/White Colors of Binary Images
  • Next by thread: Re: Invert Black/White Colors of Binary Images