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

Problems with changing layer mode in scheme

This discussion is connected to the gimp-user-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.

5 of 5 messages available
Toggle history

Please log in to manage your subscriptions.

Problems with changing layer mode in scheme Ken Moffat 18 Apr 23:22
  Problems with changing layer mode in scheme Pat David 18 Apr 23:41
   Problems with changing layer mode in scheme Ken Moffat 18 Apr 23:56
    Problems with changing layer mode in scheme Ken Moffat 21 Apr 02:10
     Problems with changing layer mode in scheme Ken Moffat 29 Apr 20:19
Ken Moffat
2017-04-18 23:22:53 UTC (over 7 years ago)

Problems with changing layer mode in scheme

Hi,

sorry for the long intro, but I tend to believe that context is important.

When I have the time, I'm gradually trying to 'process' raw photos I've taken in the past. A brief overview is: select a base exposure and two others for shadows and highlights (typically ±2EV), put those in layers with masks, remove the masks, merge down. After that I do visual correction (lens distortion, rotation, perspective distortion) and then things like tone mapping and sharpenbing.

I got back to this a few monbths ago and discovered that although it sounds obvious to use the base image ("correct exposure") to create the masks - i.e. what is dark in that, rather than in the overexposed shadow layer, should be retrieved from the shadow layer, and vice versa - I got horrible results. Eventually I found out about "lighten only" and "darken only" layer modes.

So, I now have enough confidence in that approach to try using it. But I still need to make decisions about which exposures to use, and what other things to do, so each picture still takes a long time. But the "merge three exposures" part is one of hte slowest parts of hte process and is more likely to work well when scripted: from time to time I do something wrong when I do it manually.

I found load_for_hdr_0.scm which appears to be doing similar things to what I want to do, so I've been trying to hack on it. This is with gimp-2.8.20, I'll give it a go in my machine running once it seems to work. Hmm, for those of us without a CS background, scheme/lisp is hard. I've been trying to set the layer mode in the appropriate part of my fork of that script.

It started out before my changes as -

(define (process-single-image dest-image
source-image
dest-layer-name
desaturate-option
invert-option
blur-radius)
(let* (
(layer (copy-image-as-new-layer dest-image source-image)))
(gimp-layer-set-name layer dest-layer-name) (gimp-desaturate-full (car (gimp-image-get-active-drawable source-image)) desaturate-option)
...

First I tried adding dest-layer-mode after dest-layer-name in the definitions, and passing LIGHTEN-ONLY-MODE (that is, 10) after the layer name, then adding

(gimp-layer-set-mode layer dest-layer-mode)

after gimp-layer-set-name, but I got an error from the following gimp-desaturate-full :

Error: ( : 1) Procedure execution of gimp-desaturate-full failed on invalid input arguments: Procedure 'gimp-desaturate-full' has been called with value '10' for argument 'desaturate-mode' (#2, type GimpDesaturateMode). This value is out of range.

That puzzles me, the parameters were in order, but I tried to work around it by moving dest-layer-mode to the last parameter, after blur-radius. That ran without error, but the added layers are still in normal mode. :-(

I'm also at a loss about how to debug this - the examples I can find are all pretty short, this script (ignoring comments) is all-but 100 lines, and I don't seem to be able to paste into the script-fu window (running xfce on this machine).

Any suggestions, please ? (Other than using Python - I prefer to build from source, the impenetrable deps in some Python scripts annoy me, and taking a quick look at two very-long Python scripts which appear to be for this sort of use I found their code totally impenetrable, and they did not come close to doing what I wanted).

ĸen

`I shall take my mountains', said Lu-Tze. `The climate will be good
for them.'     -- Small Gods
Pat David
2017-04-18 23:41:22 UTC (over 7 years ago)

Problems with changing layer mode in scheme

I'm not near my machine to test your script (but can have a look tomorrow). In the meantime, have you seen the tutorial on doing Luminosity masks?

https://www.gimp.org/tutorials/Luminosity_Masks/ On Tue, Apr 18, 2017 at 6:31 PM Ken Moffat wrote:

Hi,

sorry for the long intro, but I tend to believe that context is important.

When I have the time, I'm gradually trying to 'process' raw photos I've taken in the past. A brief overview is: select a base exposure and two others for shadows and highlights (typically ±2EV), put those in layers with masks, remove the masks, merge down. After that I do visual correction (lens distortion, rotation, perspective distortion) and then things like tone mapping and sharpenbing.

I got back to this a few monbths ago and discovered that although it sounds obvious to use the base image ("correct exposure") to create the masks - i.e. what is dark in that, rather than in the overexposed shadow layer, should be retrieved from the shadow layer, and vice versa - I got horrible results. Eventually I found out about "lighten only" and "darken only" layer modes.

So, I now have enough confidence in that approach to try using it. But I still need to make decisions about which exposures to use, and what other things to do, so each picture still takes a long time. But the "merge three exposures" part is one of hte slowest parts of hte process and is more likely to work well when scripted: from time to time I do something wrong when I do it manually.

I found load_for_hdr_0.scm which appears to be doing similar things to what I want to do, so I've been trying to hack on it. This is with gimp-2.8.20, I'll give it a go in my machine running once it seems to work. Hmm, for those of us without a CS background, scheme/lisp is hard. I've been trying to set the layer mode in the appropriate part of my fork of that script.

It started out before my changes as -

(define (process-single-image dest-image
source-image
dest-layer-name
desaturate-option
invert-option
blur-radius)
(let* (
(layer (copy-image-as-new-layer dest-image source-image)))

(gimp-layer-set-name layer dest-layer-name) (gimp-desaturate-full (car (gimp-image-get-active-drawable source-image)) desaturate-option)
...

First I tried adding dest-layer-mode after dest-layer-name in the definitions, and passing LIGHTEN-ONLY-MODE (that is, 10) after the layer name, then adding

(gimp-layer-set-mode layer dest-layer-mode)

after gimp-layer-set-name, but I got an error from the following gimp-desaturate-full :

Error: ( : 1) Procedure execution of gimp-desaturate-full failed on invalid input arguments: Procedure 'gimp-desaturate-full' has been called with value '10' for argument 'desaturate-mode' (#2, type GimpDesaturateMode). This value is out of range.

That puzzles me, the parameters were in order, but I tried to work around it by moving dest-layer-mode to the last parameter, after blur-radius. That ran without error, but the added layers are still in normal mode. :-(

I'm also at a loss about how to debug this - the examples I can find are all pretty short, this script (ignoring comments) is all-but 100 lines, and I don't seem to be able to paste into the script-fu window (running xfce on this machine).

Any suggestions, please ? (Other than using Python - I prefer to build from source, the impenetrable deps in some Python scripts annoy me, and taking a quick look at two very-long Python scripts which appear to be for this sort of use I found their code totally impenetrable, and they did not come close to doing what I wanted).

ĸen --
`I shall take my mountains', said Lu-Tze. `The climate will be good for them.' -- Small Gods
_______________________________________________ gimp-user-list mailing list
List address: gimp-user-list@gnome.org List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list List archives: https://mail.gnome.org/archives/gimp-user-list

Ken Moffat
2017-04-18 23:56:41 UTC (over 7 years ago)

Problems with changing layer mode in scheme

On Tue, Apr 18, 2017 at 11:41:22PM +0000, Pat David wrote:

I'm not near my machine to test your script (but can have a look tomorrow). In the meantime, have you seen the tutorial on doing Luminosity masks?

https://www.gimp.org/tutorials/Luminosity_Masks/

Thanks for that link, it looks good (at least for landscapes), but seems even more involved than what I'm currently doing. But like a lot of the things I've found when googling, it's all hands-on and I really want to save time by scripting this part of the process.

If anybody wants to look at my full script, the current version, with loads of comments - some out of date - is attached.

ĸen

`I shall take my mountains', said Lu-Tze. `The climate will be good
for them.'     -- Small Gods
Ken Moffat
2017-04-21 02:10:59 UTC (over 7 years ago)

Problems with changing layer mode in scheme

On Wed, Apr 19, 2017 at 12:56:41AM +0100, Ken Moffat wrote:

On Tue, Apr 18, 2017 at 11:41:22PM +0000, Pat David wrote:

I'm not near my machine to test your script (but can have a look tomorrow). In the meantime, have you seen the tutorial on doing Luminosity masks?

https://www.gimp.org/tutorials/Luminosity_Masks/

Thanks for that link, it looks good (at least for landscapes), but seems even more involved than what I'm currently doing. But like a lot of the things I've found when googling, it's all hands-on and I really want to save time by scripting this part of the process.

If anybody wants to look at my full script, the current version, with loads of comments - some out of date - is attached.

Small update:

First, just to clarify - the photos I particularly care about (mostly with a loss of shadow detail, some with blown highlights) are either buildings or trains, not good-looking landscapes in nice sunny conditions - all I want to do is get closer to what used to be possible (with film) when you paid for hand-printing.

The good news is that I'm making (very slow) progress, by stripping everything back to the basics (so no copied subroutines, and for the moment execute each function inline at the point I think it is needed. I got the console working enough to paste bits and pieces (after I realised the line I thought was for searching was for scheme input ;) and when it errors I can often find alternative approaches with the Browse button.

At the moment all I've managed is to get a second layer (for shadows, with lighten-only mode), and to drop the requirement for a drawable value (I started over copying something else) - strangely the dialog now has an empty long line below the field where I select the shadow image, which is annoying but not catastrophic. I still need to copy the initial image to a new layer for the mask, desaturate it, invert it, add a shadow mask and paste it. I'm sure I'll get a lot more heartache along the way, and the air here will frequently be blue, but I now have (a little) confidence that this is on the right lines. And then I need to do the highlights.

Maybe I'll be back to ask more questions. If not, I'll be back whenever I get it to "good enough". But as with everything else I do - don't hold your breathe ;-)

ĸen

Error: ( : 1) not enough arguments
Ken Moffat
2017-04-29 20:19:11 UTC (over 7 years ago)

Problems with changing layer mode in scheme

On Fri, Apr 21, 2017 at 03:10:59AM +0100, Ken Moffat wrote:

On Wed, Apr 19, 2017 at 12:56:41AM +0100, Ken Moffat wrote:

On Tue, Apr 18, 2017 at 11:41:22PM +0000, Pat David wrote:

I'm not near my machine to test your script (but can have a look tomorrow). In the meantime, have you seen the tutorial on doing Luminosity masks?

https://www.gimp.org/tutorials/Luminosity_Masks/

Thanks for that link, it looks good (at least for landscapes), but seems even more involved than what I'm currently doing. But like a lot of the things I've found when googling, it's all hands-on and I really want to save time by scripting this part of the process.

Actually, I found a link from what I think was another of Pat's pages, where there is a link to scm code.

If anybody wants to look at my full script, the current version, with loads of comments - some out of date - is attached.

Small update:

First, just to clarify - the photos I particularly care about (mostly with a loss of shadow detail, some with blown highlights) are either buildings or trains, not good-looking landscapes in nice sunny conditions - all I want to do is get closer to what used to be possible (with film) when you paid for hand-printing.

Progress report - in 2.8.20, it works. What I cannot discover is why I thought that using lighten/darken only, or masks from the base layer ("the correct exposure") seemed like a good idea when I was working in 2.9.4. Of course, I know why I did that - too much of everything, particularly with red subjects, when I used masks from the base layer in 2.9. So, for 2.8.20 it has renames such as "shadow image" for "lighter image", but I very much doubt it brings anything new and useful to the party. Attached. It appears in the Enhance filters menu and has the undo stuff wired-up so that you can just undo the whole filter at once.

FWIW, this works with *raw* images (xcf, png, probably tiff albeit with loads of warning or error messages from tiffs), and _my_ process follows up by correcting the merged layers (lens distortion, particularly on wide-angle lenses, perspective and/or rotation) before doing anything else.

Unfortunately, 2.9.4 is a different story. The layer modes now have -MODE added to their names (the numeric values still work), and the desaturate function I use is now deprecated (and the recommended replacement appears not to exist in 2.8). But after changing all that so that it runs cleanly in 2.9, on the first pic I was using (a train), the shadow layer ends up with almost nothing (a small part of the detail from below the carriage, nothing from the interior) and the highlight layer ends up with nothing at all. Possibly I'll come back to this and post here about it, but for the moment I don't see any indication that doing that will be productive.

Have a happy May Day.

ĸen

I live in a city. I know sparrows from starlings.  After that
everything is a duck as far as I'm concerned.  -- Monstrous Regiment