Simple luminosity mask script - first attempt (UPDATED)

Moderator: Kathy_9

Post Reply
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Simple luminosity mask script - first attempt (UPDATED)

Post by gbotes »

I come from a GIMP user background, and just recently purchased PaintShop Pro x8. So far there are many things about PSP that I love, and a few things that I hate. One of the things I'm missing is the ability to create and edit simple luminosity masks. I've searched Google without much success, and found no mention of luminosity masks in any of the PSP documentation as yet. So, I've tried to come up with a script that approximates how I've worked with luminosity masks in GIMP.

In case some members of the forum find usefulness in it, here is the script I recorded - it seems to do what I had in mind and what I understand as luminosity masks. If you check it out and have suggestions, comments, tips, etc I'd be grateful.

UPDATE:
I didn't encounter "jaggies" with the first two images I edited using my first script, but I did with subsequent images. This makes it clear to me that Gimp and PSP work a bit differently as far as layers go. LeviFiction (thanks!) asked about this, and pointed out that it might occur. As a result I've revised this script by removing Threshold. I would still welcome any comments/suggestions/improvements, as this script helps but still doesn't quite seem to give me luminosity masking as in Gimp.

My script was recorded and saved in my restricted scripts folder (DriveLetter:\Users\UserName\Documents\Corel PaintShop Pro\18.0\Scripts-Restricted):

Code: Select all

from PSPApp import *

def ScriptProperties():
    return {
        'Author': u'gbotes',
        'Copyright': u'',
        'Description': u'Create light, dark and mid tone masks for editi'\
            u'ng with curves',
        'Host': u'PaintShop Pro',
        'Host Version': u'18.00'
        }


def Do(Environment):
    # EnableOptimizedScriptUndo
    App.Do( Environment, 'EnableOptimizedScriptUndo', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # LayerDuplicate
    App.Do( Environment, 'LayerDuplicate', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Layer Properties
    App.Do( Environment, 'LayerProperties', {
            'General': {
                'Opacity': None, 
                'Name': u'Dark', 
                'IsVisible': None, 
                'IsTransparencyLocked': None, 
                'LinkSet': None, 
                'UseHighlight': None, 
                'PaletteHighlightColor': None, 
                'GroupLink': None, 
                'BlendMode': None
                }, 
            'BlendRanges': None, 
            'Path': (0,0,[],False), 
            'ArtMediaTexture': None, 
            'Effects': None, 
            'BrightnessContrast': None, 
            'ChannelMixer': None, 
            'ColorBalance': None, 
            'CurveParams': None, 
            'HSL': None, 
            'Threshold': None, 
            'Levels': None, 
            'Posterize': None, 
            'Vibrancy': None, 
            'Overlay': None, 
            'LocalToneMapping': None, 
            'Invert': None, 
            'HistogramAdjustment': None, 
            'FillLightClarity': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # LayerDuplicate
    App.Do( Environment, 'LayerDuplicate', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Layer Properties
    App.Do( Environment, 'LayerProperties', {
            'General': {
                'Opacity': None, 
                'Name': u'Light', 
                'IsVisible': None, 
                'IsTransparencyLocked': None, 
                'LinkSet': None, 
                'UseHighlight': None, 
                'PaletteHighlightColor': None, 
                'GroupLink': None, 
                'BlendMode': None
                }, 
            'BlendRanges': None, 
            'Path': (0,0,[],False), 
            'ArtMediaTexture': None, 
            'Effects': None, 
            'BrightnessContrast': None, 
            'ChannelMixer': None, 
            'ColorBalance': None, 
            'CurveParams': None, 
            'HSL': None, 
            'Threshold': None, 
            'Levels': None, 
            'Posterize': None, 
            'Vibrancy': None, 
            'Overlay': None, 
            'LocalToneMapping': None, 
            'Invert': None, 
            'HistogramAdjustment': None, 
            'FillLightClarity': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # LayerDuplicate
    App.Do( Environment, 'LayerDuplicate', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Layer Properties
    App.Do( Environment, 'LayerProperties', {
            'General': {
                'Opacity': None, 
                'Name': u'Mid', 
                'IsVisible': None, 
                'IsTransparencyLocked': None, 
                'LinkSet': None, 
                'UseHighlight': None, 
                'PaletteHighlightColor': None, 
                'GroupLink': None, 
                'BlendMode': None
                }, 
            'BlendRanges': None, 
            'Path': (0,0,[],False), 
            'ArtMediaTexture': None, 
            'Effects': None, 
            'BrightnessContrast': None, 
            'ChannelMixer': None, 
            'ColorBalance': None, 
            'CurveParams': None, 
            'HSL': None, 
            'Threshold': None, 
            'Levels': None, 
            'Posterize': None, 
            'Vibrancy': None, 
            'Overlay': None, 
            'LocalToneMapping': None, 
            'Invert': None, 
            'HistogramAdjustment': None, 
            'FillLightClarity': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # MaskFromImage
    App.Do( Environment, 'MaskFromImage', {
            'CreateMaskFrom': App.Constants.CreateMaskFrom.Luminance, 
            'InvertMaskData': False, 
            'SourceImage': 0, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (1,-1,[],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # MaskFromImage
    App.Do( Environment, 'MaskFromImage', {
            'CreateMaskFrom': App.Constants.CreateMaskFrom.Luminance, 
            'InvertMaskData': False, 
            'SourceImage': 0, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (1,-1,[],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # MaskFromImage
    App.Do( Environment, 'MaskFromImage', {
            'CreateMaskFrom': App.Constants.CreateMaskFrom.Luminance, 
            'InvertMaskData': True, 
            'SourceImage': 0, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (1,1,[2],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (1,-1,[2],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # Copy
    App.Do( Environment, 'Copy', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (1,2,[1],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # PasteAsNewLayer
    App.Do( Environment, 'PasteAsNewLayer', {
            'CreateFromDropData': False, 
            'InsertPos': -1, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (1,-1,[2],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # Copy
    App.Do( Environment, 'Copy', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (1,1,[2],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # PasteAsNewLayer
    App.Do( Environment, 'PasteAsNewLayer', {
            'CreateFromDropData': False, 
            'InsertPos': -1, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # LayerMergeDown
    App.Do( Environment, 'LayerMergeDown', {
            'Path': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (0,1,[],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # DeleteLayer
    App.Do( Environment, 'DeleteLayer', {
            'Path': None, 
            'MergeMask': False, 
            'WorkingMode': 1, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Layer Properties
    App.Do( Environment, 'LayerProperties', {
            'General': {
                'Opacity': None, 
                'Name': u'Mask - Mid', 
                'IsVisible': None, 
                'IsTransparencyLocked': None, 
                'LinkSet': None, 
                'UseHighlight': None, 
                'PaletteHighlightColor': None, 
                'GroupLink': None, 
                'BlendMode': None
                }, 
            'BlendRanges': None, 
            'Path': (0,0,[],False), 
            'ArtMediaTexture': None, 
            'Effects': None, 
            'BrightnessContrast': None, 
            'ChannelMixer': None, 
            'ColorBalance': None, 
            'CurveParams': None, 
            'HSL': None, 
            'Threshold': None, 
            'Levels': None, 
            'Posterize': None, 
            'Vibrancy': None, 
            'Overlay': None, 
            'LocalToneMapping': None, 
            'Invert': None, 
            'HistogramAdjustment': None, 
            'FillLightClarity': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })
Last edited by gbotes on Tue Oct 06, 2015 9:57 am, edited 2 times in total.
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: Simple luminosity mask script - first attempt

Post by LeviFiction »

If you use the [code] [/code] tags around the script text it will maintain the necessary spacing.

Does Threshold hurt the luminosity mask at all? It doesn't make it too jagged or strict? I'll admit I've tried several times to come up with a good method for creating luminosity masks and it never once occurred to me to use threshold on the mask itself.
https://levifiction.wordpress.com/
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Simple luminosity mask script - first attempt

Post by gbotes »

Ah, thanks for the tip abut the

Code: Select all

 
tags. :D

The reason I use threshold is to avoid overlap of the mask areas. It works without threshold, too, but the overlap quickly becomes apparent. It is, perhaps, a matter of personal taste whether it is better with or without it. :)
Post Reply