It is currently 09 Dec 2019, 00:28


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

Change Luminosity Mask Script

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

Change Luminosity Mask Script

Post#1 by david » 12 Nov 2019, 15:33


tim,

The Saul Goode Luminosity Mask script being unusable in GIMP 2.10.14 at the moment, I have been using your script.
Not seriously having tried it before I didn't realize how good it is!
However (there is always an however!), I would like to change it so that multiple masks could be used on one image.
I think that if LLL was subtracted from LL and both of these were subtracted from L - similarly for the D masks, as well as removing MM and MMM it would achieve my aim.

I have been able to remove the definition lines which make it compatible with 2.6 and remove the creation of MM and MMM.

But this scripting language is a mystery to me and I have been unable to work out how to make the necessary subtractions.

Help and advice will be much appreciated!

david.
0

tim
GL Blogger

Post#2 by tim » 13 Nov 2019, 00:09


When I wrote that I got the formula from somewhere or original script and don't understand the math behind it either.
So I can't change it without making it wrong.
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

david
Forum Member

Post#3 by david » 13 Nov 2019, 11:31


tim,

Thanks for your reply,
I think I have been able to make the modifications - without really understanding what I was doing!!!

If I have done it correctly, it means that you can make cumulative adjustment on the various layers. A quick try on a few images appears to be OK.

I attach the script in case others wish to try it.
dm_luminosity_masks.scm
(16.74 KiB) Downloaded 22 times
Edit: I found an error in my changes - now updated
0

Krikor
Forum Member

Post#4 by Krikor » 13 Nov 2019, 20:48


david wrote:
12 Nov 2019, 15:33
tim,

The Saul Goode Luminosity Mask script being unusable in GIMP 2.10.14 at the moment, [...]
david.
David,
The SG-LuminosityMask script is one of the scripts I like a lot.
Using Gimp 2.10.14 or other future versions without this script will be painful as I will have to create the channels manually.

It would be nice if Saulgoode could update this script.
Fortunately, version 2.10.14 has a lot of bugs, so I haven't panicked yet, as I only use this version as an experimental one.

Thanks for revealing this SG-Luminosity Mask incompatibility with 2.10.14.
All that is great is greater than all that is small.
0

Krikor
Forum Member

Post#5 by Krikor » 13 Nov 2019, 20:58


tim wrote:
13 Nov 2019, 00:09
When I wrote that I got the formula from somewhere or original script and don't understand the math behind it either.
So I can't change it without making it wrong.
@tim, the steps to create L, D, M, LL, LLL, etc. channels are very simple. :tick_tock:
In this video, the process is explained in detail (from 2:50 to 15:30).

Link - https://youtu.be/BkUZNBielKQ?t=170 <--> Get to the point.

Last edited by Krikor on 13 Nov 2019, 21:12, edited 2 times in total.
All that is great is greater than all that is small.
0

tim
GL Blogger

Post#6 by tim » 13 Nov 2019, 21:03


If I remember correctly my script creates L, LL, LLL, M, MM, MMM, D, DD, DDD alll are there.
they're all defaulted to invisible so turn on layers that you need. and leave the other ones untouched.
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

Krikor
Forum Member

Post#7 by Krikor » 13 Nov 2019, 21:15


@tim,
About the Zone System Separator script, could you fix it? :fb_sad:

It was written for Gimp version 2.8, but in versions 2.10 it has not worked correctly, leaving a 'trail' that reveals the colored layer below even without any of the 11 masked layers selected.
Attachments
Krikor ZoneSeparator bugged
Krikor ZoneSeparator bugged
zsseparatator2.png (463.18 KiB) Viewed 291 times
All that is great is greater than all that is small.
0

tim
GL Blogger

Post#8 by tim » 13 Nov 2019, 21:16


sure I can take a look at it..where is it?
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         
0

Krikor
Forum Member

Post#9 by Krikor » 13 Nov 2019, 21:25


tim wrote:
13 Nov 2019, 21:16
sure I can take a look at it..where is it?
Here it there,

Code: Select all

;
;   zone-separation.scm - script-fu for The Gimp
;	ZS-Separator - Separate a b/w-photo according to the zone system 
;   Version 0.8 (2013-11-15) 
;   testet with The Gimp 2.8
;   Copyright (C) 2013 Leif Pullich - liclic@gmx.de
; 
; Description
; 
; The script is intended to do some annoying work for a photographer
; who wants to analyze a b/w-photo according to the zone system
; of Ansel Adams.
; 
;   What it does
;
; ZS-Separator creates 11 masked layers, each representing one of the 11
; tonal zones of the zone system. The mask of each layer makes all pixels
; transparent which do not belong to the gray values of the corresponding
; zone. The sum of all layers gives the complete photo.
; Additionally, four differently colored layers are inserted below the
; stack of the zone layers which can be used to highlight pixels belonging
; to selected zones.
;
;   How to use it
;
; Activate the layer you  want to analyze and run the script. You will
; find the menu entry in Filters/Generic/Zone System Separator.
; Turn the colored layers below the layer stack invisible except
; one. Play around with the visibility or opacity of the zone layers.
; 
;   Shortcomings 
;
; - works only with RGB-images
; - does not check whether it has already been run. Hence, if it is
;   run again all layers will be created again
; - suits only for analyzing. There's no dynamic adaption if
;   you make changes to your original layer or to the zone layers 
;   If you did and you want to analyze the result, run the script again
; - excessively commented. Since the author is not a programmer he would
;   have appreciated to find more comments in other scripts while learning
;   script-fu
;
; The value ranges for each zone are inspired from an article by
; Thomas Brotzler on focussiert.com:
; http://fokussiert.com/2013/03/20/digitale-schwarzweisfotografie-das-zonensystem-2/
;
; TODO:
; - make it work with other image types or insert a check and warning
; - check whether the colored layers are already there, to avoid 
;   doubling when the script ist run again
; ----------------------------------------------------------------------
; Change log
;    - released: 2013-11-15
;
; ----------------------------------------------------------------------
;
;    This program is free software: you can redistribute it and/or modify
;    it under the terms of the GNU General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.
;
;    This program is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU General Public License for more details.
;
;    You should have received a copy of the GNU General Public License
;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; subs
(define (sub-copy-layer inImage inLayer inLayerName)
	;; copy the layer <inLayer> and set it's name to <inLayerName>
	;; create copy of the orgininal layer, insert copy, set name 
	(let ((nZone 0))
	(set! nZone (car (gimp-layer-copy inLayer FALSE))) 
	(gimp-image-insert-layer inImage nZone 0 -1)
	(gimp-item-set-name nZone inLayerName)
	)
)

(define (sub-add-mask inLayer maskType)
	;; ad a mask of the type <maskType> to the copied layer
	;; create mask, set edit mode
	(gimp-layer-add-mask inLayer (car (gimp-layer-create-mask inLayer maskType)))
	(gimp-layer-set-edit-mask inLayer TRUE)
)

(define (sub-apply-threshold inLayer inValues)
	;; apply threshold-tool to the layer's mask 
	(gimp-threshold (car (gimp-layer-get-mask inLayer)) (car inValues) (cadr inValues))
)				

(define (sub-create-layer inImage inLayer inColVals)
	;; create colored layer
	(let*
		(
		(imageWidth (car(gimp-drawable-width (car(gimp-image-get-active-layer inImage)))))
		(imageHeight(car(gimp-drawable-height(car(gimp-image-get-active-layer inImage)))))
		(drawableType 0)    ;set drawable type to RGB (TODO: insert check of image type)
		(clayParent 0) 		;position new layer in main stack
		(clayPosition -1)	;position new layer directly above the current layer
		(clayOpacity 100)	;set full opacity
		(clayMode 0)		;set layer mode to normal
		(clayFillType 0)	;set fill-type to fill with foreground color
		(clayName (car inColVals))
		(clayColor(cdr inColVals))
		(cLayer)			;anonymous layer object
		)
		(gimp-context-set-foreground clayColor)
		(set! cLayer(car(gimp-layer-new inImage imageWidth imageHeight drawableType clayName clayOpacity clayMode)))
		(gimp-image-insert-layer inImage cLayer clayParent clayPosition)
		(gimp-drawable-fill cLayer clayFillType)
	)
)
;; main
(define (script-fu-separate-zones inImage inLayer)

	(let*
		(
		(baseLayer inLayer)
		;; each element of the following vector definition is a list 
		;; containing the layer's name and values for the threshold
		;; tool
 		;; (STR_LAYER_NAME NUM_THRESHOLD_LOW NUM_THRESHOLD_HIGH)			
		(zones #(				;define vector for zone values
			("Zone 0" 0 13)
			("Zone I" 14 39)
			("Zone II" 40 64)
			("Zone III" 65 89)
			("Zone IV" 90 115)
			("Zone V" 116 140)
			("Zone VI" 141 165)
			("Zone VII" 166 191)
			("Zone VIII" 192 216)
			("Zone IX" 217 242)
			("Zone X" 243 255)
			) 	
		)						;end zones
		(zoneLayer)				;layer for the zone to create
		(zoneLayerName "")		;name of the layer
		(zoneData)				;stores list from vector with the values for zone to create
		(i 10)					;counting variable
		;; (STR_LAYER_NAME NUM_R  NUM_G NUM_B)
		(vColoredLayers #(			;define vector for colored layer values
			("zs red"   255 0 0)
			("zs cyan"  0 255 255)
			("zs black" 0 0 0)
			("zs white" 255 255 255)
			)
		)						;end vColoredLayers
		) 
								;end var definition
		;; preliminaries
		(gimp-context-push)
		(gimp-image-undo-group-start inImage)
		(gimp-progress-init "Creating zones" -1)
		(gimp-progress-pulse)
		
		;; START - work thru all elements of <zones>
		(while (>= i 0)
		
		;; get list from vector for zone to create
		(set! zoneData (aref zones i)) 
		
		;; call sub for copying the original layer
		;; set name for layer, call sub, get layer for next step
		(set! zoneLayerName (car zoneData)) 
		(sub-copy-layer inImage baseLayer zoneLayerName) 
		(set! zoneLayer (car(gimp-image-get-active-layer inImage))) 
				
		;; call sub for generating new mask
		(sub-add-mask zoneLayer 5)
		
		;; call sub for applying threshold-tool to mask with values
		(sub-apply-threshold zoneLayer (cdr zoneData))
		
		;; set original layer as active layer
		(gimp-image-set-active-layer inImage baseLayer)
						
		;; update counter 
		(set! i (- i 1))
		) ;endwhile		
		
		;; insert colored layers
		(let((j 0)) ;; very locally defined counter
			(while (< j 4)
			(sub-create-layer inImage baseLayer (aref vColoredLayers j))
			;; pass each value list from vector-----------^
			(set! j (+ j 1))
			)
		)
		 
		;; cleanup
		(gimp-context-pop)
		(gimp-image-undo-group-end inImage)
		(gimp-progress-set-text "Ready")
		(gimp-progress-update 1.0)
		(gimp-displays-flush)
		
	)

)				
		


(script-fu-register 
	"script-fu-separate-zones"
	"Zone System Separator"
	"Separates a b&w photo according to the zone system. Set selected \
	 zone layers unvisible and use the colored layers to bring out the \
	 pixels belonging to the zone"
	"Leif Pullich"
	"2013 Leif Pullich under \
	terms of CC-License BY-NC Version XX"
	"Oktober 2013"
	"RGB*"
	
	SF-IMAGE "image" 0 
    SF-DRAWABLE "layer" 0 

)
(script-fu-menu-register 
	"script-fu-separate-zones"
	"<Image>/Filters/Generic"
)


All that is great is greater than all that is small.
0

david
Forum Member

Post#10 by david » 13 Nov 2019, 21:27


tim,
Your script works great. You can select any one of the nine layers and make adjustments.

Krikor,
My script (above) is a modification of tim's script and will do everything that the Saul Goode version is capable of.
By selecting and adjusting, for instance, L, M, & D you will get the same results as MM. Selecting DD & DDD will give the same results as DD. However, you now have seven non-overlapping channels which you can also adjust individually or in any combination. That was the aim of the change.
If you would like to try it, I would be pleased to read your comments or criticisms.

david.
0


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
  • Similar Topics
    Replies
    Views
    Last post
• Featuring Members' Works (Image Attachments) •
1: member
2: member
3: member
4: member
5: member

Who is online

Users browsing this forum: No registered users and 7 guests