[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Faster image processing on the Mac



Jeff Banfield writes about reading and writing out image files on the Mac.

At Brown University, Heinrich Bulthoff and I teach an intro to
Computation for Cognitive Science using MACL, and one of the things
we do is image processing.  We found that that the most straight-forward
approach, where pixel values are represented by floats, to be almost
unusably slow and causing a lot of GCs.  I presume this is because
MACL can only store floats on the heap, so every floating point
result involves a memory allocation.

Representing pixel values by 8 bit integers doesn't produce the
GCs we experienced when using floats, but it is very slow, presumably
because the values must be packed and unpacked at each operation.

When we represented pixel values with 32 bit integers, and set the
appropriate optimization declarations, we obtained quite acceptable
performance, say only 5 times slower than a comparable C program.
We also tried using the FF interface, but since the 32 bit performance
was acceptable for our purposes we didn't go further.

It would be nice if 8 bit integer arithmetic could be speeded up
a bit, and I suspect it wouldn't be that hard to do.  It would
be nicer still if MACL's floating point arithmetic could be speeded up,
but I suspect that would be much harder.

Oh yes, if I recall correctly, we used Mac OS trap calls to do all
our input and output, speeding I/O performance considerably.

Mark