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

MathGroup Archive 2008

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

Search the Archive

Re: Drawing on top of the image

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85216] Re: Drawing on top of the image
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Sat, 2 Feb 2008 03:29:17 -0500 (EST)
  • References: <fnuhlu$9vg$1@smc.vnet.net>

?erých Jakub wrote:
> Does anybody have an idea, how to draw (lines) on top of the photo, which I
> import?
> 
> Exactly what I need is:
> image = Import["something.jpg"]
> imageData = Import["something.jpg",{"JPEG","GrayLevels"}]
> 
> Now I want to "slice" (with line) the image and work with the imageData on
> the "cut".
>  
> The question is, how to display the image together with the slicing line.
> 
> Thanks for any hint
> 
> Jakub
> 
I am assuming that you are using Mathematica 6.0.

One way to do this is to add the imported image as an Insert to another 
Graphics construction, however, since in your case, you probably want to 
preserve the natural pixel-based scale of the image, it may be better to 
use the fact that the result of the import is already a Graphics object, 
which you can manipulate. For example:

ss = Import["c:\\images\\bluemarble.jpg"];
ss[[1]] = {ss[[1]], Line[{{0, 0}, {100, 96}}]};
ss

Here I import an image file and ss looks like Graphics[Raster.....]...] 
with a PlotRange of {{0,100},{0,96}} - corresponding to the pixel size 
of the image.

Next, I replace the Raster construction with a list consisting of the 
Raster object, plus all the extra things I want to draw - in this case, 
one line - and send the result to the front end, where it displays as an 
image with a line drawn across it!

David Bailey
http://www.dbaileyconsultancy.co.uk




  • Prev by Date: Re: front end commands
  • Next by Date: Re: For Loop and NDSolve
  • Previous by thread: Re: Drawing on top of the image
  • Next by thread: Mathematica And Cron