MathGroup Archive 2010

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

Search the Archive

Re: overimpose graphics on an imported image

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106134] Re: overimpose graphics on an imported image
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Sat, 2 Jan 2010 05:06:44 -0500 (EST)
  • References: <hhkj8f$566$1@smc.vnet.net>

Hi Allessandro,

The overlay being unrasterized is scaled to the dimensions of the
first graphic and then rasterized. That explains what you see.

I find the behaviour of ImageCompose a bit unexpected. From the
documentation ("ImageCompose[image,obj] overlays obj pixel-by-pixel
onto image, without changing the size of obj. ") I understand that if
the overlay is rasterized its size isn't changed, but it seems it is.
The positioning commands don't seem to work as expected as well:

{Lx, Ly} = {100, 100};
i1 = Rasterize[
  Graphics[{Yellow, Rectangle[{0, 0}, {1, 1}]}, ImagePadding -> None,
   PlotRangePadding -> None], RasterSize -> {Lx, Ly},
  ImageSize -> Round[{Lx, Ly}]]
i2 = Rasterize[
  Graphics[Rectangle[{0, 0}, {1, 0.5}], ImagePadding -> None,
   PlotRangePadding -> None], RasterSize -> Round[1/2 Lx],
  ImageSize -> Round[1/2 Lx]]
i1 // ImageDimensions
i2 // ImageDimensions
ImageCompose[i1, i2, {Left, Bottom}, {Left, Bottom}]

Cheers -- Sjoerd

On Jan 1, 12:37 pm, "alexxx.ma... at gmail.com" <alexxx.ma... at gmail.com>
wrote:
> hi people,
> I wonder if it is just me being dumb, but I'm unable to perform what I
> thought was a very simple operation:
>
> having imported an image of (Lx,Ly) pixels, draw above it an empty
> rectangle at coordinates (x0,y0) (x1,y1) (say, lower left and upper
> right corners).
>
> Say for example that I want to overimpose on image i1 a rectangle
> covering a 10% portion, if I use this:
>
> ImageCompose[i1, Graphics[Rectangle[{0, 0}, {0.1*Lx, 0.1*Ly}]]]
>
> I have (apart from a filled rectangle instead of empty, but I can deal
> with it later)
> a huge rectangle covering all of it!
> How these coordinates interact?
>
> Thanks for any help...
>
> Alessandro Magni



  • Prev by Date: Re: Re: Re: Re: algebraic numbers
  • Next by Date: Re: Re: Replace and ReplaceAll -- simple application
  • Previous by thread: Re: overimpose graphics on an imported image
  • Next by thread: Re: List to Expression