WERBUNG

Gimp-Script=Scheme :-/

schnebeck

Themenersteller
Ich hab mich mal rangesetzt und versuche ein DRI-Plugin für GIMP2 zu coden. Dabei durfte ich meine ersten Erfahrungen in Scheme (eine Art Lisp) sammeln. Ist ja schon etwas... anders.

Code:
(set! new-layer (car (gimp-layer-copy drawable 0)))
;build layer mask
(gimp-layer-add-alpha drawable)
(gimp-layer-add-mask drawable (car (gimp-layer-create-mask drawable 4)))

Glücklicherweise sind die Gimpfunktionen recht mächtig.

Und Version 0.0.1 meines Skriptes funktioniert sogar! :-))

Prinzip:

select by color 0,0,0
grow 60
invert selection
feather 100
add alpha to layer
add layermask from selection

Jetzt muss man nur noch das dunklere der beiden Bilder in einen unteren Layer laden. Nun muss ich erstmal die magischen Zahlen im Skript schlau ersetzen.

Für ein paar Anregungen wäre ich sehr dankbar. Reichen zwei Bilder oder sollte man mehr mischen können? Wie sollte die Übergabe der Bilder erfolgen? Dateidialog? Ach ja, wie funktionieren If-Abfragen in Scheme bzw. Script-Fu?

Jetzt muss aber erstmal meine Akkumaus ins Häuschen und ich ins Bettchen ;-)

Bye

Thorsten
 
Danke für die verschiedenen Hilfen auch per PN.

Script-Fu ist ja nicht so schwierig - nur halt anders ;-)
Ich hab das Script soweit fertig, allerdings wollte ich noch schauen, ob es nicht intelligentere Ansätze gibt Layermasken zu erstellen. Dazu habe ich mich etwas bei
http://www.erik-krause.de
umgeschaut. Ich will da mal noch mit ein paar Dingen spielen, vielleicht wird aus dem DRI ja ein HDR ;-)

Für Spielkinder hier das Korsett für meine Experimente

Code:
; dri.scm
; 0.1 (2004-08-02)
;
; 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 2 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, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;
; dynamic range increase 
; based on the tutorial of Michael Reichmann 
; http://www.luminous-landscape.com/tutorials/digital-blending.shtml
;
; (C) 2004 by Thorsten Schnebeck (thorsten.schnebeck@gmx.net)
;
; copy this script to ~/.gimp/scripts/dri.scm
; and in Gimp2: Xtns->Script-Fu->Refresh Scripts
; you find this script in Xtns/Script-Fu/Misc/DRI...

(define (script-fu-dri dark_file light_file radius feather threshold adjust)

	(set! dri		(car (gimp-file-load 1 dark_file  dark_file))) 
	(set! tmp_img	(car (gimp-file-load 1 light_file light_file))) 

	; move light image as new layer into DRI image
	(gimp-image-add-layer dri (car (gimp-layer-new-from-drawable (car (gimp-image-get-active-layer tmp_img)) dri)) 0)
	(gimp-image-delete tmp_img)

	; work on lighter layer
	(set! drawable (car (gimp-image-get-active-layer dri)))

	; select white color 
	(gimp-by-color-select drawable '(255 255 255) threshold 0 0 0 0 0)
	(gimp-selection-grow dri radius)
	(gimp-selection-feather dri feather)
	(gimp-selection-invert dri)
    
	; build layer mask
	(gimp-layer-add-alpha drawable)
	(gimp-layer-add-mask drawable (car (gimp-layer-create-mask drawable 4)))
	(gimp-selection-clear dri)
	
	(if (= adjust TRUE)
		(begin
			(gimp-image-merge-visible-layers dri 0)
;			(gimp-levels-auto (car (gimp-image-get-active-layer dri)))
		)
	) 
	
	; show merged image
	(gimp-display-new dri)
)

(script-fu-register "script-fu-dri"
					  
"<Toolbox>/Xtns/Script-Fu/Misc/DRI..."

"Dynamic Range Increase
Select a darker and a lighter image of the same scene.
Choose radius, feather and threshold around
the lighter parts of the lighter layer.
Select Adjust to merge both layers into one layer."

"Thorsten Schnebeck"
"Thorsten Schnebeck (thorsten.schnebeck@gmx.net)"
"2004"
"RGB*"
	
	SF-FILENAME		_"Image (dark)" "~"
	SF-FILENAME		_"Image (light)" "~"
	SF-ADJUSTMENT	_"Radius (px)"  '(50 1 1000 5 10 0 1)
	SF-ADJUSTMENT	_"Feather (px)"  '(50 1 1000 5 10 0 1)
	SF-ADJUSTMENT	_"Treshhold (0-255)" '(1 0 255 1 10 0 1)
	SF-TOGGLE		_"Adjust" FALSE
)
;Tab=4

Bye

Thorsten
 
WERBUNG
Zurück
Oben Unten