[sane-devel] Coolscan dust-removal: error messages & fu-script

Laurent-jan ljm@xs4all.nl
Wed, 30 Apr 2003 14:18:16 +0200


Hi,

I am still trying to dust-off my Coolscan2 scans.
Current status is that I can remove dust, but it is
not yet practical or realy thought-through. So I will
continue trying to improve.

When scanning the IR channel via xsane as a GIMP-plug-in
I use a batchscan, with two times the same area. After the
first scan (the RGB-image) I get 4 error messages:

Failed to set value of option green-gamma-table: Invalid argument
(same for the other colors)
and

Failed to start scanner: Invalid argument

The RGB-version of the image apears.

I click away the messages, and restart a batchscan

The IR-grayscale image apears, with an error-message:

Failed to start scanner: Invalid argument

There is some logic to the messages that I can understand,
the IR being a grayscale. But it is not very userfriendly.

As I had no experience programming for the GIMP, it took
me some time to remove the dust from the image. A quick &
dirty way to remove the dust is by running the following
script-fu.
-------------------------<cut here>------------------------
(define (script-fu-dirty-dust rgblayer irlayer)
         (set! rgbimg (car (gimp-drawable-image rgblayer)))
         (set! irimg (car (gimp-drawable-image irlayer)))
; Make IR-layer more black & white
         (gimp-brightness-contrast irlayer -110 125)
; Dup the RGB-layer for later purposes
         (set! holeslayer (car (gimp-layer-copy rgblayer 1)))
         (gimp-layer-set-name holeslayer "Holeslayer")
         (gimp-image-add-layer rgbimg holeslayer 0)
         (set! irsellayer  (car (gimp-layer-copy holeslayer 1)))
         (gimp-layer-set-name irsellayer "selection-layer" )
         (gimp-image-add-layer rgbimg irsellayer 0)
; Copy the IR-layer to the irsellayer
         (gimp-selection-all irimg)
         (gimp-edit-copy irlayer)
         (set! selfloat (car (gimp-edit-paste irsellayer TRUE)))
         (gimp-floating-sel-anchor selfloat)
; Make holes in the holes-layer where there are dust-pixels
         (gimp-by-color-select irsellayer '(0 0 0) 150 2 1 0 0 0)
         (gimp-selection-grow rgbimg 1)
         (gimp-edit-cut holeslayer)
; Blur the underlying image
         (plug-in-gauss-iir 1 rgbimg rgblayer 25 25 25)
; Clean-up
         (gimp-image-remove-layer rgbimg irsellayer)
         (gimp-image-flatten rgbimg)

         (gimp-displays-flush)
)



(script-fu-register
         "script-fu-dirty-dust"
;       "<Toolbox>/Xtns/Script-Fu/Misc/Dirty duster"
         "<Toolbox>/ljm/Dirty duster"
         "Try to dust-off coolscan2-pictures"
         "ljm"
         "GPL"
         "April 30, 2003"
         "RGB* INDEXED* GRAY*"
         SF-DRAWABLE "Layer containing image"    0
         SF-DRAWABLE "Layer containing dust"     1
)

-- 
(c) ljm @ xs4all . nl.  No part of this copyright message may be
reproduced, read or seen, dead or alive or by any means, including
but not limited to telepathy  without the benevolence of the author.