Advertisement
metallaro1980

SharpBlurEdge V2

Mar 22nd, 2019
1,070
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 3.40 KB | None | 0 0
  1. ;plug-in-edge
  2. ;1/0 run-interactive non-interactive
  3. ;image
  4. ;drawable
  5. ;float edge detection amount 1 <= amount <= 10
  6. ;edge detection behavior: none 0, wrap 1, smear 2, black 3
  7. ;edge detection algorithm: sobel 0, prewitt 1, gradient 2, roberts 3, differential 4, laplace 5
  8. ;
  9. ;LAYER-MODE-LCH-LIGHTNESS (27)
  10. ;(plug-in-edge TRUE img Edge1 edgeradius 1 1) Wrap Prewitt
  11. ;Sharpen Layer -> the sharpened layer is sharpened with the unsharp-mask plugin and a level mask created with a desaturated image that in precedence it has been filtered with the detect-edge filter in order to regulate the amount of sharpen.
  12. ;Blur Layer -> the blurred layer is blurred with the gauss-rle plugin and a level mask created with a desaturated and inverted image that in precedence it has been filtered with the detect-edge filter in order to regulate the amount of blur.
  13. ;After you can modify the levels/curves of the two level masks
  14. ;the blend mode of the Sharpen and Blur levels is set to LAYER-MODE-LCH-LIGHTNESS (27)
  15. ;You can also modify the opacity of the Blur level in order to regulate its effect.
  16.  
  17. (define (script-FU-SharpBlurEdge2 img drawable edgeradius radius amount threshold radiusblur)
  18. ;duplico il layer
  19. (gimp-image-undo-group-start img)
  20.  
  21.  
  22. (let* (
  23. (new-flatten (car (gimp-image-flatten img)))
  24. (Edge1 (car (gimp-image-duplicate img)))
  25. (MaskLayer (cadr (gimp-image-get-layers Edge1)))
  26. (Duplicated1 (car (gimp-layer-copy new-flatten 0)))
  27. (Duplicated2 (car (gimp-layer-copy new-flatten 0)))
  28.  
  29. )
  30.  
  31.  
  32. (gimp-item-set-name Duplicated1 "Sharpen")
  33. (gimp-item-set-name Duplicated2 "Blur")
  34.  
  35. (gimp-image-insert-layer img Duplicated1 0 -1)
  36. (gimp-image-insert-layer img Duplicated2 0 -1)
  37.  
  38.  
  39. (gimp-layer-set-mode Duplicated1 27)
  40. (gimp-layer-set-mode Duplicated2 27)
  41.  
  42. (plug-in-edge TRUE Edge1 (aref MaskLayer 0) edgeradius 1 1)
  43. (gimp-convert-grayscale Edge1)
  44.  
  45. (gimp-image-set-active-layer img (car (gimp-image-get-layer-by-name img "Sharpen")))
  46. (plug-in-unsharp-mask 1 img Duplicated1 radius amount threshold)
  47.  
  48. (gimp-image-set-active-layer img (car (gimp-image-get-layer-by-name img "Blur")))
  49. (plug-in-gauss-rle 1 img Duplicated2 radiusblur 1 1)
  50.  
  51.  
  52.  
  53.  
  54. (let* (
  55. (mask (car (gimp-layer-create-mask (car (gimp-image-get-layer-by-name img "Sharpen")) ADD-BLACK-MASK )))
  56. )
  57.  
  58. (gimp-layer-add-mask Duplicated1 mask)
  59. (gimp-selection-all Edge1)
  60. (gimp-edit-copy (aref MaskLayer 0))
  61. (gimp-floating-sel-anchor (car (gimp-edit-paste mask FALSE)))
  62.  
  63.  
  64. (let* (
  65. (mask2 (car (gimp-layer-create-mask (car (gimp-image-get-layer-by-name img "Blur")) ADD-BLACK-MASK )))
  66. )
  67.  
  68. (gimp-layer-add-mask Duplicated2 mask2)
  69. (gimp-selection-all Edge1)
  70. (gimp-edit-copy (aref MaskLayer 0))
  71. (gimp-floating-sel-anchor (car (gimp-edit-paste mask2 FALSE)))
  72. (gimp-drawable-invert mask2 FALSE)
  73.  
  74. (gimp-image-delete Edge1)
  75.  
  76.  
  77. )))
  78.  
  79.  
  80.  
  81.  
  82.  
  83. (gimp-image-undo-group-end img)
  84. (gimp-displays-flush)
  85. )
  86.  
  87.  
  88.  
  89. (script-fu-register
  90. "script-FU-SharpBlurEdge2"
  91. _"SharpBlurEdge V2"
  92. _""
  93. "Andrea Verdi"
  94. "Andrea Verdi"
  95. "2018"
  96. "RGB*"
  97. SF-IMAGE "Image" 0
  98. SF-DRAWABLE "Drawable" 0
  99.   SF-ADJUSTMENT _"Radius edge"  '(1 0.1 10.0 0.1 1.0 1 0)
  100.   SF-ADJUSTMENT _"Radius sharpen"   '(0.3 0.1 10.0 0.1 1.0 1 0)
  101.   SF-ADJUSTMENT _"Amount sharpen"   '(0.4 0.1 10.0 0.01 1.0 2 0)
  102.   SF-ADJUSTMENT _"Threshold sharpen"    '(0 0 255 1 5 0 0)
  103.   SF-ADJUSTMENT _"Radius Blur " '(0.3 0.1 10.0 0.1 1.0 1 0)
  104. )
  105.  
  106. (script-fu-menu-register "script-FU-SharpBlurEdge2"
  107.                          "<Image>/Filters/Image/")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement