RSS/Atom feed Twitter
Site is read-only, email is disabled

How to deal with pixel-per-pixel operations?

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

How to deal with pixel-per-pixel operations? Alessandro Francesconi 10 Jun 23:32
  How to deal with pixel-per-pixel operations? Øyvind Kolås 10 Jun 23:48
Alessandro Francesconi
2013-06-10 23:32:38 UTC (over 11 years ago)

How to deal with pixel-per-pixel operations?

Hello, I'm starting to write a GIMP plugin and I'm facing the problem of "pixel-per-pixel" algorithms and their speed. Without going on details, my algorithm should take every pixel in the image and for each one it must check its 24 neighbours, it does some simple calcs and finally it set a new color for the pixel.

How to speed-up the execution? I tried with the easiest approach with a classic "for-in-for" loop but the computation is really slow. Looking around, I've seen some GIMP functions like:

gimppixelfetcher Functions for operating on pixel regions. gimppixelrgn Functions for operating on pixel regions. gimpregioniterator Functions to traverse a pixel regions.

Can they help me? I can't actually understand well how they work because the GIMP-dev reference is incomplete in several parts... Is there, maybe, some code snippets or tutorial about this problem?

Thank you for your support, Ale

Øyvind Kolås
2013-06-10 23:48:44 UTC (over 11 years ago)

How to deal with pixel-per-pixel operations?

On Tue, Jun 11, 2013 at 1:32 AM, Alessandro Francesconi < alessandrofrancesconi@live.it> wrote:

Hello, I'm starting to write a GIMP plugin and I'm facing the problem of "pixel-per-pixel" algorithms and their speed. Without going on details, my algorithm should take every pixel in the image and for each one it must check its 24 neighbours, it does some simple calcs and finally it set a new color for the pixel.

How to speed-up the execution? I tried with the easiest approach with a classic "for-in-for" loop but the computation is really slow. Looking around, I've seen some GIMP functions like:

gimppixelfetcher Functions for operating on pixel regions. gimppixelrgn Functions for operating on pixel regions. gimpregioniterator Functions to traverse a pixel regions.

All of the above functions are considered deprecated; even when developing a GIMP plug-in and not a GEGL operation you would be encouraged to use GeglBuffer APIs (search for "gegl" in gimp's plug-in directories.). Though for a filter plug-in like you describe, the most proper way to do it now and for the future is to write a GeglOperation that derives from the provided GeglOperationAreaFilter like for instance:

https://git.gnome.org/browse/gegl/tree/operations/common/noise-spread.c

you'd probably want to fetch the entire neighborhood of the rectangular region being processed though; rather than doing like that particular plug-in which gegl_buffer_get's pixels one by one.

/pippin