-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy patharto_huotari.gmic
1987 lines (1826 loc) · 71.5 KB
/
arto_huotari.gmic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#@gmic
#
# G'MIC filters from Arto Huotari. All filters lisenced under the same Cecill lisence as G'MIC
#
#####################################################################
# Artistic Folder
#####################################################################
#@gui _<b>Artistic</b>
#****************************************
# Dream smoothing
#****************************************
#@gui Dream Smoothing : fx_dreamsmooth, fx_dreamsmooth_preview(0)
#@gui : note = note("Updated for 1.5.4.0")
#@gui : note = note("A relatively slow filter that uses anisotropic filtering to smooth an image. More iterations produces softer image as does lower opacity values. Practical modes for merging are Alpha and Average. Note that results are resolution dependent.")
#@gui : sep = separator(), note = note("General settings")
#@gui : Iterations = int(3,1,10)
#@gui : Equalize at Each Step = bool(1)
#@gui : sep = separator(), note = note("Merging of iterations")
#@gui : Merging Option = choice(1,"add","alpha","and","average","blue","burn","darken",
#@gui : "difference","divide","dodge","exclusion","freeze",
#@gui : "grainextract","grainmerge","green","hardlight","hardmix",
#@gui : "hue","interpolation","lighten","lightness","linearburn",
#@gui : "linearlight","luminance","multiply","negation","or",
#@gui : "overlay","pinlight","red","reflect","saturation","screen",
#@gui : "shapeaverage","softburn","softdodge","softlight","stamp",
#@gui : "subtract","value","vividlight","xor","edges")
#@gui : Opacity = float(0.8,0,1)
#@gui : Reverse Order = bool(0)
#@gui : note = note("Settings for layer mode edges")
#@gui : Smoothness = float(0.8,0,5)
#@gui : sep = separator()
#@gui : note = note("Parallel processing settings. Increase spatial overlap if vertical bands appear.")
#@gui : Parallel Processing = choice(1,"Auto","One thread","Two threads","Four threads","Eight threads","Sixteen threads")
#@gui : Spatial Overlap = int(24,0,256)
#@gui : sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate top","Duplicate left","Duplicate bottom","Duplicate right","Duplicate horizontal","Duplicate vertical","Checkered","Checkered inverse")
#@gui : sep = separator(), note = note("<small> Author: Arto Huotari Latest update : <i>2014/02/20</i>.</small>")
#@gui : note = link("Sample processing here","http://www.flickr.com/photos/naggobot/7644006608/")
fx_dreamsmooth :
m "MergeChoise : $""=_mode" MergeChoise "add","alpha","and","average","blue","burn","darken","difference","divide","dodge","exclusion","freeze","grainextract","grainmerge","green","hardlight","hardmix","hue","interpolation","lighten","lightness","linearburn","linearlight","luminance","multiply","negation","or","overlay","pinlight","red","reflect","saturation","screen","shapeaverage","softburn","softdodge","softlight","stamp","subtract","value","vividlight","xor","edges","error"
to_color
Iterations=$1
Eqa=$2
MergingOption=$3
Opacity=$4
ReverseOrder=$5
Smoothness=$6
Threads=$7
Overlap=$8
# Handle multiple layers
repeat $! l[$>] split_opacity l[0]
# Enter loop and smooth first image
repeat $Iterations
# Calculate width and height
IWidth={0,round(w/($<+1))}
IHeight={0,round(h/($<+1))}
# Resize previously processed image. Not done on first repeat loop since there is no such image yet.
if $>!=0
# Resize [image_w],[image_h],[image_d],[image_s],_interpolation,_boundary,_ax,_ay,_az,_ac
r. $IWidth,$IHeight,1,3,5,1
fi
# Resize and make a copy
+r[0] $IWidth,$IHeight,1,3,5,1 # Image 1 and on loop 2 image 2 / -1 and -2
# Smoothing
fx_smooth_anisotropic. {430/$Iterations*($<+1)},0.4,0.5,0.6,2,0.8,30,2,0,0,1,0,$Threads,$Overlap,0
fx_smooth_anisotropic. {600/$Iterations*($<+1)},0.4,1,0.6,4,0.8,15,5,0,1,1,0,$Threads,$Overlap,0
# Combine images if not first round
if $>!=0
# Something wrong with this boolean. It does not work.
if $3!=42
blend[-1,-2] ${_mode{$MergingOption+1}},$Opacity,$ReverseOrder
fi
if $3==42
blend_edges[-1,-2] $Opacity,$Smoothness,$ReverseOrder
fi
if $Eqa
equalize. 256
fi
fi
done
k.
# End command for multilayer handling block
done a c done done
fx_dreamsmooth_preview :
gui_split_preview "fx_dreamsmooth ${1--2}",$-1
#****************************************
# Morphology painting
#****************************************
#@gui Morphology Painting : fx_MorphoPaint, fx_MorphoPaint_preview(0)
#@gui : sep = separator()
#@gui : note = note("Creates a painting using Morphology-, Segmentation- and Painting- filters. CPU intensive filter that may take long.")
#@gui : sep = separator()
#@gui : note = note("Morphology settings")
#@gui : sep = separator()
#@gui : Method = choice(1,"Erosion","Dilation","Opening","Closing")
#@gui : MorphoStrenght = int(18,2,60)
#@gui : Shape = choice(2,"Square","Octagonal","Circular")
#@gui : sep = separator()
#@gui : note = note("Lightness for Morpholayer")
#@gui : Black Point = int(25,0,50)
#@gui : Expand Shadows = int(100,50,255)
#@gui : Compress Highlights = int(230,200,255)
#@gui : sep = separator()
#@gui : note = note("Smoothing strength")
#@gui : Spread Amount = int(8,0,20)
#@gui : Blur Strength = int(3,0,10)
#@gui : sep = separator()
#@gui : note = note("Segmentation settings")
#@gui : Edge Threshold = float(4,0,15)
#@gui : Smoothness = float(0.5,0,5)
#@gui : sep = separator()
#@gui : note = note("Painting Settings")
#@gui : Abstraction = int(2,1,10)
#@gui : Details Scale = float(0.5,0,5)
#@gui : Smoothness = float(200,0,1000)
#@gui : sep = separator()
#@gui : Merge Layers? = bool(1)
#@gui : note = note("When unchecked the filter will output layers separately for manual composing. Set G'Mic output to new layers.")
#@gui : sep = separator()
#@gui : Enable Paintstroke = bool(1)
#@gui : Stroke Strength = float(1,0,1)
#@gui : Enable Segmentation = bool(1)
#@gui : Segments Strength= float(1,0,1)
#@gui : Enable Morphology = bool(1)
#@gui : Morphology Strength= float(1,0,1)
#@gui : Normalize = bool(1)
#@gui : sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate top","Duplicate left","Duplicate bottom","Duplicate right","Duplicate horizontal","Duplicate vertical","Checkered","Checkered inverse")
#@gui : sep = separator(), note = note("<small>Author : <i>Arto Huotari</i>. Latest update : <i>2013/09/28</i>.</small>")
#@gui : note = link("Filter Explained here","http://www.flickr.com/photos/naggobot/6108637935/")
fx_MorphoPaint :
to_rgb[0]
+fx_morpho[0] $1,$2,0,2,0,$3,0 # Morpho as nro 1
+fx_apply_curve[1] $4,50,$5,200,$6,-1,128,-1,128,-1,128,255,1,3,0,0,0 # Curved morpho as nro 2
fx_spread[1] $7,$7,0,0 # Spread Morpho nro 1
fx_gaussian_blur[2] $8,0,0,1,0,0,0 # Blur Morpho+Spread nro 1
fx_segment_watershed[1] $9,$10,0,0 # Segment Morpho+Spread+Blur nro 1
+fx_painting[0] $11,$12,1.5,$13,1,0 # Paint from original nro 0
rm[0] # Remove original from stack
rv[0,2] # Reverse images to logical order (Important if output to Gimp)
rv[1,2]
if $14
if $19==0 MorphoStrength={0} elif $19==1 MorphoStrength={$20} fi # Set layer value to zero if enabled
*[2] {$MorphoStrength/3} # Morphology
if $15==0 StrokeStrength={0} elif $15==1 StrokeStrength={$16} fi # Set layer value to zero if enabled
*[0] {$StrokeStrength/3} # Paint stroke
if $17==0 SegmentStrength={0} elif $17==1 SegmentStrength={$18} fi # Set layer value to zero if enabled
*[1] {$SegmentStrength/3} # Segments
+[1] [2] # Combine images
+[1] [0]
if $21 n[1] 0,255 fi # Conditional normalize to get the image to correct range
rm[0,2] # Remove extra images
fi
fx_MorphoPaint_preview :
gui_split_preview "fx_MorphoPaint ${1--2}",$-1
#****************************************
# Simple Noise canvas
#****************************************
#@gui Simple Noise Canvas : fx_SimpleNoiseCanvas, fx_SimpleNoiseCanvasPreview(0)
#@gui : note = note("Simpe noise based xy canvas effect. Preserve canvas and bumpmap image with canvas after filtering for best results. Merge option DoNothing outputs only original image if Preserve canvas option is not selected.")
#@gui : sep = separator()
#@gui : Scale Factor = float(0,0,1)
#@gui : sep = separator()
#@gui : note = note("Noise Parameters")
#@gui : Amplitude = float(3,0,20)
#@gui : Noise Type = choice(2,"Gaussian","Uniform","Salt and Pepper","Poisson")
#@gui : sep = separator()
#@gui : note = note("Thread Length")
#@gui : Horisontal Length = float(5,2,15)
#@gui : Vertical Length = float(5,2,15)
#@gui : Overall Blur = float(0,0,15)
#@gui : Canvas Brightness = float(255,230,255)
#@gui : Canvas Darkness = float(0,0,255)
#@gui : sep = separator()
#@gui : note = note("How to combine XY threads")
#@gui : Merging Option = choice(2,"Average","Multiply","Darken","Edges")
#@gui : Invert Canvas Colors = bool(0)
#@gui : Invert Image Colors = bool(0)
#@gui : note = note("How to combine image + canvas")
#@gui : Reverse Order = bool(0)
#@gui : Merging Option = choice (1,"Avg","Multiply","Scr","Darken","Lighten","Dif","Negation","Exclusion","Overlay","Hardlight","Softlight","Dodge","Colorburn","Reflect","Freeze","Stamp","Interpolate","Grainext","Grainmerge","Xor","Edges","DoNothing")
#@gui : Preserve Canvas for Post Bump Mapping = bool(0)
#@gui : Canvas Color = color(255,255,255,255)
#@gui : sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate top","Duplicate left","Duplicate bottom","Duplicate right","Duplicate horizontal","Duplicate vertical","Checkered","Checkered inverse")
#@gui : sep = separator(), note = note("<small>Author : <i>Arto Huotari</i>. Latest update : <i>2013/09/28</i>.</small>")
#@gui : note = link("Filter Explained here","http://www.flickr.com/photos/naggobot/6152040642/")
fx_SimpleNoiseCanvas :
# Filter has some unnecessary reversing of layers due to change from compose to blend
CanvasScale={$1}
NoiseAmplitude=$2
NoiseType=$3
ThreadHorizLen=$4
ThreadVertLen=$5
OverAllBlur=$6
HighCut=$7
LowCut=$8
CanvasMergeChoice=$9
InvertCanvasColors=$10
InvertImageColors=$11
ReverseChoice=$12
MergeChoice=$13
PreserveCanvas=$14
# (Remember that color is set directly with param 15-17)
# Remove alpha channel from image
to_rgb[0]
# Invert scale factor for scaling
CanvasScale={1.2-$CanvasScale}
# Make white base image with specified color and resize it to inputimage size
(255^255^255)
ri. [0]
# Resize to scale factor
r[1] {100*$CanvasScale}%,{100*$CanvasScale}%
# Add noise
if $NoiseType!=2 NoiseAmplitude={$NoiseAmplitude*10} fi
fx_noise[1] $NoiseAmplitude,$NoiseType,0,1,0
# Make noise BW
fx_ditheredbw[1] 1,1,0,0,0,0 # [G'MIC] B&W dithering
# Blur X for noize, make new image
+fx_gaussian_blur[1] 0,$ThreadHorizLen,0,1,0,0,0 # image 2
# Blur y for noize, make new image
+fx_gaussian_blur[1] 0,0,$ThreadVertLen,1,0,0,0 # image 3
n[2] 0,255
n[3] 0,255
# Combine canvas
if $CanvasMergeChoice==0 blend[2,3] average
elif $CanvasMergeChoice==1 blend[2,3] multiply
elif $CanvasMergeChoice==2 blend[2,3] darken
elif $CanvasMergeChoice==3 blend_edges[2,3] 0.9
fi
# OverAllBlur
fx_gaussian_blur[2] $OverAllBlur,0,0,1,0,0,0 # image 3
# Remove noise image
rm[1]
# Scale canvas back to image size
ri[1] [0]
# Make color and transfer it
($15^$16^$17) # image 2
ri[2] [0]
blend[1,2] multiply
# Adjust range
fx_apply_curve {$LowCut},-1,128,-1,128,-1,128,-1,128,-1,128,{$HighCut},1,3,0,0,0
# Reverse if requested
if $ReverseChoice==1 rv[0,1] fi
# Invert canvas colors if requested
if $InvertCanvasColors==1 negate[1] fi
# Invert Image colors if requested
if $InvertImageColors==1 negate[0] fi
# Combine to original
if $MergeChoice==0 +blend[1,0] average # Image 2
elif $MergeChoice==1 +blend[1,0] multiply
elif $MergeChoice==2 +blend[1,0] screen
elif $MergeChoice==3 +blend[1,0] darken
elif $MergeChoice==4 +blend[1,0] lighten
elif $MergeChoice==5 +blend[1,0] difference
elif $MergeChoice==6 +blend[1,0] negation
elif $MergeChoice==7 +blend[1,0] exclusion
elif $MergeChoice==8 +blend[1,0] overlay
elif $MergeChoice==9 +blend[1,0] hardlight
elif $MergeChoice==10 +blend[1,0] softlight
elif $MergeChoice==11 +blend[1,0] dodge
elif $MergeChoice==12 +blend[1,0] colorburn
elif $MergeChoice==13 +blend[1,0] reflect
elif $MergeChoice==14 +blend[1,0] freeze
elif $MergeChoice==15 +blend[1,0] stamp
elif $MergeChoice==16 +blend[1,0] interpolation
elif $MergeChoice==17 +blend[1,0] grainextract
elif $MergeChoice==18 +blend[1,0] grainmerge
elif $MergeChoice==19 +blend[1,0] xor
elif $MergeChoice==20 +blend_edges[1,0] 0.8
fi
# Reverse original and canvas if it was done previously
if $ReverseChoice==1 rv[0,1] fi
# Remove canvas if not asked to preserve
if $PreserveCanvas==0 rm[1] fi
# PreserveCanvas=1
if $PreserveCanvas==1" && "$MergeChoice!=21 rv[1,2] fi
# Remove original if merging is done
if $MergeChoice!=21 rm[0] fi
# Switch items for correct preview
if $MergeChoice!=21" && "$PreserveCanvas==1 rv[0,1] fi
fx_SimpleNoiseCanvasPreview :
gui_split_preview "fx_SimpleNoiseCanvas ${1--2}",$-1
######################################
# ColorAbstractionPaint
#####################################
#@gui Color Abstraction Paint : fx_ColorAbstractionPaint, fx_ColorAbstractionPaint_Preview(0)
#@gui : Abstraction = int(5,1,10)
#@gui : Ellipse Ratio = float(10,1,100)
#@gui : sep = separator(),note = note("Opacities, try 0 to see individual effect layers")
#@gui : Ellipsionism Opacity = float(1,0,1)
#@gui : sep = separator()
#@gui : Use as Hue = bool(0)
#@gui : Painting Opacity = float(1,-1,1)
#@gui : sep = separator()
#@gui : Use as Saturation = bool(0)
#@gui : Color Abstraction Opacity = float(1,-1,1)
#@gui : Negative Color Abstraction = bool(0)
#@gui : Cubism on Color Abstraction = bool(0)
#@gui : Kuwahara on Painting = bool(0)
#@gui : Soften = float(0,0,100)
#@gui : Soften All Channels = bool(0)
#@gui : DoNotMergeLayers = bool(0)
#@gui : sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate top","Duplicate left","Duplicate bottom","Duplicate right","Duplicate horizontal","Duplicate vertical","Checkered","Checkered inverse")
#@gui : note = link("Sample art here","http://www.flickr.com/photos/naggobot/6640743133/")
#@gui : sep = separator(), note = note("<small>Author : <i>Arto Huotari</i>. Latest update : <i>2014/02/23</i>.</small>")
fx_ColorAbstractionPaint :
# Filter may have some unnecessary reversing of layers due to change from compose to blend
# Alternative merge is Ellipsionism->Value, Painting -> Hue, Color -> Saturation
# Force rgb
to_rgb
# Ellipsionism
pAbstraction=$1
EllipseRatio=$2
ValueOpacity=$3
UseHue=$4
MultiplyOpacity=$5
UseSaturation=$6
GrainMergeOpacity=$7
NCA=$8
CubeIt=$9
KuwaIt=$10
Soften=$11
SoftenAll=$12
DoNotCompose=$13
ReverseOrder0=1
ReverseOrder1=1
ReverseOrder2=1
eSmoothness=1
eOpacity=0.8
eOutline=1
eDensity={1.5*$eSmoothness/10}
# Painting p
pDetailsScale={$pAbstraction/2}
pColor=1.5
pSmoothness={10*$pAbstraction}
# y=y0+(x-x0)(y1-y0)/(x1-x0)
# Smoothness Y goes to 10 from 0 when abstraction X goes to 1 from 10
eSmoothness={10+($pAbstraction-1)*(1-10)/(10-1)}
ePrimaryRadius={0,($pAbstraction/5)*($pAbstraction/5)*sqrt(h)}
eSecondaryRadius={$EllipseRatio/100*$ePrimaryRadius}
cAbstraction={2+($pAbstraction-1)*(10-2)/(10-1)}
# CubeSize={$ePrimaryRadius*$cAbstraction/30}
CubeSize={4+($pAbstraction-1)*(10-4)/(10-1)}
+fx_ellipsionism[0] $ePrimaryRadius,$eSecondaryRadius,$eSmoothness,$eOpacity,1,$eDensity,0 # 1 # -3
if $SoftenAll==1" && "$Soften>0 b. $Soften,0 fi
+fx_painting[0] $pAbstraction,$pDetailsScale,$pColor,$pSmoothness,1,0 # 2 # -2
if $KuwaIt==1 fx_kuwahara. 2,$pAbstraction,0,0 fi
if $Soften>0 b. $Soften,0 fi
+fx_color_abstraction[0] $cAbstraction,45,0.35,0 # 3 # -1
# If negative then invert colors of -1
if $NCA==1 negate. fi
if $CubeIt==1 cubism. 600,$CubeSize,40,0.7,0 fi
if $Soften>0 b. $Soften,0 fi
if $DoNotCompose==0
# Compose Original and Ellipsionism with value
blend[0,1] value,$ValueOpacity,$ReverseOrder0 # 0 # -3
# Compose Original+Ellipsionism with painting
if $MultiplyOpacity<0
ReverseOrder1=0
MultiplyOpacity={-1*$MultiplyOpacity}
fi
if $UseHue==0
blend[0,1] multiply,$MultiplyOpacity,$ReverseOrder1 # 0 # -2
elif $UseHue==1
blend[0,1] hue,$MultiplyOpacity,$ReverseOrder1
fi
# Compose Original+Ellipsionism+Painting with Color abstraction
if $GrainMergeOpacity<0
ReverseOrder2=0
GrainMergeOpacity={-1*$GrainMergeOpacity}
fi
if $UseSaturation==0
blend[0,1] grainmerge,$GrainMergeOpacity,$ReverseOrder2
elif $UseSaturation==1
blend[0,1] saturation,$GrainMergeOpacity,$ReverseOrder2
fi
k[0]
fi
if $DoNotCompose==1 rm[0] fi
fx_ColorAbstractionPaint_Preview :
gui_split_preview "fx_ColorAbstractionPaint ${1--2}",$-1
#****************************************
# Make Squiggly
#****************************************
#@gui Make Squiggly : fx_Squiggly, fx_Squiggly_Preview(0)
#@gui : note = note("Squigles an image")
#@gui : note = note("Squigle parameters")
#@gui : Spread Noise Amount = float(2,0,20)
#@gui : Segmentation Edge Threshold = float(12,0,15)
#@gui : Segmentation Smoothness = float(0.8,0,5)
#@gui : GradienNormSmoothness = float(0,0,10)
#@gui : GradienNormLinearity = float(0.5,0,1.5)
#@gui : Invert Luminance = bool(1)
#@gui : sep = separator()
#@gui : sep = separator()
#@gui : note = note("<b>Optional color enhancement</b>")
#@gui : note = note("Note that the effect of sliders depends on the merge setting.")
#@gui : Activate Color Enhancement = bool(0)
#@gui : Toggle to View Base Image = bool(0), note = note("Check this to view base image")
#@gui : IncreaseChroma1 = float(3,1,4)
#@gui : Tone Threshold = float(0.2,0,1)
#@gui : Tone Gamma = float(0.4,0,1)
#@gui : note = note("Select merging mode to original")
#@gui : Merging Option = choice("Alpha","And","Average","Burn","Darken","Difference","Divide","Dodge","Exclusion","Freeze","Grain extract","Grain merge",
#@gui : "Hard light","Hue","Interpolation","Lighten","Lightness","Luminance","Multiply","Negation","Or","Overlay","Reflect","Saturation",
#@gui : "Soft light","Screen","Stamp","Value","Xor")
#@gui : Opacity = float(1,0,1)
#@gui : Reverse Order = bool(1)
#@gui : sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate top","Duplicate left","Duplicate bottom","Duplicate right","Duplicate horizontal","Duplicate vertical","Checkered","Checkered inverse")
#@gui : sep = separator(), note = note("<small>Author : <i>Arto Huotari</i>. Latest update : <i>2013/09/28</i>.</small>")
#@gui : note = link("Filter Explained here","http://www.flickr.com/photos/naggobot/6667673847/")
fx_Squiggly :
# Variables
SpreadNoiseAmount=$1
SEgThrshld=$2
SegSmooth=$3
GNSmooth=$4
GNLin=$5
InvertLuminance=$6
EnhanceColors=$7
ToggleOrg=$8
Chroma=$9
ToneTr=$10
ToneGm=$11
OrgMergeCh=$12
OrgOpacity=$13
OrgReverseorder=$14
repeat $! l[$>]
# Enable original preview from color enhancement section
if $ToggleOrg==1
OrgMergeCh=30
OrgReverseorder=1
fi
# Remove alpha channel, something goes wrong if image has aplha
to_rgb
+fx_spread[0] $SpreadNoiseAmount,$SpreadNoiseAmount,0,0 # Spread noise (image1)
fx_segment_watershed[1] $SEgThrshld,$SegSmooth,0,0 # Segmentation (image1)
+fx_gradient_norm[1] $GNSmooth,$GNLin,0,100,0,0 # Gradient norm (image2)
# Create colorized squiggle
+blend[2,1] multiply # image 3
# Make bg white
if $InvertLuminance==1
# Convert to LAB
rgb2lab.
# Split channels
s. c
negate...
a[-3--1] c
lab2rgb.
fi
if $EnhanceColors==1
# Increase chroma
fx_mix_ycbcr[3] 1,0,0,$Chroma,0,0,$Chroma,0,0,0,2,0 # image 3
# Tonemap original
fx_map_tones[0] $ToneTr,$ToneGm,0.1,30,0,0 # image 0
# fx_apply_curve[0] 0,30,128,-1,128,-1,128,-1,128,-1,128,255,1,3,0,0,0
# Compose Squigglies to original
fx_blend[0,3] $OrgMergeCh,0,$OrgOpacity,0,0
k[0]
fi
k.
done done
fx_Squiggly_Preview :
gui_split_preview "fx_Squiggly ${1--2}",$-1
#################################################################################################################
#@gui _<b>Details</b>
#################################################################################################################
#******************************************
# USM WITH LCE
#******************************************
#@gui Local Contrast Enhancement : fx_LCE, fx_LCE_preview(0)
#@gui : note = note("Local contrast enhancement is <i>Unsharp Mask</i> with high radius. Apply filter to RGB channels for color and contrast enhancement.")
#@gui : Spatial Radius = float(80,30,200)
#@gui : Amount = float(0.5,0,5)
#@gui : Darkness Level = float(1,0,4)
#@gui : Lightness Level = float(1,0,4)
#@gui : sep = separator(), Channel(s) = choice("All","RGBA [all]","RGB [all]","RGB [red]","RGB [green]","RGB [blue]","RGBA [alpha]","Linear RGB [all]","Linear RGB [red]","Linear RGB [green]","Linear RGB [blue]","YCbCr [luminance]","YCbCr [blue-red chrominances]","YCbCr [blue chrominance]","YCbCr [red chrominance]","YCbCr [green chrominance]","Lab [lightness]","Lab [ab-chrominances]","Lab [a-chrominance]","Lab [b-chrominance]","Lch [ch-chrominances]","Lch [c-chrominance]","Lch [h-chrominance]","HSV [hue]","HSV [saturation]","HSV [value]","HSI [intensity]","HSL [lightness]","CMYK [cyan]","CMYK [magenta]","CMYK [yellow]","CMYK [key]","YIQ [luma]","YIQ [chromas]")
#@gui : sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate top","Duplicate left","Duplicate bottom","Duplicate right","Duplicate horizontal","Duplicate vertical","Checkered","Checkered inverse")
#@gui : note = note{"\n\n<small><b>Note : </b>
#@gui : Original USM code by <i>by David Tschumperlé</i>.
#@gui : </small>"}
#@gui : sep = separator(), note = note("<small>Authors : <i>Arto Huotari, PhotoComiX</i>. Latest update : <i>2013/03/23</i>.</small>")
_fx_LCE :
SpatialRadius=$1
Amount=$2
DarknessLevel=$3
LightnessLevel=$4
# Since LCE a threshold of 0 is used always
Threshold=0
+b. $SpatialRadius
-. .. *. -$Amount
+norm. ge. $Threshold% ri. .. *[-2,-1]
+c. 0,100% c.. -100%,0 *.. $DarknessLevel *. $LightnessLevel +[-2,-1]
+[-2,-1] c. 0,255
fx_LCE :
ac "_fx_LCE $1,$2,$3,$4",$5,0
fx_LCE_preview :
gui_split_preview "fx_LCE ${1--2}",$-1
#******************************************
# YAG effect
#******************************************
#@gui YAG Effect : fx_yag_soften, fx_yag_soften_preview(0)
#@gui : Darken = float(0,0,100)
#@gui : Soften = float(0,0,100)
#@gui : sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate top","Duplicate left","Duplicate bottom","Duplicate right","Duplicate horizontal","Duplicate vertical","Checkered","Checkered inverse")
#@gui : sep = separator(), note = note("<small>Author : <i>Arto Huotari</i>. Latest update : <i>2013/09/28</i>.</small>")
#@gui : note = link("Filter Explained here","http://www.flickr.com/photos/naggobot/6260257923/")
fx_yag_soften :
Darken=$1
Soften=$2
# Make sharpener layer
+fx_laplacian[0] 0,0,100,0,0,0 # image 1
# Blur laplacian
if $Soften>0
fx_gaussian_blur[1] {$Soften/10},0,0,1,0,0,0
fi
# Make soft and vivid
+fx_mix_lab[0] 0.5,50,0.2,1,2,1,1,2,1,0,10,0 # image 2
# Make darkener mask with softlight
# Multiply with previous darkener mask
if $Darken>0
+blend[0,2] softlight # image 3
blend[0,3] multiply,{$Darken/100}
fi
# Compose soft and vidid with hardlight
blend[0,2] hardlight # image0 is modified, image 2 is removed
# Sharpen with grainextract
if $Soften!=100
blend[0,1] grainextract # Image 0 image 1 is removed
elif $Soften==100
rm[1]
fi
fx_yag_soften_preview :
gui_split_preview "fx_yag_soften ${1--2}",$-1
###################################################################################################################
#@gui _<b>Testing</b>
###################################################################################################################
#@gui Naggobot
#******************************************
# Import 16 bit image
#******************************************
#@gui Import 16bits Image : fx_import_image_16, fx_import_image_16
#@gui : note = note("Filter can be used to import and adjust 16 bit images to Gimp. Plugin may have limited set of import formats available depending on compilation. At minimum only .png should work reliably.")
#@gui : note = note("1. Create new empty image to Gimp")
#@gui : note = note("2. Open G'Mic from filters menu")
#@gui : note = note("3. Set G'Mic output to "new layers")
#@gui : note = note("4. Select 16 bit image from folder")
#@gui : note = note("5. Make adjustments using sliders")
#@gui : note = note("6. Image will be outputted to Gimp")
#@gui : note = note("By default a scaled down image is processed. Before processing full size disable preview window from gui.")
#@gui : note = note("LAB adjustment often yields more aesthetic results than RGB adjustment.")
#@gui : Input Image = file()
#@gui : Process Selection = choice(1,"Preview Only", "Histogram", "Logarithmic Histogram", "Full resolution")
#@gui : Gamma = float(2.2,0,5)
#@gui : sep = separator(), note = note("LAB adjustment")
#@gui : Brightness = float(0,-1,1)
#@gui : Contrast = float(1,0,3)
#@gui : Equalize = float(0,0,1)
#@gui : Saturation = float(0,-1,10)
#@gui : A(R-G) = float(0,-1,1)
#@gui : B(Y-B) = float(0,-1,1)
#@gui : sep = separator(), note = note("RGB cut and normalize histogram by percentage")
#@gui : Cut Highlight Values = float(100,0,100)
#@gui : Cut Dark Values = float(0,0,100)
#@gui : sep = separator(), note = note("<small>Author: <i>Arto Huotari;</i>. Latest update: <i>2014/04/02</i>.</small>")
fx_import_image_16 :
# Variables
ProcessTo=$2
Gamma=$3
Brightness=$4
Contrast=$5
Equalize=$6
AB=$7
A=$8
B=$9
CutHigh=$10
CutLow=$11
# Remove import image
rm i
# Import image from disk
"$1"
# Make sure that the input is rgb
to_rgb
# Scale down to preview size
if $ProcessTo!=3
rs 520,,1
fi
apply_gamma $Gamma
# Check if image has pixelvalues over 255
# Correct only for gamma if not
if {0,iM>256}
if $Equalize
+equalize 65535
blend alpha,{$Equalize/2}
fi
# Scale values to 0 to 1 range
/ 65535
# Separate luminance from colour
rgb2lab
s c
if $Brightness
+... $Brightness
fi
if $Contrast!=1
*... $Contrast
fi
# Adjust saturation by multiplying both A and B channels
if $AB
*.. $AB
*. $AB
fi
# Adjust colour balance by multiplying A or B channel.
if $A
*.. {1+$A}
fi
if $B
*. {1+$B}
fi
a c
lab2rgb
# RGB cut and normalize
if $CutHigh!=100" || "$CutLow!=0
Range=1
# Calculate cut high
HighValue={$CutHigh/100*$Range}
# Calculate low value from remaining
LowValue={$CutLow/100*$HighValue}
c $LowValue,$HighValue
n 0,1
fi
# Scale to 255 for Gimp
* 255
# Cut 0,255 for Gimp
c 0,255
if $ProcessTo==1
+display_histogram {0,w},{0,h},255,0,254,0
blend lighten,0.7
fi
if $ProcessTo==2
+display_histogram {0,w},{0,h},255,0,254,0,log(1+i)-1
blend lighten,0.7
fi
fi
#******************************************
# Luminance to alpha
#******************************************
#@gui Luminance to Alpha : fx_split_luminance, fx_split_luminance(1)
#@gui : note = note("Filter splits image to different levels of Luminance. Set preview output to "all outputs". Order of output to Gimp from top to bottom is Midtones,Light,LL,..,Dark,DD,.. If reduced overlap is used then first Light layer is removed from output as redundant if more than one level is processed. Mutilevel output becomes Midtones,,LL,LLL,..,Dark,DD,DDD.. with intermediary light and dark levels containing midtones. ")
#@gui : sep = separator()
#@gui : Levels = int (1,1,6)
#@gui : Output as Alpha = bool(1)
#@gui : Reduce Overlap = bool(1)
#@gui : sep = separator(), note = note("Use keep[] or remove[] to select output images")
#@gui : Keep Custom = bool(0)
#@gui : Keep Custom = text(0,keep.)
#@gui : sep = separator(), note = note("<small>Author: <i>Arto Huotari;</i>. Latest update: <i>2014/04/13</i>.</small>")
intersect_images:
# Create masks to extract
# Extract areas in L that are darker than those in D (white shows light areas)
+lt[0] [1]
*. 255
# Extract areas in D that are darker than those in L (white shows dark areas)
+lt[1] [0]
*. 255
# Subtract booleans from L and D -> areas with selected pixels will go to 0 or below
-[0] .
-[1] ..
# Remove booleans
rm[-1,-2]
# Cut to 0-1 range - remove areas selected by booleans
c[0] 0,255
c[1] 0,255
# Combine images - this image now contains
# midtone area pixels but grey values = image pixel values
+[0] [1]
rm[1]
# Normalize to create mask i.e. pixel with value of 127.5
# will be shown with opacity of 255 when mask is used
create_base_levels:
Levels=$1
# Create Lighter levels
# Darker levels are created by subtracting D from L repeatedly
# there fore Li=L-i*D
repeat $Levels-1
# Multiply D level with loop index+1
+*[2] {$>+1}
# Subtract i*D from L
+-[1] .
rm..
c. 0,255
done
# Create Darker levels
# Ligter levels are created by subtracting L repeatedly from D
repeat $Levels-1
# Multiply L with loop index + 1
+*[1] {$>+1}
# Subtract i*L from D
+-[2] .
rm..
c. 0,255
done
reorder_stack :
Levels=$1
# Subtract overlapping portions from Light masks
# Stack is now
# O, L, D, M, LL,LLL,LLLL,DD,DDD,DDDD
# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
# -10,-9,-8,-7, -6, -5, -4,-3, -2, -1
# Stack needs to be re-arranged to
# O,M,L,LL,LLL,LLLL,D,DD,DDD,DDDD
# O,M, L, D, _ , LL,LLL,LLLL,DD,DDD,DDDD
mv[3] 1
# O,M, L, D, LL,LLL,LLLL,DD,DDD,DDDD
if $Levels>1
rv[2,3]
# O,M, D, L,LL,LLL,LLLL,DD,DDD,DDDD to
# O,M, _ , L,LL,LLL,LLLL,D,DD,DDD,DDDD
mv[2] {-$Levels+1}
fi
reduce_overlap :
Levels=$1
repeat $Levels-1
-[{2+$>}] [{3+$>}]
c[{2+$>}] 0,255
done
repeat $Levels-1
-[{-$Levels+$>}] [{-$Levels+$>+1}]
c[{-$Levels+$>}] 0,255
done
# Subtract brights and lights from midtones
-[1] [{-$Levels-1}]
-[1] .
c[1] 0,255
fx_split_luminance:
Levels=$1
AlphaOutput=$2
ReduceOverlap=$3
KeepCustom=$4
KeepText=$5
to_rgb
# L
+rgb2lab
s. c
rm[-1,-2]
n. 0,255
# D
+negate.
# M
+intersect_images[-1,-2]
if $ReduceOverlap==0
n. 0,255
fi
# Create base levels
create_base_levels $Levels
# Reorder stack
reorder_stack $Levels
# Stack is now O,M,L,LL,LLL,LLLL,D,DD,DDD,DDDD
if $ReduceOverlap==1" && "$Levels>1
reduce_overlap $Levels
fi
repeat $!-1
# add 1 to alpha and cut 0,225 to avoid cutting of colour channels
# no idea why this is necessary, it yields correct results
# Ma and ma are already 0 and even though 1 is added the output is still
# 0 for transparent areas of the mask.
+[{$>+1}] 1
c[$>] 0,255
done
# Combine with original
if $AlphaOutput
repeat $!-1
+a[0,1] c
rm[1]
done
fi
if $ReduceOverlap==1" && "$Levels>1
# D and L are now equal, remove first
rm[2]
fi
# Remove original
rm[0]
if $KeepCustom
$KeepText
fi
#****************************************
# Exposure Fusion weight map
#****************************************
#@gui Exposure Fusion Weight Map : fx_ExposureWeightMap, fx_ExposureWeightMapPreview(1)
#@gui : sep = separator()
#@gui : note = note("Create exposure fusion weight map")
#@gui : sep = separator()
#@gui : note = note("Set filter output to "New layers". Copy filter output to corresponding layer mask. Use aligned layers to combine multiple exposures.")
#@gui : sep = separator()
#@gui : Contrast Bias = float(0.3,0,1)
#@gui : Saturation Bias = float(0.3,0,1)
#@gui : Exposure Sigma = float(0.2,0,1)
#@gui : Exposure Bias = float(0.3,0,1)
#@gui : BlurMap = bool(1)
#@gui : sep = separator(), Preview type = choice("Full","Forward horizontal","Forward vertical","Backward horizontal","Backward vertical","Duplicate top","Duplicate left","Duplicate bottom","Duplicate right","Duplicate horizontal","Duplicate vertical","Checkered","Checkered inverse")
#@gui : sep = separator(), note = note("<small> Author: Arto Huotari Latest update : <i>2014/11/30 v2</i>.</small>")
##@gui : note = link("Based on article","http://research.edm.uhasselt.be/tmertens/papers/exposure_fusion_reduced.pdf")
# Sub, Contrast bias factor, returns absolute laplacian
Sub_Contrast_Bias:
/. 255
to_gray.
laplacian.
abs.
# Sub, Saturation bias factor, returns standard deviatin of picel values
Sub_Saturation_Bias:
# 1: Calculate average values
/. 255
+s[0] c
blend[-1,-2,-3] average # Destroyes images 1,2,3, leaves 0 and 1
# 2: Calculate difference values
s[0] c # images ,0, R1,G2,B3; 0 contains average
# Probable error on removing next image.
# Commented out on 30.11.2014
# rm[0]
+-[0] [1] # images ,0, R1,G2,B3,DR4
rm[1] # images ,0,,G2,B3,DR4
+-[0] [1] # images 0,,G1,B2,DR3,DG4
rm[1] # images ,0,,,B1,DR2,DG3
+-[0] [1] # images 0,,,B1,DR2,DG3,DB4
rm[1] # images ,0,,,,DR1,DG2,DB3
rm[0] # images ,,,,,DR1,DG2,DB3
# Raise to power
^[0] 2 # DR1²
^[1] 2 # DR2²
^[2] 2 # DR3³
# sum
+[1] [2] # DR1²,DR3²+DR2²,DR3²
rm[2]
+[0] [1] # DR1²+(DR3²+DR2²),DR3²+DR2²
rm[1] # DR1²+(DR3²+DR2²)
# Population has three datapoints, divide by 3
/[0] 3
# Standard deviation
sqrt[0]
# Sub, Exposure bias factor
# Wchannel=exp(-(V-0.5)²/(2*sigma*sigma))
# V-0.5
Sub_Exposure_Bias :
/[0] 255
-[0] 0.5
^[0] 2
/[0] {2*$1*$1}
*[0] -1
exp[0]
s[0] c # 1,2,3
*[0] [2]
rm[2]
*[0] [1]
rm[1]
# Sub, Pyramid bluring
Sub_BlurPyramid :
# Calculate size
size={0,min(w,h)}
levels={round(log($size)/log(5))}
Deviation=1
# Scale down and blur
b[0] $Deviation,1,1 # Blur image 100
repeat $levels-1
+resize. 50%,50%,5,1 # Scale subsequently down, create {$levels-1} images
b. $Deviation,1,1 # Blur scaled image
done
# Scale up and blend
blndalpha=0.5
repeat $levels-1
index={-($<+1)} # Image index to blend, start at next step of pyramid and progress to smaller iteratins
resize[$index] [0],5,1
blend[0,$index] alpha,$blndalpha,0
blndalpha={$blndalpha/2} # Reduce opacity of blending by factor of 2 on each iteration
done
# Main, Combined weight
fx_ExposureWeightMap :
wc=$1
ws=$2
sigma=$3
we=$4
BlurMap=$5
to_rgb[0]
+Sub_Contrast_Bias[0] # CB, 0,1
+Sub_Saturation_Bias[0] # SB, 0,1,2
+Sub_Exposure_Bias[0] $sigma # EB, 0,1,2,3
rm[0] # 0,1,2
# Weight W=CB^wc+SB^ws+EB^we
^[0] $wc
^[1] $ws
^[2] $we
+[0] [1]
+[0] [2]
k[0]
n[0] 0,255
# Blur mask
if $BlurMap==1
sub_BlurPyramid[0]
fi
fx_ExposureWeightMapPreview :
gui_split_preview "fx_ExposureWeightMap ${1--2}",$-1
############################
# Smooth sketch
############################
#@gui Smooth Sketch : fx_SmoothSketch, fx_SmoothSketch_preview(0)
#@gui : note = note("Convert image to black and white sketch. By default gradient edges are used but if filter input set to Active and Below a premade edge layer can be used from the layer below. Sketch strength slider will not have any effect if premade edges layer is used.")
#@gui : sep = separator()
#@gui : note = note("Sketch and edges")
#@gui : Create Sketch = bool(1)
#@gui : Sketch Strength = float(6,0,20)
#@gui : Sharpness = float(0.8,0,1)
#@gui : Anisotropy = float(0.3,0.1,1)
#@gui : Smoother Scaling = float(0.3,0.1,2.5)
#@gui : Smoother Degradation = float(0,0,1)
#@gui : Smoothing Amplitude = float(1000,1,3000)
#@gui : Smudge Angle = float(0,-180,180)
#@gui : sep = separator()
#@gui : note = note("Empty area coloring")
#@gui : Coloring Density = float(50,0,200)
#@gui : Coloring Stroke Length = float(10,0,100)
#@gui : Coloring Style = choice(2,"Linear","Angular","Linear wavy","Angular wavy")
#@gui : Coloring Opacity = float(0.6,0,1)
#@gui : sep = separator()
#@gui : note = note("Post processing parameters")