; 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. (define (sg-count-dashes image drawable filename vert?) (let* ( (width (car (gimp-image-width image))) (height (car (gimp-image-height image))) (extent (if (= vert? TRUE) width height) ) (slice extent) (hist '(0)) (pixcnt 0) ) (while (> slice 0) (set! slice (- slice 1)) (gimp-progress-update (/ (- extent slice) extent)) (if (= vert? TRUE) (gimp-rect-select image slice 0 1 height CHANNEL-OP-REPLACE FALSE 0) (gimp-rect-select image 0 slice width 1 CHANNEL-OP-REPLACE FALSE 0) ) (set! pixcnt (cadr (cdddr (gimp-histogram drawable HISTOGRAM-VALUE 0 127)))) (unless (and (= (car hist) 0) (= pixcnt 0)) (set! hist (cons pixcnt hist)) ) ) (let* ( (cnt 0) (acc '()) (lis '()) (p #f) ) (while (pair? hist) (if (= (car hist) 0) (begin (unless (= cnt 0) (set! lis (cons (/ (apply + acc) cnt) lis)) (set! cnt 0) (set! acc '()) ) (set! hist (cdr hist)) ) (begin (set! acc (cons (car hist) acc)) (set! cnt (+ cnt 1)) (set! hist (cdr hist)) ) ) ) (set! p (open-output-file filename)) (if (not p) (gimp-message "Unable to create file!") (begin (write lis p) (close-output-port p) ) ) ) ) ) (script-fu-register "sg-count-dashes" "/Filters/Misc/Count Dashes..." "Count the dashes on an image per 'jvolm' on Registry Forum" "Saul Goode" "Saul Goode" "10/3/2008" "" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 SF-STRING "Filename" "histdata.txt" SF-TOGGLE "Vertical?" TRUE )