GIMP Chat
http://gimpchat.com/

Saturation H M L plug-in
http://gimpchat.com/viewtopic.php?f=9&t=19670
Page 1 of 1

Author:  david [ Thu Oct 28, 2021 10:12 am ]
Post subject:  Saturation H M L plug-in

I have eventually produced a plug-in that others might find useful!
It creates three masked layers of different saturations, high, medium, and low. These allow largely independent adjustment of the saturation of the three layers.
I have frozen the undo stack to speed-up the operation and reduce memory usage.

It would be good to be able to undo the script with a "ctrl-z" and merge the layers with a key-press on completion, but this is way beyond my capability!

The only slight problem - when I run the script from the terminal, I get the error message "EEEEeEeek! 1 GeglBuffers leaked". I don't know if this is significant and I have been unable to find the source of the error.

Any comments, criticism, and advice are most welcome.

Attachment:
saturation_h_m_l.zip [2.54 KiB]
Downloaded 53 times


Attachment:
saturation_h_m_l_tut.zip [51.15 KiB]
Downloaded 69 times


Edit: The files have been updated to allow them to work with other languages. 29/10/2021.
Edit: Updated to latest version of plug-in - corrected error in script.
Edit: File updated to version 4 with options to select transition between masked layers.

Author:  Pocholo [ Thu Oct 28, 2021 10:56 am ]
Post subject:  Re: Saturation H M L plug-in

I tested an it's not giving any errors. There is no changes in the color of the image. The only thing that each layer with a mask does, it create a different Transparency in each one.

Author:  david [ Thu Oct 28, 2021 11:26 am ]
Post subject:  Re: Saturation H M L plug-in

Thanks for the reply.

The error only appears in the terminal.

By selecting a layer, the saturation of that layer can be adjusted using Colours/Saturation, without a substantial effect on the other two layers. This makes it possible to change the saturation in each of the three regions independently.

Perhaps I wasn't clear in my description.

Author:  MareroQ [ Thu Oct 28, 2021 12:14 pm ]
Post subject:  Re: Saturation H M L plug-in

Hi David.

A strange story.
It works in the English and French versions of Gimp.
It does not work in Italian and Polish. :gaah

Attachments:
HML2.jpg
HML2.jpg [ 23.53 KiB | Viewed 2482 times ]
HML1.jpg
HML1.jpg [ 92.47 KiB | Viewed 2482 times ]

Author:  ofnuts [ Thu Oct 28, 2021 2:00 pm ]
Post subject:  Re: Saturation H M L plug-in

Possibly due to "saturation_layer = pdb.gimp_image_get_layer_by_name(decomposed_image, 'saturation')" that will only work in some languages.

@david what is likely the same everywhere is the stack order, so instead of using names you can use "image.layers[position]" once you have figured out which of H, S, V correspond to 0, 1, 2.

Author:  david [ Thu Oct 28, 2021 2:26 pm ]
Post subject:  Re: Saturation H M L plug-in

ofnuts to the rescue as always!!!

I just reached the same conclusion while lying in the bath. Would you call that an Archimedes moment?

At the moment it decomposes to separate images, so all three are layer zero. So I will have to change it to decompose to layers and then saturation will be layer 1.

Edit: A quick look in a translate program shows that perhaps English and French are the only languages where it is the same.

Author:  david [ Fri Oct 29, 2021 4:52 am ]
Post subject:  Re: Saturation H M L plug-in

@MareroQ,
Thanks for your reply. I had not considered the language implications of getting images and layers by name. I made this plug-in for my own use (with much help from Tin Tran) and thought it may be useful for other people.

@ofnuts,
After more thought, I don't believe I can find a solution to the language problem. I could change a line to:

saturation_layer = image.add_layer(layer, 0) (Is this syntax correct?)

However, in the decompose image command it seems that the only way of using it is to specify "HSV". This will surely change depending what language is used. If there were alternative tokens/numbers for the various decompose-type it may be possible

At this point I have decided to give up on GIMP Python - I waste so many hours trying things and searching the internet for working examples!

Author:  MareroQ [ Fri Oct 29, 2021 10:32 am ]
Post subject:  Re: Saturation H M L plug-in

Hi David.

The Ofnuts solution works.
When do You exchange (on line 66) with:
saturation_layer = pdb.gimp_image_get_layer_by_name(decomposed_image, 'saturation')

on:
saturation_layer = image.layers[1]


David - Thanks for the very useful plugin. :bigthup
I am asking for more. :yes
I was confused too - but we have some smart coders. :clap :clap :clap

Author:  david [ Fri Oct 29, 2021 10:59 am ]
Post subject:  Re: Saturation H M L plug-in

MareroQ,

I am pleased that the plug-in now works and I hope it will be useful to you.

However, it still leaves me confused. The decompose statement at line 62 gets an image by name "HSV" and I find it strange that the abbreviation for Hue, Saturation & Value would remain the same in other languages.

Thanks for your help.

Edit: Files in #1 updated. 29/10/2021

Author:  MareroQ [ Fri Oct 29, 2021 11:13 am ]
Post subject:  Re: Saturation H M L plug-in

I did a test first - changed 'saturation' to 'nasycenie' - and it started working.
So HSV is immutable input - and GIMP is so smart that it translates the output names into different (appropriate) languages.
I learned so much today. :lol

Author:  david [ Fri Oct 29, 2021 12:00 pm ]
Post subject:  Re: Saturation H M L plug-in

MareroQ,

Thanks for your help. I have updated the files in entry #1 of this thread.

Out of curiosity, if you look at decompose in the procedure browser, in either the Polish or Italian versions of GIMP, does it show the English version - HSV - or is it translated?

Author:  MareroQ [ Fri Oct 29, 2021 12:32 pm ]
Post subject:  Re: Saturation H M L plug-in

Python Procedure Browser is translated to a very limited extent.

Attachments:
PPB.jpg
PPB.jpg [ 135.61 KiB | Viewed 2034 times ]

Author:  david [ Fri Oct 29, 2021 12:45 pm ]
Post subject:  Re: Saturation H M L plug-in

Thank you for that, it resolves my confusion!!!

Author:  david [ Sat Oct 30, 2021 5:38 am ]
Post subject:  Re: Saturation H M L plug-in

Apologies! I have had to correct the script. The latest change (line 73) was indexing the incorrect image.
Thanks to Krikor for finding the error.
I have checked with numerous photographs this morning and hopefully it is now OK.
The file at #1 of this thread has been updated.

Author:  david [ Tue Nov 02, 2021 10:42 am ]
Post subject:  Re: Saturation H M L plug-in

I have been experimenting with this plug-in. The version in #1 of this thread has a soft transition (overlap) between the high, medium and low saturation regions.
Having tried varying the amount of overlap on numerous photographs, I am undecided as to the best degree of overlap. So I have produced a version which gives a choice of three different transitions which I hope people will try and then give me feedback in order to make a plug-in which is of the greatest use.

The amount of overlap is infinitely variable by changing the curves which create the three regions (overall and within the individual regions).

I look forward to some comments, criticism and suggestions!

Attachment:
saturation_h_m_l_trial.zip [2.21 KiB]
Downloaded 41 times

Author:  MareroQ [ Wed Nov 03, 2021 3:33 am ]
Post subject:  Re: Saturation H M L plug-in

Hi David.

My preference is usually Soft - but it's very nice to have additional options now. Thanks for that. :bigthup
On minor matters: a bit of description, change of location in the (Colors) menu, NORMAL_MODE mode (works, but actually doesn't exist anymore). ;)

Attachments:
Example Info.png
Example Info.png [ 8.39 KiB | Viewed 1869 times ]

Author:  david [ Wed Nov 03, 2021 5:30 am ]
Post subject:  Re: Saturation H M L plug-in

MareroQ.

I have tried the plug-in on numerous photographs. While "soft" (the same as the original) works well on some pictures, I found that on others there was too much overlap between the different regions. I was hoping to find a compromise, hence the trial version. I think that the options menu of this version may be adding unnecessary complication to the plug-in.

As always, your opinion is appreciated.

Author:  david [ Thu Nov 04, 2021 6:09 am ]
Post subject:  Re: Saturation H M L plug-in

The general opinion is that it is useful for certain images to be able to select the transition between the masked layers. So I have updated the file in #1 of this thread to Version 4.

Any suggestions to improve this plug-in are always welcome.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/