R without Hadley Wickham

Tim Hopper asked on Twitter today:

#rstats programming without @hadleywickham’s libraries is like ________ without _________.

Some of the replies were:

  • (skydiving, a parachute)
  • (gouging your own eyes out, NULL)
  • (dentistry, anesthesia)
  • (shaving, a razor)
  • (Internet shopping, credit card)

Clearly there’s a lot of love out there for Hadley Wickham’s R packages. I’m familiar with his ggplot2 graphics package, and it’s quite impressive. I need to look at his other packages as well.

Interview with Michael Hammel, author of The Artist’s Guide to GIMP

Michael J. Hammel is the author of The Artist’s Guide to GIMP, a book I reviewed three weeks ago. The following interview is based on my correspondence with Michael.

 

JC: The bio on your book says that you are an embedded software developer. Is GIMP something you use for fun or is it related to your work? Was it related to your work before?

MH: I use it once in awhile at work but not often. GIMP started as something related to what I worked on when it first came out (graphics software for Unix systems). But I’ve never been paid to be an artist. At one point I looked at trying to use what I knew about it to leverage my way into Pixar or Dreamworks. But that never panned out and my interest in that kind of animation has peeked and ebbed, mostly because I decided I didn’t want to live in California (too expensive).

JC: How did you become involved in the development of GIMP?

MH: When GIMP was born, back around 1995 or so, I was working for a company that provided commercial X servers for Unix systems (Xi Graphics, started by Thomas Roell who wrote the original reference implementation of an X server for 386 systems, aka X386, which begot XFree86 which begot X.org). I packaged Motif as part of my work. A guy I worked with noticed GIMP’s Motif version and pointed me at it. I wrote a plugin for John Beale’s sparkle code (the original Sparkle plugin). I’ve been working with GIMP ever since.

JC: Are you still a developer for GIMP or primarily a user?

MH: A user. I haven’t provided any useful code development to the project in quite sometime.

JC: What’s it like to be a developer on GIMP?

MH: Take this with a grain of salt. It’s a follower’s view from the outside, without being involved with the developers directly.

GIMP’s developer community is somewhat different than other open source communities that I’ve been involved with. GIMP’s leadership is de facto, but not necessarily structured. Many other projects have defined leaders with defined tasks. GIMP’s development is a little more oriented towards scratching your own itch: pick something that that you want to improve and start working on it. The only tough part (at least for some) is understanding and adhering to the main developers coding styles and rules, which are not (to my knowledge) written down.

My only complaint with this style is it tends to allow long term development cycles. End users can’t rely on when new features might be available. While the developers want do things “the right way”, that means that users have been waiting a very long time, for example, for deep paint support. There is a tradeoff for how you do development. Remember that the developers are volunteers, so there is no valid reason for complaining if you, as a user, aren’t getting what you want when you want it. If it bothers you, step in and help out. Otherwise, do as I do: be content with their development process.

JC: What advice would you give people who want to learn image editing?

MH: I learned how to use GIMP by reading Photoshop texts. Image editing is a common set of processes. Think about what you want to do if you weren’t using software. You’re house needs a new color? You mask off the window boarders and roof line and start painting. Same thing in image editing. Only difference: it’s easier to try different colors. Image editing is all about selections and masks. I’m not talking about creating the next Marvel comic, I mean editing existing images. Once you identify what needs to be changed using a selection and mask, you can do all kinds of things: copy and distort, recolor, refocus, etc.

Making comics or custom drawings requires real artistic talent to create a rough design on paper, then import (via scanner or digital camera) into GIMP for cleanup and coloring.

Personally, I prefer taking photos and mixing them together to create a scene that otherwise wouldn’t exist. There is a small example of this in the book. A photo of a city skyline as it exists and a munged version I created to make the city look decayed and falling apart. Beats me what people think of that image, but the creative process that went into it was very relaxing.

JC: What advice would you give people who want to learn GIMP in particular?

MH: Buy my book. Seriously. You learn both at the same time: what is image editing and how do you do it with GIMP. GIMP is just like any other desktop software. You learn where the menus are and what the various windows provide. The rest of your time is learning process — creating a workflow to produce a specific image type or style.

JC: What other software do you use/recommend for creating graphics?

MH: I use simple viewers like Geeqie for browsing images, but if you’re into photography you’ll nee something like f-spot. Photographers, who are nuts about image quality, should learn ufraw. Those interested in 3D or animation should take a look at Blender.

JC: Do you want to say anything about your work with embedded development?

MH: It’s my primary focus in life these days. I’m working on creating a custom media-focused Linux distribution (which I call BeagleBox) for the BeagleBoard C4 (and later the xm). I’d like to get my hands on the Raspberry Pi but wasn’t able to place an order when they first went on sale.

Embedded work is the future for Linux. The desktop for non-techies might change to tablets or such, but Linux will be in everything: your fridge, your TV, your car, your electrical system, your water and sewage systems, your phone, you’re neighbors who are flying robotic UAVs to peek in your windows. Everything.

My day job is building a radar system for UAVs (the big ones) that use embedded Linux to run out of flash. But the direction of interest is smaller devices, little boards with processors and memory in one, like the Pi or BeagleBoard, that can sense the environment and communicate to the rest of the household, with one of those devices used to display all the info on a big wall, removing the need for specialized devices just for the purpose of display.

Anyway, I’m really into making my own custom distribution based on Crosstool-NG (for cross compiling), u-boot (bootloader), Buildroot/Busybox (for root filesystems) and of course Linux.

The Artist’s Guide to GIMP

Learning how to edit images has been on my to-do list for a long time. I do some very basic editing with Paint.NET, but I keep meaning to learn to use GIMP.

I heard years ago that GIMP is terribly complicated and that I should learn Photoshop instead. I tried Photoshop—not extensively, but I spent some time with it—and I tried GIMP. My conclusion was that image editing is complicated. Image editing software is complicated, but not unnecessarily so. If you expect image processing to be as easy as word processing, as I suppose I implicitly did, your expectations are unrealistic.

The only way I’m going to learn image editing is by doing it. But a book can help, and I expect The Artist’s Guide to GIMP will help more than other GIMP resources I’ve read. That’s because this book puts a little more emphasis on problem solving strategies and techniques and a little less emphasis on software features. As Michael Hammel says in the introduction,

This is a book about process, not buttons or menu paths. … Don’t get bogged down in the mechanics of the tool. Focus on the task at hand. I’ll point you to the GIMP components necessary to finish the job.

The first chapter is about tools more than process, but I suppose some of that is inevitable at first. The rest of the book really is more about process. And there’s plenty of information about buttons and menu paths, but the book is organized by task and process comes before tool details. This is what I want from a book. I can read online documentation, but that documentation won’t tell me what I ought to be looking up. I look to books to get me started in the right direction.

The Book of Inkscape

When I first started using Inkscape, I read Inkscape: Guide to a Vector Drawing Program by Tavmjong Bah, 3rd edition. It’s now in its 4th edition, which I have not seen.

I received a copy of The Book of Inkscape by Dmitry Kirsanov recently, and it looks like the book I would have preferred to start with. Both books are fine introductions, but Kirsanov’s book is more my style.

Bah’s book is more inductive. It teaches you the elements of Inkscape by first taking you through a series of projects. Kirsanov’s book is organized more like a textbook or a reference. Some people would prefer Bah’s book, especially if it were their intention to work through all the exercises. I prefer Kirsanov’s book, organized more by topic than by project. It’s easier to dip in and out of as needed.

I’d like to learn Inkscape well. I could imagine going through a book slowly, carefully working all the examples, exploring side roads, etc. But that’s not realistic for me any time soon. For now, I expect I’ll learn more about Inkscape just-in-time as I need to make illustrations. And Kirsanov’s book is better suited for that.

More Inkscape posts

Thoughts on the new Windows logo

I appreciate spare design, but the new Windows logo is just boring.

Here’s the rationale for the new logo according to The Windows Blog:

But if you look back to the origins of the logo you see that it really was meant to be a window. “Windows” really is a beautiful metaphor for computing and with the new logo we wanted to celebrate the idea of a window, in perspective. Microsoft and Windows are all about putting technology in people’s hands to empower them to find their own perspectives. And that is what the new logo was meant to be. We did less of a re-design and more to return it to its original meaning and bringing Windows back to its roots – reimagining the Windows logo as just that – a window.

Greg Hewgill had a different perspective:

If you think about it, the new logo sort of looks like deck chairs on the Titanic when it stern was up in the air…

2010 calendar of lost mathematical art

Rod Carvalho wrote a post this morning announcing a beautiful 2010 calendar created by Ron Doerfler. Doerfler’s blog is entitled Dead Reckonings: Lost Art in the Mathematical Sciences. The calendar is an example of such lost art. It is illustrated with nomograms, ingenious ways of computing with graphs before electronic calculators were common. The illustrations are pleasant to look at even if you have no idea what they mean.

Image via Ron Doerfler.

Related posts

Spherical trig is a lost art. Why care about spherical trig?

The Gudermannian function gd(x) is another interesting relic of an early time. It is closely related to the Mercator projection and shows how to relate ordinary and hyperbolic trig functions without using complex numbers.

The image above shows solutions to the equation u + v + w = uvw. Here’s a post explaining the significance of that equation.

Including LaTeX in an Inkscape drawing

My previous post described how to include an Inkscape drawing in a LaTeX document. This post describes how to use LaTeX in an Inkscape drawing, which is probably more useful. The LaTeX output is included not as bitmap but as a vector drawing that can then be manipulated with all the features of Inkscape.

labeled triangle

The Inkscape book describes the InkLaTeX extension, but the website for InkLaTeX recommends a newer extension textext. Once textext is installed, you can insert LaTeX into an Inkscape drawing by going to the Extensions menu and selecting “TeX Text”. This launches a window in which to type your LaTeX source.

Before I could install textext, I had to install pstoedit. The textext extension also requires LaTeX and Ghostscript, but these were already on my computer. pstoedit has several installation options; I chose the default basic option and that worked. Also, pstoedit says that it requires two Visual C++ runtime DLLs: msvcr70.dll and msvcp70.dll. I already had these, but the pstoedit site gives a link to where you can find these DLLs if you need them.

I had Inkscape running when installed textext and I had to restart Inkscape to see the “TeX Text” menu.

Related post: Including an Inkscape drawing in LaTeX

Including an Inkscape drawing in LaTeX

The Inkscape drawing package can export to a large variety of vector drawing formats, including LaTeX. If you save your drawing to a file foo.tex, you can include the file in a LaTeX document as follows.

\documentclass{article}
\usepackage{pstricks}
\begin{document}
Testing Inkscape \LaTeX\ output.

\input{foo.tex}

\end{document}

Of course you could always export the drawing to an image format and include that image the way you’d include any other image. But you also have the option of directly including the content Inkscape output in your LaTeX file rather than referencing it as an external file using the input statement. This makes your LaTeX file self-contained and is something you could not do, for example, with a PNG file.

Two notes:

  1. You must use the pstricks package.
  2. You must compile the file with latex and not pdflatex. To create a PDF file, you must first compile to PostScript.

The next post is a sort of opposite of this one. It explains how to use LaTeX inside an Inkscape drawing.

Function plots in Inkscape

Why would you want to plot a mathematical function using a drawing package like Inkscape rather than a mathematical package like Mathematica or R? One reason is that you may want plot for its visual properties. For example, you might want to include a sine wave in a drawing.

Another reason is that you may want to have more control (or at least easier control) over your plot. Mathematical packages make it easy to produce a basic plot with default options. But I’ve found it difficult to change the aesthetics of a plot in every mathematical package I’ve used. The things I want to do are often possible but require arcane options that I have trouble remembering. In a drawing program, it’s obvious how to manipulate a plot as an image.

butterfly curve

Inkscape provides a couple extensions to include function plots in a drawing. One is “Function Plotter” and the other is “Parametric Curves.” Both are found under Extensions -> Render. The following dialog shows the settings used to produce the graph above.

The first time I tried using these extensions nothing happened. Then I discovered you have to select a rectangle to contain the plot before creating a plot; the plotting tools do not create their own rectangles.

The Function Plotter supports rectangular and polar coordinates. You’re in for quite a surprise if you expect rectangular coordinates when the polar coordinates box is checked.

Bezier basics

Bézier curves are very common in computer graphics. They also interesting mathematical properties. This post will give a quick introduction to Bézier curves, describing them first in visual terms and then in mathematical terms.

There are different degrees of Bézier curves: linear, quadratic, cubic, etc. Linear Bézier curves are just straight lines. The most common kind of Bézier curve in drawing programs is the cubic and that’s the one I’ll describe below.

Bezier curve

A cubic Bézier curve is determined by four points: two points determine where the curve begins and ends, and two more points determine the shape. Say the points are labeled P0, P1, P2, and P3. The curve begins at P0 and initially goes in the direction of P1. It ends at P3 going in the direction of a line connecting P2 and P3. If you move P1 further away from P0, the curve flattens, going further in the direction of P1 before turning. Similar remarks hold for moving P2 away from P3.

Now for equations. The cubic Bézier curve is given by

B(t) = (1-t)3 P0 + 3(1-t)2t P1 + 3(1-t)t2 P2 + t3 P3

for t running between 0 and 1. It’s clear from the equation that B(0) = P0 and B(1) = P3. A little calculation shows that the derivatives satisfy

B‘(0) = 3(P0P1)

and

B‘(1) = 3(P3P2).

Moving the points P1 and P2 further out increases the derivatives and thus makes the curve go further in the direction of these points before bending.

Related post: The smoothest line through a set of points