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

newbie: how to scan lines?

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.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

newbie: how to scan lines? balachandran c 27 Feb 11:49
  newbie: how to scan lines? Sven Neumann 27 Feb 13:24
newbie: how to scan lines? William Skaggs 27 Feb 18:44
balachandran c
2005-02-27 11:49:05 UTC (about 19 years ago)

newbie: how to scan lines?

hi all,

I am a newbie.

Q.1) I am writing a plugin which requires comparing one row of pixels with the one following it. Here is what I could think of,

iterate over pixel regions (width = image width, height = tile height): iterate over rows in current pixel region: do comparison;
cp the last row into buff for cmp with first row of next rgn

is that advisable? how should it be done?

Q.2) Could someone please point me to resources for making my plugin multithreaded?

One part of the algorithm involves quantizing the image, and the other involves user input. They are independent steps. Is it advisable to use one thread to launch the quantizing step, while the other waits for user input? I am planning to give a decent, default set of parameters for quantizing, and if the user is unhappy, he should be able to change it. Any suggestions?

Any help is welcome,

Thanks in advance,

Balachandran C.

Sven Neumann
2005-02-27 13:24:35 UTC (about 19 years ago)

newbie: how to scan lines?

Hi,

"balachandran c" writes:

Q.1)
I am writing a plugin which requires comparing one row of pixels with the one following it. Here is what I could think of, iterate over pixel regions (width = image width, height = tile height):
iterate over rows in current pixel region: do comparison;
cp the last row into buff for cmp with first row of next rgn is that advisable? how should it be done?

Why don't you just iterate over the image row by row? If you set the plug-in tile cache large enough, libgimp will take care of minimizing the amount of data that is being sent over the wire. Of course you can try to optimize this further but it will most probably not be worth it unless you are working on very large images and are low on memory.

Q.2)
Could someone please point me to resources for making my plugin multithreaded?

You can do that using gthread (part of GLib) but it is questionable if it's worth the effort. You would have to synchronize access to libgimp since libgimp isn't MT-safe.

One part of the algorithm involves quantizing the image, and the other involves user input. They are independent steps. Is it advisable to use one thread to launch the quantizing step, while the other waits for user input?

You could run the quanitization as an idle handler in the plug-in's main loop. You just need to split it into reasonably small chunks. That will probably be easier than a multi-threaded approach and it avoids the problems you would get with threads.

Sven

William Skaggs
2005-02-27 18:44:58 UTC (about 19 years ago)

newbie: how to scan lines?

Just to add a bit to Sven's response:

"balachandran c" writes:

I am writing a plugin which requires comparing one row of pixels with the one following it. . . . how should it be done?

There are lots of examples in the GIMP source that you can look at. Among the simplest is plug-ins/common/blur.c.

One part of the algorithm involves quantizing the image, and the other involves user input. They are independent steps. Is it advisable to use one thread to launch the quantizing step, while the other waits for user input?

Usually what I do in a situation like this is to have the time-consuming code at intervals execute a little chunk of code like this:

while (gtk_events_pending ()) gtk_main_iteration ();

This processes all Gtk+ events that have occurred since the last check, and then returns control to the function.

Best, -- Bill


______________ ______________ ______________ ______________ Sent via the CNPRC Email system at primate.ucdavis.edu