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: [mg84266] Re: Invert Black/White Colors of Binary Images
  • From: "Dana DeLouis" <dana.del at gmail.com>
  • Date: Mon, 17 Dec 2007 01:45:59 -0500 (EST)

As a side note, you can apply your "RandomSample" directly to your data.
DiscreteDelta is just another option to reverse 0/1's.

ReverseBits[m_] := Map[DiscreteDelta, m, {2}]

blackcolor = Table[1, {45}]; 
whitecolor = Table[0, {855}]; 
BlackWhite = Join[blackcolor, whitecolor]; 
image = Partition[RandomSample[BlackWhite], 30]; 
t1 = Graphics[Raster[image], Frame -> True]; 
t2 = Graphics[Raster[ReverseBits[image]], Frame -> True]; 

GraphicsArray[{t1, t2}]


I may be wrong, but I think Black is 0, and White is 1.

t = Range[0, 1, 1/10]; 
Graphics[Raster[{t}]] 

-- 
HTH   :>)
Dana DeLouis
Windows XP & Mathematica 6.0 


<Tara.Ann.Lorenz at gmail.com> wrote in message
news:fjnupg$fhc$1 at smc.vnet.net...
> 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
>



  • Prev by Date: Re: Re: Help needed with new Export (v. 6)
  • Next by Date: Re: ListPlot ignoring default options
  • Previous by thread: Re: Invert Black/White Colors of Binary Images
  • Next by thread: Plotting of Sin(x)/x