MathGroup Archive 2012

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

Search the Archive

Re: Drawing on an image in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126387] Re: Drawing on an image in Mathematica
  • From: JUN <noeckel at gmail.com>
  • Date: Sun, 6 May 2012 03:23:53 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jnven4$8ee$1@smc.vnet.net> <jo0avr$cb2$1@smc.vnet.net>

On Friday, May 4, 2012 3:28:11 AM UTC-7, JUN wrote:
> On Thursday, May 3, 2012 7:25:40 PM UTC-7, Julian Francis wrote:
> > Dear all,
> >
> > I have a binary image in which I'd like to use the mouse to draw
> > (freehand) on top of the image, and use this in Mathematica.
> >
> > Presently, I can import the image into a painting program, use its
> > sketching facilities, then cut and paste into Mathematica. I can
> > extract the matrix if I wish by using ImageData.
> >
> > Is there a way of drawing on the image directly in Mathematica to save
> > me cutting and pasting between programs?
> >
> > I've worked out how to create a graphic and draw into it using the
> > Mathematica graphics drwaing tools, but my problem is either the
> > graphic is far too large, or if I shrink it down
> > (I want to work on matrices 16x16), the resulting picture is far too
> > small. I want to draw into a matrix 16x16, but it be large enough for
> > me to see easily.
> >
> > Thanks,
> > Julian.
>
> The image has to be put into a Graphics box, and you can do that using the Inset command:
>
> im = RandomImage[1, {16, 16}];
> Graphics[Inset[im, Automatic, Automatic, Scaled[1]]]
>
> Here I've just used a random image and scaled it to fill the default Graphics width. Now you can double-click on the graphic and press Control-t to get the drawing tools, and they should work as you want.
>
> I think what you want to do after you're done editing is to convert the result back to an image. To do that, you could type:
>
> Rasterize[      , "Image", ImageSize -> 16]
>
> and copy the edited graphic from the previous cell back into the empty space I left in the Rasterize command. The result is again an image of the or iginal dimensions.
>
> Jens

Reading this again, I should clarify that you can also edit the image directly if you magnify it by dragging its outline manually, or doing Magnify[im,20] ... the Inset method above isn't the only way, I guess it's just the first thing that came to mind when you mentioned your own approach. 



  • Prev by Date: Re: New to Mathematica
  • Next by Date: Re: New to Mathematica
  • Previous by thread: Re: Drawing on an image in Mathematica
  • Next by thread: Re: Drawing on an image in Mathematica