Functional Images [Was: [plt-scheme] newbie - plotting points]

From: andrew cooke (andrew at
Date: Fri Jan 20 06:17:30 EST 2006

[Sorry Noel; sent first reply to you alone]

If you're interested in a more functional paradigm for images you might
look at Pan -

The idea is to represent images as functions.

Pan uses C code in places for speed - it's implemented as a language
embedded in Hakell that's somehow compiled via C (I can't remember the
details any more but there are papers at

I wrote a pure Haskell version because I wasn't that concerned about speed
and was frustrated with the limitations of the embeddded language.  It's
called Pancito and is available here -  Someone once put some
effort into speeding it up (using unboxed types, mutable arrays), but they
never gave me the code, unfortunately.

You can get an idea of the code from the literate source, which is also
the manual -

Some images of mine are here (not all use Pancito) -

The style of image you get with this approach is very different to DBN. 
DBN places much more emphasis on lines / boxes (things with hard edges);
with functional images it's very difficult to get a line, much easier to
vary things smoothly across the surface of the image.

For example this image -
- is defined using a function that shades a surface either side of a "fold
line"; the function is also a function of position/angle (of the fold). 
So the final image is defined by currying that function with random fold
points and then composing those curried functions to get a final transform
for the whole surface.  Computing that image at 6000x6000 took several
days on a 2MHz desktop a few years ago.

The lines in an image like this - - come from the
underlying plane that is transformed.  So that image is the result of
applying many functions to a plane that originally contained a single
(hard-edged) circle.

Since I'm already in an orgy of self links, here are the details of what I
ended up doing in scheme thanks to the help from people here (not pretty!
- just exploring numeric values)


Noel Welsh wrote:
> --- Danny Yoo <dyoo at> wrote:
>> Tangent question: has anyone looked at Design by Numbers?
>> I'm was curious what other PLT Scheme folks think about
>> it.
> Skimmed it in the bookstore, thought it was *very*
> imperative.  Seemed to concentrate on visualising the
> contents of a 2D memory -- which seems quite unrelated to
> what to me is the true nature of programming.  Was quite
> disappointed as John Maeda's other work has impressed me.
> But that's like 2 minutes flipping through the book.
> Should I look again?
> N.
> Email: noelwelsh <at> yahoo <dot> com   noel <at> untyped <dot> com AIM:
> Blogs:
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> _________________________________________________
>   For list-related administrative tasks:

Posted on the users mailing list.