MathGroup Archive 2007

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

Search the Archive

Re: image opacity/image overlaying?

  • To: mathgroup at
  • Subject: [mg80376] Re: image opacity/image overlaying?
  • From: AV <akvelu at>
  • Date: Mon, 20 Aug 2007 03:41:27 -0400 (EDT)
  • References: <f9p5ut$rm2$><f9s2gk$9gg$>

Thanks alot for the reply,

Your suggestion led me along the right direction and I got the effect
I was looking for.  I didn't realize that the Raster function, which
the Import function returns, returns a graphics primitive which can be
combined with other primitives unlike most of the other plotting
functions.  I ended up using the following to plot an overlay image
over a reference image, with a variable overlay threshold and alpha
value - here set to threshold 0.25 in a normalized image and alpha to

           	Graphics[Raster[refimage,ColorFunction -> "GrayTones"]],
           	Graphics[Raster[overlayimage, Automatic,
{Min[overlayimage],Max[overlayimage]},ColorFunction ->(OverlayColor[#,

With the following color function to allow thresholding of the overlay

OverlayColor[ z_ ,threshold_,alpha_] := If[z > (0.5-threshold) && z <
(0.5+threshold), Directive[Opacity[0],RGBColor[0,0,0]],

Thanks again.


On Aug 14, 6:09 am, "Mariusz Jankowski" <mjankow... at>
> This doesn't use ArrayPlot, but works for 2D image arrays. Given two images,
> for example,
> img1 = Import[
>   ""; ] ;
> img2 = Import[
>   ""; ] ;
> then this gives the desired result
> Show[{img1, Graphics[{Opacity[0.5], img2[[1]]}] }]
> Bye, Mariusz
> >>> On 8/13/2007 at 4:49 AM, in message <f9p5ut$rm... at>,
> AV<akv... at> wrote:
> > Is there a way of overlaying a partially transparent 2D image array on
> > another 2D image array using ArrayPlot or ListDensityPlot?  I am
> > currently using a workaround by making an array of transparent points
> > and showing this on top of a ListDensityPlot graphics but I wanted to
> > check if there was a better way since this is very slow.
> > AV

  • Prev by Date: But is it worth to use Mathematica ?
  • Next by Date: Re: image opacity/image overlaying?
  • Previous by thread: Re: image opacity/image overlaying?
  • Next by thread: Re: "formatting notebook contents" messages, why so many in Mathematica 6?