Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: image is not graphics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110945] Re: image is not graphics
  • From: Maxim <m.r at inbox.ru>
  • Date: Tue, 13 Jul 2010 05:26:48 -0400 (EDT)
  • References: <i16vn8$ivv$1@smc.vnet.net>

On Jul 9, 6:04 am, Alessandro <alexxx.ma... at gmail.com> wrote:
> I have to admit that I'm really tired with Mathematica's assumption that
> "Image is not a graphics primitive or directive":
> I lost track of how many times I received that annoying error, due to
> this stupid internal dichotomy.
>
> At the moment I get the error since I'm trying to set in some way the
> output of the composition of two images with ImageSize, so I tried:
>
> Print[Graphics[ImageCompose[bi,   Graphics[Locator[{0, 0}, loc]],
> {nx/2 - b, ny/2 + a}], ImageSize -> 300]],
>
> Seems that I cannot put Graphics around ImageCompose, since the latter
> returns an image which <sarcasm> as we all know is not a Graphics
> object...  </sarcasm> so how do I use ImageSize?
>
> I'll be grateful to anybody who will help me here,
> but really this kind problem is happening more and more often - I
> believe that some rethinking of the graphics would be appreciated...
>
> thank you
>
> alessandro

You can either convert Image to Raster or put Image inside Inset:

img = Image[.5 - .5 DiagonalMatrix[ConstantArray[1, 190], 10, 200]]

Show[Image`ToGraphicsRaster@img,
 Graphics[{Red, Line[{{50, 160}, {150, 60}}]}],
 BaseStyle -> "ImageGraphics", ImageSizeRaw -> {200, 200}]

DynamicModule[{p = {50, 160}},
 Graphics[{Inset[img, Automatic, Automatic, 200],
   Inset[Dynamic@p, ImageScaled at {.75, .75}], {Red,
    Line[Dynamic@{p, p + {100, -100}}]}, Locator[Dynamic@p]},
  PlotRange -> {{0, 200}, {0, 200}}, ImageSize -> 200,
  BaseStyle -> "ImageGraphics", ImageSizeRaw -> {200, 200}]]

If you just need a locator, you can also use LocatorPane.

Maxim Rytin
m.r at inbox.ru


  • Prev by Date: Re: Fast pricer for American options
  • Next by Date: File names and strings
  • Previous by thread: Re: image is not graphics
  • Next by thread: Simple Question