Re: image opacity/image overlaying?
- To: mathgroup at smc.vnet.net
- Subject: [mg80376] Re: image opacity/image overlaying?
- From: AV <akvelu at gmail.com>
- Date: Mon, 20 Aug 2007 03:41:27 -0400 (EDT)
- References: <f9p5ut$rm2$1@smc.vnet.net><f9s2gk$9gg$1@smc.vnet.net>
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
0.75.
Show[{
Graphics[Raster[refimage,ColorFunction -> "GrayTones"]],
Graphics[Raster[overlayimage, Automatic,
{Min[overlayimage],Max[overlayimage]},ColorFunction ->(OverlayColor[#,
0.25,0.75]&)]]
}];
With the following color function to allow thresholding of the overlay
image.
OverlayColor[ z_ ,threshold_,alpha_] := If[z > (0.5-threshold) && z <
(0.5+threshold), Directive[Opacity[0],RGBColor[0,0,0]],
Directive[Opacity[alpha],ColorData["TemperatureMap"][z]]];
Thanks again.
AV
On Aug 14, 6:09 am, "Mariusz Jankowski" <mjankow... at usm.maine.edu>
wrote:
> This doesn't use ArrayPlot, but works for 2D image arrays. Given two images,
> for example,
>
> img1 = Import[
> "http://www.ee.usm.maine.edu/courses/ele489/data/cameraman.tif" ] ;
>
> img2 = Import[
> "http://www.ee.usm.maine.edu/courses/ele489/data/face.tif" ] ;
>
> 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 smc.vnet.net>,
> AV<akv... at gmail.com> 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