What is it?
Some Japanese artists have helpfully censored using transparent black rectangles. It should be possible to completely decensor if you can guess the exact color and opacity of the rectangle. For example, 50% black aka rgba(0,0,0,0.5).
The script will have to work with any color and any opacity, not just 50%. One test showed a value closer to 52%. The edges of the rectangle may be feathered. Meaning you might have to make multiple selections.
Adding color
rgb(128,0,128) + rgba(255,192,0,0.6) = rgb(204,115,51)
(128 * 0.4) + (255 * 0.6) = 204.2
(0 * 0.4) + (192 * 0.6) = 115.2
(128 * 0.4) + (0 * 0.6) = 51.2
Subtracting transparent color (decensor)
((204.2 - (0.6 * 255)) / 0.4) = 128
((115.2 - (0.6 * 192)) / 0.4) = 0
((51.2 - (0.6 * 0)) / 0.4) = 128
Code
It doesn't work but it will look like this:
(define (script-fu-decensor img drawable mask-color mask-opacity) (define color-get-red car) (define color-get-green cadr) (define color-get-blue caddr) (gimp-context-push) (gimp-image-set-active-layer img drawable) (gimp-image-undo-group-start img) ;; Do stuff here (let* ((selection-bounds (gimp-selection-bounds img)) (select-offset-x (cadr selection-bounds)) (select-offset-y (caddr selection-bounds)) (select-width (- (cadr (cddr selection-bounds)) select-offset-x)) (select-height (- (caddr (cddr selection-bounds)) select-offset-y)) (y select-offset-y) (x select-offset-x) ) (gimp-selection-none img) (gimp-palette-set-background (list 255 255 255)) (gimp-palette-set-foreground (list 0 0 255)) (gimp-brushes-set-brush "Circle (01)") (while (< y (+ select-offset-y select-height)) (set! x select-offset-x) (while (< x (+ select-offset-x select-width)) (let* ((in-color (gimp-drawable-get-pixel drawable x y)) (out-color (list (cons (aref (aref in-color 4) 0) (aref (aref in-color 4) 1)) (cons (aref (aref in-color 4) 2) (aref (aref in-color 4) 3)) (cons (aref (aref in-color 4) 4) (aref (aref in-color 4) 5)))) ) ;;CHANGE FILL COLOR (gimp-rect-select img x y 1 1 REPLACE 0 0) (gimp-edit-fill drawable 0) (gimp-selection-none img) ) (set! x (+ x 1))) (set! y (+ y 1))) (gimp-image-undo-group-end img) (gimp-context-pop) (gimp-displays-flush) ) ) (script-fu-register "script-fu-decensor" "Decensor" "Subtracts a partially transparent color \previously added to the image." "Anonymous" "Anonymous" "2015" "*" SF-IMAGE _"Image" 0 SF-DRAWABLE _"Drawable" 0 SF-COLOR _"Color" '(0 0 0) SF-ADJUSTMENT _"Opacity" '(50 0 100 1 10 0 1) ) (script-fu-menu-register "script-fu-decensor" "<Image>/Filters/Enhance")
Updated by savageorange