Quote
Here is the Elements process...

Posted 20 December 2008 - 04:49 PM
Quote


Posted 22 December 2008 - 08:26 PM
See below for the improved script...
Posted 23 December 2008 - 04:48 PM




Posted 01 January 2009 - 01:00 AM
Posted 01 January 2009 - 08:51 AM
Posted 13 January 2009 - 05:54 PM
Posted 15 January 2009 - 01:27 AM
Posted 15 January 2009 - 02:44 AM
mishra said:
Posted 15 January 2009 - 02:57 AM
Posted 26 January 2009 - 08:23 PM
Posted 26 January 2009 - 10:21 PM
Posted 29 January 2009 - 01:30 PM
; DivideScannedImages.scm
; by Rob Antonishen
; http://ffaat.pointclark.net
; Version 1.3 (20090128)
; Description
;
; Locates each separate element and creates a new image from each.
; will call the deskew plugin http://www.cubewano.org/gimp-deskew-plugin/
; if it is installed on each image
;
; Changes:
; v1.1 - Added a size threshold slider, and it will call the deskew plugin if installed
; v1.2 - takes a rectangular selection bounding the path rather than a selection from the path itself, added an abort threshold incase the parameters are wonky
; v1.3 - simplifies the selection via feather/sharpen first to speed up the image analysis.
; - fixed exporting the whole image as one.
; - added sliders to pick a background offset. This is useful if your scanner has a "shadow" around the edge of full scans,
;
; License:
;
; 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.
;
; The GNU Public License is available at
; http://www.gnu.org/copyleft/gpl.html
(define (script_fu_DivideScannedImages img inLayer inThreshold inSize inLimit inX inY)
(let*
(
(width (car (gimp-image-width img)))
(height (car (gimp-image-height img)))
(newpath 0)
(strokes 0)
(tempVector 0)
(tempImage 0)
(tempLayer 0)
(bounds 0)
(count 0)
(numextracted 0)
)
; it begins here
(gimp-context-push)
(gimp-image-undo-disable img)
;logging
;(gimp-message-set-handler ERROR-CONSOLE)
;(gimp-message-set-handler CONSOLE)
;(gimp-message-set-handler MESSAGE-BOX)
;or start GIMP wwith "gimp --console-messages" to spawn a console box
;then use this:
;(gimp-message "foobar")
;testing for functions defined
;(if (defined? 'plug-in-shift) (gimp-message "It Exists") (gimp-message "Doesnt Exist"))
;use 0,0 as the background colour
(gimp-context-set-background (car (gimp-image-pick-color img inLayer inX inY FALSE FALSE 0)))
; convert in inverted copy of the background selection to a path
(gimp-fuzzy-select inLayer inX inY inThreshold CHANNEL-OP-REPLACE TRUE FALSE 0 TRUE)
(gimp-selection-feather img (/ (min width height) 100))
(gimp-selection-sharpen img)
(gimp-selection-invert img)
(plug-in-sel2path RUN-NONINTERACTIVE img inLayer)
;break up the vectors
(set! newpath (vector-ref (cadr (gimp-image-get-vectors img)) 0))
(set! strokes (gimp-vectors-get-strokes newpath))
(while (and (< count (car strokes)) (< numextracted inLimit))
(set! tempVector (gimp-vectors-new img "Temp"))
(gimp-image-add-vectors img (car tempVector) -1)
(gimp-vectors-stroke-new-from-points (car tempVector)
(list-ref (gimp-vectors-stroke-get-points newpath (vector-ref (cadr strokes) count)) 0)
(list-ref (gimp-vectors-stroke-get-points newpath (vector-ref (cadr strokes) count)) 1)
(list-ref (gimp-vectors-stroke-get-points newpath (vector-ref (cadr strokes) count)) 2)
(list-ref (gimp-vectors-stroke-get-points newpath (vector-ref (cadr strokes) count)) 3)
)
(gimp-vectors-to-selection (car tempVector) CHANNEL-OP-REPLACE TRUE FALSE 0 0)
;check for minimum size
(set! bounds (gimp-selection-bounds img))
(if (and (> (- (list-ref bounds 3) (list-ref bounds 1)) inSize) (> (- (list-ref bounds 4) (list-ref bounds 2)) inSize) ;min size slider
(< (- (list-ref bounds 3) (list-ref bounds 1)) width) (< (- (list-ref bounds 4) (list-ref bounds 2)) height)) ;max size image
(begin
(gimp-rect-select img (list-ref bounds 1) (list-ref bounds 2)
(- (list-ref bounds 3) (list-ref bounds 1)) (- (list-ref bounds 4) (list-ref bounds 2))
CHANNEL-OP-REPLACE FALSE 0 )
(gimp-edit-copy inLayer)
(set! tempImage (car (gimp-edit-paste-as-new)))
(gimp-image-undo-disable tempImage)
(gimp-display-new tempImage)
;run deskew if it is installed
(if (defined? 'gimp-deskew-plugin)
(begin
(set! tempLayer (car (gimp-image-get-active-layer tempImage)))
(gimp-layer-flatten tempLayer)
(gimp-deskew-plugin 0 tempImage tempLayer 0 0 0 0 0)
(gimp-image-resize-to-layers tempImage)
(gimp-layer-flatten tempLayer)
(plug-in-autocrop RUN-NONINTERACTIVE tempImage tempLayer)
)
)
(gimp-image-undo-enable tempImage)
(set! numextracted (+ numextracted 1))
)
)
(gimp-image-remove-vectors img (car tempVector))
(set! count (+ count 1))
)
;delete temp path
(gimp-image-remove-vectors img newpath)
(gimp-selection-none img)
;done
(gimp-image-undo-enable img)
(gimp-progress-end)
(gimp-displays-flush)
(gimp-context-pop)
)
)
(script-fu-register "script_fu_DivideScannedImages"
"/Filters/Divide Scanned Images..."
"Attempts to isolate each part of the image from the background and creates a new image from it"
"Rob Antonishen"
"Rob Antonishen"
"Dec 2008"
"RGB* GRAY*"
SF-IMAGE "image" 0
SF-DRAWABLE "drawable" 0
SF-ADJUSTMENT "Selection Threshold" (list 10 0 255 1 10 1 SF-SLIDER)
SF-ADJUSTMENT "Size Threshold" (list 100 0 2000 10 100 1 SF-SLIDER)
SF-ADJUSTMENT "Abort Limit" (list 5 1 100 1 10 1 SF-SLIDER)
SF-ADJUSTMENT "Background Sample X Offset" (list 5 1 100 1 10 1 SF-SLIDER)
SF-ADJUSTMENT "Background Sample Y Offset" (list 5 1 100 1 10 1 SF-SLIDER)
)
Posted 05 April 2009 - 06:32 PM
Posted 05 April 2009 - 11:08 PM
Posted 20 April 2009 - 12:52 AM
Posted 20 April 2009 - 01:40 AM
Posted 20 April 2009 - 02:34 AM
Posted 20 April 2009 - 05:04 PM
madthad said:
Posted 20 April 2009 - 05:41 PM