[lug] Off-topic: Contour line in image problem

D. Stimits stimits at idcomm.com
Fri Dec 7 13:14:30 MST 2001


Glenn Murray wrote:
> 
> Yes, the appeal of using something like the Gimp is that it might make
> it easy to do manual manipulation of the image.  My question is the
> one Ralf Mattes hinted at: once I get the embossed or mouse-drawn line
> created, how do I get those pixels into a file of x,y coordinates?  At
> that point I can think about getting the line's length.

I would guess you'd need to know the details of a particular graphics
file format to go by pixels, and you'd need to know for certain the
zoom. The point of a spline (like Bezier) is that it has predefined
formulas, you merely throw in the control points and then you can
directly find any y coordinate for any given percent of the way between
start and end points.

I have not tested this, but PostScript is a human readable text file
(more or less, there are some tricks, like line endings have to be
preserved, and eps images are embedded bitmaps), renowned for use of
Beziers to create its scaleable fonts. So if Gimp is smart enough during
save as eps or ps (eps has a bitmap, but it is only for preview, it
still has postscript code) to keep hand-made curves as Bezier control
points instead of computing the final bits, then you have the exact
formula right in your PostScript file (in PostScript language, which is
a lot like an HP RPN calculator...HP fans would find PostScript
friendly). With the particular formula, you don't even need the bitmap
points or the image, you can reproduce the Bezier any time you want.

Should you save it as a regular bitmap image of some sort, I'd recomment
you check for the uncompressed formats that Gimp can save (or any app).
Octave (using gnuplot for graphics) can plot splines and such, so if you
can find a way to import a bitmap, then use it as the background of your
plots, you could manipulate the formula for the spline control points
directly, as well as save their output, and even do the final
calculations for sweeping or rotating. The problem there is that Octave
and gnuplot do not seem to offer an interactive mouse pick
mechanism...i.e., you couldn't deflect or model your spline (Bezier) via
the mouse.

An ideal solution would seem to be a program that allows the import of
an image of whatever format yours is in, then have a transparent alpha
channel directly over this, which does nothing but model a limited
subset of splines. Then save the spline data, and optionally have
packages for rotation or sweeping the splines. Such an app might not be
too hard if you used OpenGL/glut, maybe Qt has some extensions to also
make this easy. gtk+ has a widget available glarea, which could also be
used (I like C++ though, so I'd prefer Qt if I had to choose between Qt
and gtk+).

How much time do you have to finish this?

D. Stimits, stimits at idcomm.com

> 
> I'm thinking it might be wiser to do the whole thing in some package
> (e.g., Matlab), though I expect to lose the mousing.
> 
> But line integrals?  Laplace transforms?  The next time I teach Calc
> III I'm going to make you guys sit in.
> 
> Glenn Murray
> www.mines.edu/~gmurray/public_html/Welcome.html
> 
> On Thu, 6 Dec 2001, D. Stimits wrote:
> 
> > Rob Mohr wrote:
> > >
> > > Approximate or match profile to a curve function.  Then integrate to calc
> > > the area.  I would *guess* that cad programs such as AutoCad use a series
> > > of Laplace Transforms to do the same thing.
> > >
> > > Save for the challenge, and dusty math books, you can prolly get something
> > > via a perl library and a good Google search string.
> > >
> > > Rob Mohr (Iowa City, Iowa - Boulder, Colo )
> > > eof
> > >
> > > _______________________________________________
> > > Web Page:  http://lug.boulder.co.us
> > > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> >
> > Aha, that reminds me. If you have a drawing program that lets you draw
> > curves, most likely Bezier, then it might be possible to simply bring in
> > the bitmap (embossing would be an aid still), and manually draw a curve
> > to the outline. Then it might be possible at some point to save with
> > original Bezier specification in-tact. You'd then integrate along the
> > curve. Possibly there are existing applications (like octave) that know
> > how to directly find the line integral along the path of a Bezier (I
> > haven't searched). In any case, it is probably easy to emboss via Gimp,
> > and also easy to draw a curve free-hand, what you'd need to do is find a
> > way to get free-hand drawings and pixmaps mixed on the same application.
> > (and maybe scaling?)
> >
> > D. Stimits, stimits at idcomm.com
> > _______________________________________________
> > Web Page:  http://lug.boulder.co.us
> > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> >
> 
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug



More information about the LUG mailing list