Re: [Gimp-developer] Hints on image reduction algorithm

On Monday, 11. February 2013 16:15:06 Vincent Cadet wrote:
> Hello people.
> I am looking for an algorithm to reduce a screen image to a very small size,
> e.g. 3x2 pixels width x height so as each pixel is the average colour (RGB)
> of the corresponding screen area.
> ...
> There are Arduino kits for the hardware part so I'm focusing on the software
> part right. Most algorithms I saw are screen grabbing and involve nested
> loops for each pixel and I'm sure there's a better way. (E.g. MMX
> instructions?) I thought of JPEG reduction since it corresponds to what I
> need if you keep only the average from the spectrum. So my question is: can
> the JPEG compression algorithm be effectively used and optimized to get
> that to work? Or if you have better ideas or hints, I'm open.

Hello Vincent,

first of all, you probably don't want to use GIMP for this task, I assume you
just write here because you guess that people here can answer anyway. :-)

What do you mean by nested loops?  Averaging over a (very) large number of
elements is not trivial, since you don't want to run into numerical precision
or overflow problems.

But all in all you probably don't want jpeg or other fancy and time-consuming
stuff, but just average the R, G and B components.  Your compiler should do
all the processor specific optimization for you anyway, I think.  In a few
little tests I did with XGetImage(...), most of the time was used by copying
the screenshot into memory, I ended up at around 30ms per image.

If you are looking for optimization: Reduce the resolution you work with (if
that's possible with your preferred screengrabber library), you won't see the
details in your 6 LEDs anyway ;-)  And reduce your framerate and simply
interpolate the color in between, your eyes probably won't see a difference.

Have fun with this project and show some photos later on!


Mein öffentlicher Schlüssel / My public key: 4096R/600ACB3B 2012-04-01
Fingerabdruck / Fingerprint:
9902 575B B9A0 C339 CFDF  250B 9267 CA6B 600A CB3B
Runterladen z.B. bei/ Get it e.g. from:,,,, ...

Attachment: signature.asc
Description: This is a digitally signed message part.

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