Histogram adjustment script not behaving as expected

Moderator: Kathy_9

Post Reply
JoshuaJSlone
Posts: 2
Joined: Tue Jun 19, 2018 5:14 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Video Card: GTX 970
Corel programs: PaintShop Pro 2018

Histogram adjustment script not behaving as expected

Post by JoshuaJSlone »

I have tried to make a script for a simple histogram adjustment, where for all of R, G, and B the Low is set to 30 and the High to 238. Recording it went fine, but when I try to run the script I get very different results.

Looking at the saved script file I see the correct 30 and 238 settings are saved. I tried saving a variant where I cut out almost all the other settings it had automatically saved in case those were affecting things, but when I try this new slim script the result is just the same as the full one.

Here is what remains in the slim script:
from PSPApp import *

def ScriptProperties():
    return {
        'Author': u'',
        'Copyright': u'',
        'Description': u'',
        'Host': u'PaintShop Pro',
        'Host Version': u'20.00'
        }

def Do(Environment):

    # Histogram Adjustment
    App.Do( Environment, 'HistogramAdjustment', {
            'HistogramAdjustment': {
                'RedChannel': {
                    'HighClipLimit': 238, 
                    'LowClipLimit': 30, 
                    }, 
                'GreenChannel': {
                    'HighClipLimit': 238, 
                    'LowClipLimit': 30, 
                    }, 
                'BlueChannel': {
                    'HighClipLimit': 238, 
                    'LowClipLimit': 30, 
                    }, 
                }, 
            })
In the attached image: The left is original input. The center is where I've manually adjusted the histogram. The right is the result of running the script.
Attachments
histo2.png
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Histogram adjustment script not behaving as expected

Post by LeviFiction »

I have an idea, no guarantees but worth a try. But first some background

So, really quick, something about scripting. If you leave a parameter out of the script PSP will simply use the last known setting for that parameter. So your slimmed down script is still using those values even though you've cut them out. This is important because if you only leave them out and then manually use the command again, those values will be taken from the last time you used the command so you could end up with a huge variation in results because of that.

Some parameters accept the keyword - None

I don't have a valid description of what None does. It either tells the command to use its default value, or to ignore the value altogether. It could even be a mixture of both.

Not all parameters accept None but some do. Very specifically, in HistogramAdjustment, these parameters

'HighClipLimitPercentage': None
'LowClipLimitPercentage': None

I suggest giving this a try, in the full version of the script everywhere you see 'HighClipLimitPercentage' and 'LowClipLimitPercentage' change those values to None. And then see what happens.

In my own tests, if I simply record the script the images look different. I did a comparison and found that the green channel was off by just 1 value.
Then I compared your images and found that for you it was off by a few values only in the red channel.

After changing the clip limit percentage to None my script produced a pixel-perfect copy of my image. I wasn't so lucky with your image so I am uncertain if this will work or not.
https://levifiction.wordpress.com/
JoshuaJSlone
Posts: 2
Joined: Tue Jun 19, 2018 5:14 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Video Card: GTX 970
Corel programs: PaintShop Pro 2018

Re: Histogram adjustment script not behaving as expected

Post by JoshuaJSlone »

Thanks very much, that did the trick! My test images come out a match with what I expected.

Your observation about the red was right on, too. HighClipLimitPercentage and LowClipLimitPercentage for green and blue were 0, but red had actual values.
Post Reply