It is currently 23 Oct 2021, 15:29

• Featuring Members' Works (Image Attachments) •
1: member
2: member
3: member
4: member
5: member

GIMP/GL:  Tutorials | Tips | Questions | Interests | 🡆 Script Requests
Recommendations:  Index | Top 10
Resources:  Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP
Sponsored content for World Food Program

Luminosity Mask Plug-in Speedup

Post your Script Requests for GIMP here.
Forum rules
Request your Script(s) for GIMP here in this forum.
Provide details of steps performed in GIMP so that script can be written for the process and also give the request a name so that scripts can be named after.
david
Forum Member
19th Place
281 Post(s)

Luminosity Mask Plug-in Speedup

Post#1 by david » 05 Oct 2021, 15:30


tim,

I have been playing with my equal luminosity mask plug-in. It is very slow for large images. By eliminating the need to create channels, eliminating layers as soon as no longer required and disabling undo, I have reduced the memory requirements by about 75%. It has also resulted in a slight speed increase, but not enough!

Is it possible that the technique shown in "Fast Pixel Ops in GIMP-Python" would work in this plug-in? I see that you used it in your "maskif" filter.

All my attempts to date have resulted in an infinite loop which I could only escape by closing GIMP.

This plug-in I use occasionally, but it is also part of my process of trying to learn gimp-python. That is why the listing is full of comments - in the hope of keeping myself on the straight and narrow!

david.
eq_lum_mask.py #
(6.58 KiB) Downloaded 27 times

tim
GL Blogger
1st Place
5553 Post(s)

Post#2 by tim » 07 Oct 2021, 11:13


It's doable if you know how to apply operations to pixels individually.
I don't know exactly how draw-spline-curves in your plug-in works so I am not sure how to do this manually using pixel operations.
aka Tin
World Food Program | Good Deeds Forum

         

david
Forum Member
19th Place
281 Post(s)

Post#3 by david » 07 Oct 2021, 15:36


tim,

Many thanks for the reply.
In slow time I shall check how long each part of the process takes, then starting with the slowest parts, I will try to incorporate the pixel operations. It all teaches me something about gimp python!

david
Forum Member
19th Place
281 Post(s)

Post#4 by david » 12 Oct 2021, 17:22


I have done some timing checks. If I load a 61 MB ,tif file (189.4 MB when loaded) running eq_lum_mask.py takes just under 30 seconds. The curves routine takes only about 8% of the total time.
However,
pdb.gimp_selection_all(image)
pdb.gimp_edit_copy(layer_copy1) which copy the image to a buffer takes more than 11% of the total and,
mask = pdb.gimp_layer_create_mask(layer_add, ADD_MASK_WHITE)
pdb.gimp_layer_add_mask(layer_add, mask)
floating_sel=pdb.gimp_edit_paste(mask,TRUE)
pdb.gimp_floating_sel_anchor(floating_sel)
pdb.gimp_item_set_visible(layer_add,TRUE)
pdb.gimp_selection_none(image) where it is pasted back and creates the mask takes about 21% of the total time - both together 32%.

So, this is where I need to find how to save time. It would appear that copy and paste are slow operations.

david
Forum Member
19th Place
281 Post(s)

Post#5 by david » 14 Oct 2021, 16:21


Just for reference.

I re-wrote the routine, making a channel to create the mask from. This is slower than cut & paste.
It is a pity that there doesn't appear to be a way of making a mask directly from a layer.

david
Forum Member
19th Place
281 Post(s)

Post#6 by david » 15 Oct 2021, 17:26


I have done a major re-write.
By creating a masked layer before going into the loop it has reduced the execution time for the same 61 MB .tif file from 30 seconds to 20 seconds. For a .jpg file of 270 KB it takes about 5 seconds.

I have attached the file and a PDF "Tutorial" describing its use.
eq_lum_mask.py #
(6.93 KiB) Downloaded 15 times
eqlumtut.pdf #
(148.89 KiB) Downloaded 21 times

david
Forum Member
19th Place
281 Post(s)

Post#7 by david » 17 Oct 2021, 13:40


The latest (and final!!!) versions are now in the GIMP Plug-ins thread with updated tutorials.


GIMP/GL:  Tutorials | Tips | Questions | Interests | 🡆 Script Requests
Recommendations:  Index | Top 10
Resources:  Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Post Reply New Topic
  • Similar Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 5 guests