PDA

View Full Version : Efficient way to store images for processing?


davidhorman
17th May 2007, 20:27
Hello,

I've written myself a library full of useful and esoteric C functions for manipulating images. Unfortunately my little laptop is getting a bit slow for this sort of thing (1GHz), but although I'm looking at a new laptop, I'd also like to improve my library (last time I put my mind to it, I got a 4x speed increase out of it - mainly by replacing a=floor(x) with int a=x-(x<0)).

At the moment, I'm storing images like this:

struct image {
int w,h;
struct bitmap **pixel;
}

struct pixel {
unsigned char r,g,b;
}

and, for example, examining a pixel like this:

image->bitmap[x][y].r

And I was wondering if there was a more efficient/standard way. Can anyone point me in a faster direction?

Thanks,
David

Manao
20th May 2007, 09:05
It depends how often you have to consider R/G/B at the same time.

You could consider using instead three independent planes R, G, B. It would speed up spatial processing in which R, G and B are processed independently.

If it happens that R, G, B are too often used together, you may instead use a luma/chroma colorspace, in order to try to remove some dependency and R, G and B.