Autor Tema: Enfocar con Gimp ¿Sharpen o Unsharp?  (Leído 22100 veces)

xabih

  • Comenzando
  • *
  • Mensajes: 22
Enfocar con Gimp ¿Sharpen o Unsharp?
« on: 12 abr 2008, 09:51 am »
Tengo una duda a la hora de enfocar con Gimp, por lo que veo hay dos filtros para hacerlo: Sharpen y Unsharp, ¿cual es mas conveniente usar?
Unsharp parece mas potente aunque aun no me he puesto a investigar para que sirve cada deslizador, eso si, los valores que aparecen por defecto me parecen demasiado agresivos ¿no se pueden modificar para no estar siempre bajándolos?

Gracias y un saludo.
Mas vale duda que dogma.

tonilupi

  • Consolidad@
  • ****
  • Mensajes: 129
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #1 on: 12 abr 2008, 10:31 am »
Hola xabih, leete este post y te aclarará un poco las cosas  http://comunidad.fotolibre.net/index.php/topic,134.0.html .

Yo uso el smart-sharpening, he probado el refocus pero no le acabo de coger el hilo, en cambio el primero es el que mejor de va.

Saludos

xabih

  • Comenzando
  • *
  • Mensajes: 22
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #2 on: 12 abr 2008, 15:58 pm »
Gracias, ya me he instalado el Smartsharpening  :-)
Mas vale duda que dogma.

Colegota

  • Palizas oficial
  • *
  • Mensajes: 8188
  • ¡Me faltan carretes!
    • ¡Me faltan carretes!
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #3 on: 13 abr 2008, 17:37 pm »
Buenas,

pues yo sigo esperando a ver si alguien me consigue explicar cómo usar valores para radios, cantidades y lo otro. Y llevo unos años con ello.  :'(

El caso es que casi tirando la toalla había empezado a probar el smart sharpening porque el que yo uso no me funcionaba en 2.4, pero justo acabo de encontrar el problema y ya lo tengo rulando en 2.4.

Bien, mi favorito es el Unsharp mask de Shuji Narazaki que venía en las versiones antiguas pero un día dejó de funcionar.
Crea una capa con una máscara para las luces y otra para las sombras y jugando con la opacidad de dichas capas se consigue afinar el resultado. Es especialmente útil el jugar con la transparencia de la de las luces cuando salen los dichosos artefactos esos. La de las sombras yo casi siempre la pongo al 100%.
El método está descrito en un libro de Dan Margulis que me recomendó Maky hace tiempo.

Para los que lo queráis probar, deberéis aseguraros de que en /usr/share/gimp/2.0 o similar no existe el antiguo unsharp-mask.scm borrándolo previamente (o moviéndolo a otro sitio si no os fiáis).
Y luego copiar este en vuestra carpeta /home/usuario/.gimp-2.4/scripts o equivalente (en win es otro).
A mi me aparece ahora en 2.4 en el menú Filtros->Artístico.


Saludos,
Colegota


Código: [Seleccionar]
;;; unsharp-mask.scm
;;; Time-stamp: <1998/11/17 13:18:39 narazaki@gimp.org>
;;; Author: Narazaki Shuji <narazaki@gimp.org>
;;; Version 0.8

(define (script-fu-unsharp-mask img drw mask-size mask-opacity)
  (let* ((drawable-width (car (gimp-drawable-width drw)))
(drawable-height (car (gimp-drawable-height drw)))
(new-image (car (gimp-image-new drawable-width drawable-height RGB)))
(original-layer (car (gimp-layer-new new-image
      drawable-width drawable-height
      RGB-IMAGE "Original"
      100 NORMAL-MODE)))
(original-layer-for-darker #f)
(original-layer-for-lighter #f)
(blured-layer-for-darker #f)
(blured-layer-for-lighter #f)
(darker-layer #f)
(lighter-layer #f))

    (gimp-selection-all img)
    (gimp-edit-copy drw)

    (gimp-image-undo-disable new-image)

    (gimp-image-add-layer new-image original-layer 0)
    (gimp-floating-sel-anchor
     (car (gimp-edit-paste original-layer FALSE)))

    (set! original-layer-for-darker (car (gimp-layer-copy original-layer TRUE)))
    (set! original-layer-for-lighter (car (gimp-layer-copy original-layer TRUE)))
    (set! blured-layer-for-darker (car (gimp-layer-copy original-layer TRUE)))
    (gimp-drawable-set-visible original-layer FALSE)
    (gimp-display-new new-image)

    ;; make darker mask
    (gimp-image-add-layer new-image blured-layer-for-darker -1)
    (plug-in-gauss-iir TRUE new-image blured-layer-for-darker mask-size
       TRUE TRUE)
    (set! blured-layer-for-lighter
  (car (gimp-layer-copy blured-layer-for-darker TRUE)))
    (gimp-image-add-layer new-image original-layer-for-darker -1)
    (gimp-layer-set-mode original-layer-for-darker SUBTRACT-MODE)
    (set! darker-layer
  (car (gimp-image-merge-visible-layers new-image CLIP-TO-IMAGE)))
    (gimp-drawable-set-name darker-layer "darker mask")
    (gimp-drawable-set-visible darker-layer FALSE)

    ;; make lighter mask
    (gimp-image-add-layer new-image original-layer-for-lighter -1)
    (gimp-image-add-layer new-image blured-layer-for-lighter -1)
    (gimp-layer-set-mode blured-layer-for-lighter SUBTRACT-MODE)
    (set! lighter-layer
  (car (gimp-image-merge-visible-layers new-image CLIP-TO-IMAGE)))
    (gimp-drawable-set-name lighter-layer "lighter mask")

    ;; combine them
    (gimp-drawable-set-visible original-layer TRUE)
    (gimp-layer-set-mode darker-layer SUBTRACT-MODE)
    (gimp-layer-set-opacity darker-layer mask-opacity)
    (gimp-drawable-set-visible darker-layer TRUE)
    (gimp-layer-set-mode lighter-layer ADDITION-MODE)
    (gimp-layer-set-opacity lighter-layer mask-opacity)
    (gimp-drawable-set-visible lighter-layer TRUE)

    (gimp-image-undo-enable new-image)
    (gimp-displays-flush)))


(script-fu-register "script-fu-unsharp-mask"
    "<Image>/Script-Fu/Alchemy/Unsharp Mask..."
    "Make a sharp image of IMAGE's DRAWABLE by applying unsharp mask method"
    "Shuji Narazaki <narazaki@gimp.org>"
    "Shuji Narazaki"
    "1997,1998"
    ""
    SF-IMAGE       "Image"             0
    SF-DRAWABLE    "Drawable to apply" 0
    SF-ADJUSTMENT _"Mask size"         '(5 1 100 1 1 0 1)
    SF-ADJUSTMENT _"Mask opacity"      '(50 0 100 1 1 0 1))
[Canon EOS 50 40D (sin diapos ni nada)] [Escáner Minolta DSE 5400] [Vuescan] [El GIMP] [Galería] [Página de Viajes]

tonilupi

  • Consolidad@
  • ****
  • Mensajes: 129
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #4 on: 13 abr 2008, 19:37 pm »
Colegota, gracias por tu aportación, pero creo que te has comido unas líneas al final del archivo, lo he intentado usar y no va.

Falta la sección en la que se registra el plugin en el menú de Gimp y no se si faltarán otras líneas.

Te agradecería lo pusieras entero o me lo envies por privado, estaría bien poder compararlo con el smart-sharpen e incluso con otro que acabo de ver y que nunca he usado y que a mi me sale como "Máscara de desenfoque".

Saludos.

Colegota

  • Palizas oficial
  • *
  • Mensajes: 8188
  • ¡Me faltan carretes!
    • ¡Me faltan carretes!
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #5 on: 13 abr 2008, 19:41 pm »
Buenas,

lo he revisado y está completo...  :?

¿Qué error te da? ¿Has borrado el original? Comprueba que lo has copiado bien y esas cosas...

Saludos,
Colegota
[Canon EOS 50 40D (sin diapos ni nada)] [Escáner Minolta DSE 5400] [Vuescan] [El GIMP] [Galería] [Página de Viajes]

tonilupi

  • Consolidad@
  • ****
  • Mensajes: 129
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #6 on: 14 abr 2008, 18:07 pm »
El problema es que no me sale en el menú.

El archivo anterior lo he renombrado así que no creo que sea por su culpa.

Adjunto el código del script smart sharpening, fíjate en la última sección es la que registra el sript en el menú de Gimp y eso no lo veo en el código que has colgado.

Saludos


Cita
;

; Smart Sharpening, Redux, V2.4

;

; Martin Egger (martin.egger@gmx.net)

; (C) 2007, Bern, Switzerland

;

; You can find more about Smart Sharpening at

; http://www.gimpguru.org/Tutorials/SmartSharpening2/
;
; The Refocus plugin from http://hphsite.de/refocus/ must be installed seperately.

;

; This script was tested with Gimp 2.4

;

; 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 3 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, see <http://www.gnu.org/licenses>.

;

; Define the function

;

(define (script-fu-Eg-SmartSharpen InImage InLayer InRadius InAmount InThreshold InRefocus InMatSize InRFRadius InGauss InCorrelation InNoise InEdge InBlur InFlatten)

;

; Save history         

;

   (gimp-image-undo-group-start InImage)

   (if (= (car (gimp-drawable-is-rgb InLayer)) FALSE ) (gimp-image-convert-rgb InImage))

;

   (let*   (

      (MaskImage (car (gimp-image-duplicate InImage)))

      (MaskLayer (cadr (gimp-image-get-layers MaskImage)))

;

      (OrigLayer (cadr (gimp-image-get-layers InImage)))

      (HSVImage (car (plug-in-decompose TRUE InImage InLayer "Value" TRUE)))

         (HSVLayer (cadr (gimp-image-get-layers HSVImage)))

;

      (SharpenLayer (car (gimp-layer-copy InLayer TRUE)))

      )

;

      (gimp-image-add-layer InImage SharpenLayer -1)

;

        (gimp-selection-all HSVImage)

         (gimp-edit-copy (aref HSVLayer 0))

         (gimp-image-delete HSVImage)

        (gimp-floating-sel-anchor (car (gimp-edit-paste SharpenLayer FALSE)))

;

         (gimp-layer-set-mode SharpenLayer VALUE-MODE)

;

; Find edges, Warpmode = Smear (1), Edgemode = Sobel (0)

;

      (plug-in-edge TRUE MaskImage (aref MaskLayer 0) InEdge 1 0)

      (gimp-levels-stretch (aref MaskLayer 0))

      (gimp-image-convert-grayscale MaskImage)

      (plug-in-gauss TRUE MaskImage (aref MaskLayer 0) InBlur InBlur TRUE)

;

      (let*   (

         (SharpenChannel (car (gimp-layer-create-mask SharpenLayer ADD-WHITE-MASK)))

         )

         (gimp-layer-add-mask SharpenLayer SharpenChannel)

;

         (gimp-selection-all MaskImage)

         (gimp-edit-copy (aref MaskLayer 0))

         (gimp-floating-sel-anchor (car (gimp-edit-paste SharpenChannel FALSE)))

         (gimp-image-delete MaskImage)

;

         (cond         
            ((= InRefocus FALSE)(plug-in-unsharp-mask TRUE InImage SharpenLayer InRadius InAmount InThreshold))
            ((= InRefocus TRUE)(plug-in-refocus TRUE InImage SharpenLayer InMatSize InRFRadius InGauss InCorrelation InNoise))
         )

         (gimp-layer-set-opacity SharpenLayer 80)

         (gimp-layer-set-edit-mask SharpenLayer FALSE)

      )

;

; Flatten the image, if we need to

;

      (cond

         ((= InFlatten TRUE) (gimp-image-merge-down InImage SharpenLayer CLIP-TO-IMAGE))

         ((= InFlatten FALSE)

            (begin

               (gimp-drawable-set-name SharpenLayer "Sharpened")

               (gimp-image-set-active-layer InImage InLayer)

            )

         )

      )

   )

;

; Finish work

;

   (gimp-image-undo-group-end InImage)

   (gimp-displays-flush)

;

)

;

(script-fu-register

   "script-fu-Eg-SmartSharpen"

   _"_Sharpen (Smart Redux)"

   "Smart Sharpening, Redux version"

   "Martin Egger (martin.egger@gmx.net)"

   "2006, Martin Egger, Bern, Switzerland"

   "28.01.2007"

   "RGB* GRAY*"

   SF-IMAGE   "The Image"      0

   SF-DRAWABLE   "The Layer"      0

   SF-ADJUSTMENT   "USM: Radius"      '(2.0 0.0 50.0 1 0 2 0)

   SF-ADJUSTMENT   "USM: Amount"      '(1.0 0.0 5.0 0.5 0 2 0)

   SF-ADJUSTMENT   "USM: Threshold"      '(0.0 0.0 50.0 1.0 0 2 0)
   SF-TOGGLE   "Use refocus plugin"   FALSE
   SF-ADJUSTMENT   "Refocus: Size of matrix"    '(5.0 0.0 10.0 1.0 0 2 0)
   SF-ADJUSTMENT   "Refocus: Circle radius"       '(1.0 0.0 25.0 0.1 0 2 0)
   SF-ADJUSTMENT   "Refocus: Parameter for Gaussian" '(0.0 0.0 25.0 0.1 0 2 0)
   SF-ADJUSTMENT   "Refocus: Correlation"       '(0.5 0.0 1.0 0.05 0 2 0)
   SF-ADJUSTMENT   "Refocus: Noise to Signal ratio"    '(0.01 0.0 1.0 0.01 0 2 0)

   SF-ADJUSTMENT   "Edges: Detect Amount"   '(6.0 1.0 10.0 1.0 0 2 0)

   SF-ADJUSTMENT   "Edges: Blur Pixels"   '(6.0 1.0 10.0 1.0 0 2 0)

   SF-TOGGLE   "Flatten Image"      FALSE

)

;

(script-fu-menu-register "script-fu-Eg-SmartSharpen"

          "<Image>/Filters/Eg")

;

invisible

  • Moderador
  • Palizas oficial
  • *****
  • Mensajes: 8097
    • INVItARTE
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #7 on: 14 abr 2008, 18:51 pm »
Salud, tonilupi:
Si crees que ese es el motivo lo tienes fácil: añade tú la línea al script y lo sitúas donde quieras. q:)
"Si quieres ver lo invisible, observa con atención lo visible."
                                                     Manuel Álvarez Bravo (1902-2002)

Colegota

  • Palizas oficial
  • *
  • Mensajes: 8188
  • ¡Me faltan carretes!
    • ¡Me faltan carretes!
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #8 on: 14 abr 2008, 18:58 pm »
Buenas,

sí que está la parte del registro

Código: [Seleccionar]
(script-fu-register "script-fu-unsharp-mask"
    "<Image>/Script-Fu/Alchemy/Unsharp Mask..."
    "Make a sharp image of IMAGE's DRAWABLE by applying unsharp mask method"
    "Shuji Narazaki <narazaki@gimp.org>"
    "Shuji Narazaki"
    "1997,1998"
    ""
    SF-IMAGE       "Image"             0
    SF-DRAWABLE    "Drawable to apply" 0
    SF-ADJUSTMENT _"Mask size"         '(5 1 100 1 1 0 1)
    SF-ADJUSTMENT _"Mask opacity"      '(50 0 100 1 1 0 1))

Puede que te lo haya puesto en otro menú... En la ventana de gimp, en Ext->explorador de complementos, escribe unsharp y mira en la ruta de menú que te dice ahí.
Asegurándote, claro de que habías copiado el script entero...

Saludos,
Colegota
[Canon EOS 50 40D (sin diapos ni nada)] [Escáner Minolta DSE 5400] [Vuescan] [El GIMP] [Galería] [Página de Viajes]

tonilupi

  • Consolidad@
  • ****
  • Mensajes: 129
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #9 on: 14 abr 2008, 19:07 pm »
Ya lo tengo funcionando, era un tema de que aunque había eliminado los archivos llamados unsharp-mask.scm de todos los directorios a los que apuntan las preferencias de Gimp se ve que lo que prevalece es el nombre con que se registra el plug-in y habrá alguno que aunque no comparta el mismo nombre sí que internamente lo registro como tal.

De todas formas veo que con este script solo me salen dos parámetros.

Aparte del que venía usando desde hace un tiempo hoy me he fijado que hay otro que a mí me sale en Filtros/Realzar [Enhance]/Máscara de desenfoque y que muestra una previsualización de lo que está haciendo, cosa que le encuentro a faltar al smart-sharpen.

Saludos

Colegota

  • Palizas oficial
  • *
  • Mensajes: 8188
  • ¡Me faltan carretes!
    • ¡Me faltan carretes!
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #10 on: 14 abr 2008, 19:22 pm »
Buenas,

Código: [Seleccionar]
(script-fu-register "script-fu-unsharp-mask"
    "<Image>/Script-Fu/Alchemy/Unsharp Mask..."

puedes sustituir Unsharp Mask... por otra cosa como "Enfoque dos capas..." y será como lo registre y te aparezca en el menú.

Deja los valores por defecto y prueba una vez en la imagen nueva a cambiar la opacidad de las capas. Sube la de las sombras al 100% y la de las luces hasta que empiecen a "chillar" los puntitos blancos.

Cuando tenga un rato ya pondré algún ejemplo de como usarlo.

Saludos,
Colegota
[Canon EOS 50 40D (sin diapos ni nada)] [Escáner Minolta DSE 5400] [Vuescan] [El GIMP] [Galería] [Página de Viajes]

Colegota

  • Palizas oficial
  • *
  • Mensajes: 8188
  • ¡Me faltan carretes!
    • ¡Me faltan carretes!
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #11 on: 15 abr 2008, 15:50 pm »
Buenas,

Cuando tenga un rato ya pondré algún ejemplo de como usarlo.

de momento he encontrado en google que... ya lo expliqué en su día:ejem:

Eso no quita que en una de estas haga un como un poco más detallado con ejemplos y capturas. Estoy repasando todo el tema de scripts y versiones a ver si al menos me aclaro.

Saludos,
Colegota
[Canon EOS 50 40D (sin diapos ni nada)] [Escáner Minolta DSE 5400] [Vuescan] [El GIMP] [Galería] [Página de Viajes]

tonilupi

  • Consolidad@
  • ****
  • Mensajes: 129
Re: Enfocar con Gimp ¿Sharpen o Unsharp?
« Respuesta #12 on: 26 abr 2008, 19:36 pm »
Colegota, ayer estuve probando el enfoque con el script que colgaste y me dejó francamente satisfecho, los resultados me parecieron mejores que los conseguidos con otros scripts.

Seguiré avanzando con él y ya os contaré.

Saludos