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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
|
/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using UVtools.Core.Extensions;
using UVtools.Core.FileFormats;
using UVtools.Core.Objects;
namespace UVtools.Core.Operations;
[Serializable]
public class OperationPixelArithmetic : Operation
{
#region Enums
public enum PixelArithmeticIgnoreAreaOperator
{
[Description("Smaller than")]
SmallerThan,
[Description("Larger than")]
LargerThan
}
#endregion
#region Subclasses
class StringMatrix
{
public string Text { get; }
public Matrix<byte> Pattern { get; set; } = null!;
public StringMatrix(string text)
{
Text = text;
}
}
#endregion
#region Members
private PixelArithmeticOperators _operator = PixelArithmeticOperators.Set;
private PixelArithmeticApplyMethod _applyMethod = PixelArithmeticApplyMethod.Model;
private uint _wallThicknessStart = 20;
private uint _wallThicknessEnd = 20;
private bool _wallChamfer;
private PixelArithmeticIgnoreAreaOperator _ignoreAreaOperator = PixelArithmeticIgnoreAreaOperator.SmallerThan;
private uint _ignoreAreaThreshold;
private byte _value = byte.MaxValue;
private bool _usePattern;
private ThresholdType _thresholdType = ThresholdType.Binary;
private byte _thresholdMaxValue = 255;
private ushort _patternAlternatePerLayersNumber = 1;
private bool _patternInvert;
private string _patternText = null!;
private string _patternTextAlternate = null!;
private Matrix<byte> _pattern = null!;
private Matrix<byte>? _patternAlternate;
private byte _patternGenMinBrightness;
private byte _patternGenBrightness = 128;
private byte _patternGenInfillThickness = 10;
private byte _patternGenInfillSpacing = 20;
private short _noiseMinOffset = -128;
private short _noiseMaxOffset = 128;
private byte _noiseThreshold;
private ushort _noisePixelArea = 1;
private byte _noisePasses = 1;
#endregion
#region Enums
public enum PixelArithmeticOperators : byte
{
[Description("Set: to a brightness")]
Set,
[Description("Add: with a brightness")]
Add,
[Description("Subtract: with a brightness")]
Subtract,
[Description("Multiply: with a brightness")]
Multiply,
[Description("Divide: with a brightness")]
Divide,
//[Description("Exponential: pixels by a brightness")]
//Exponential,
[Description("Minimum: set to a brightness if is lower than the current pixel")]
Minimum,
[Description("Maximum: set to a brightness if is higher than the current pixel")]
Maximum,
[Description("Bitwise Not: invert pixels")]
BitwiseNot,
[Description("Bitwise And: with a brightness")]
BitwiseAnd,
[Description("Bitwise Or: with a brightness")]
BitwiseOr,
[Description("Bitwise Xor: with a brightness")]
BitwiseXor,
[Description("AbsDiff: perform a absolute difference between pixel and brightness")]
AbsDiff,
[Description("Corrode: Diffuse pixels using uniform random noise")]
Corrode,
[Description("Threshold: between a minimum/maximum brightness")]
Threshold,
[Description("Keep Region: in the selected ROI or masks")]
KeepRegion,
[Description("Discard Region: in the selected ROI or masks")]
DiscardRegion,
}
public enum PixelArithmeticApplyMethod : byte
{
[Description("All: Apply to all pixels within the layer")]
All,
[Description("Model: Apply only to model pixels")]
Model,
[Description("Model surface: Apply only to model surface/visible pixels")]
ModelSurface,
[Description("Model surface & inset: Apply only to model surface/visible pixels and within a inset from walls")]
ModelSurfaceAndInset,
[Description("Model inner: Apply only to model pixels within a margin from walls")]
ModelInner,
[Description("Model walls: Apply only to model walls with a set thickness")]
ModelWalls,
//[Description("Model walls minimum: Apply only to model walls where walls must have at least a minimum set thickness")]
//ModelWallsMinimum
}
#endregion
#region Overrides
public override string IconClass => "mdi-circle-opacity";
public override string Title => "Pixel arithmetic";
public override string Description =>
"Perform arithmetic operations over the pixels.";
public override string ConfirmationText =>
$"arithmetic {_operator}" +
(ValueEnabled && !_usePattern ? $"={_value}" : string.Empty) +
(_usePattern && IsUsePatternVisible ? " with pattern" : string.Empty) +
(_operator is PixelArithmeticOperators.Threshold ? $"/{_thresholdMaxValue}" : string.Empty)
+ $" layers from {LayerIndexStart} through {LayerIndexEnd}";
public override string ProgressTitle =>
$"Arithmetic {_operator}"+
(ValueEnabled && !_usePattern ? $"={_value}" : string.Empty) +
(_usePattern && IsUsePatternVisible ? " with pattern" : string.Empty) +
$" layers from {LayerIndexStart} through {LayerIndexEnd}";
public override string ProgressAction => "Calculated layers";
public override string? ValidateInternally()
{
var sb = new StringBuilder();
if (_operator == PixelArithmeticOperators.KeepRegion && !HaveROI && !HaveMask)
{
sb.AppendLine("The 'Keep' operator requires selected ROI/masks.");
}
else if (_operator == PixelArithmeticOperators.DiscardRegion && !HaveROI && !HaveMask)
{
sb.AppendLine("The 'Discard' operator requires selected ROI/masks.");
}
else if (_operator
is PixelArithmeticOperators.Add
or PixelArithmeticOperators.Subtract
or PixelArithmeticOperators.Maximum
or PixelArithmeticOperators.BitwiseOr
or PixelArithmeticOperators.BitwiseXor
or PixelArithmeticOperators.AbsDiff
&& _value == 0)
/*||
(_operator is PixelArithmeticOperators.Exponential && _value == 1)
)*/
{
sb.AppendLine($"{_operator} by {_value} will have no effect.");
}
else if (_operator == PixelArithmeticOperators.Divide && _value == 0)
{
sb.AppendLine("Can't divide by 0.");
}
else if (_operator == PixelArithmeticOperators.Corrode && _noiseMinOffset >= _noiseMaxOffset)
{
sb.AppendLine("Minimum noise offset must be less than the maximum offset.");
}
if (_applyMethod is PixelArithmeticApplyMethod.ModelWalls //or PixelArithmeticApplyMethod.ModelWallsMinimum
&& (
(_wallChamfer && _wallThicknessStart == 0 && _wallThicknessEnd == 0) ||
(!_wallChamfer && _wallThicknessStart == 0)
)
)
{
sb.AppendLine("The current wall settings will have no effect.");
}
if (_usePattern && IsUsePatternVisible)
{
var stringMatrix = new[]
{
new StringMatrix(PatternText),
new StringMatrix(PatternTextAlternate),
};
foreach (var item in stringMatrix)
{
if (string.IsNullOrWhiteSpace(item.Text)) continue;
var lines = item.Text.Split('\n', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
for (var row = 0; row < lines.Length; row++)
{
var bytes = lines[row].Split(' ');
if (row == 0)
{
item.Pattern = new Matrix<byte>(lines.Length, bytes.Length);
}
else
{
if (item.Pattern.Cols != bytes.Length)
{
sb.AppendLine($"Row {row + 1} have invalid number of pixels, the pattern must have equal pixel count per line, per defined on line 1");
return sb.ToString();
}
}
for (int col = 0; col < bytes.Length; col++)
{
if (byte.TryParse(bytes[col], out var value))
{
item.Pattern[row, col] = (byte)(_patternInvert ? byte.MaxValue - value : value);
}
else
{
sb.AppendLine($"{bytes[col]} is a invalid number, use values from 0 to 255");
return sb.ToString();
}
}
}
}
_pattern = stringMatrix[0].Pattern;
_patternAlternate = stringMatrix[1].Pattern;
if (_pattern is null && _patternAlternate is null)
{
sb.AppendLine("Either even or odd pattern must contain a valid matrix.");
return sb.ToString();
}
}
return sb.ToString();
}
public override string ToString()
{
var result = $"[{_operator}: {_value}] [Apply: {_applyMethod}] " +
$"[Pattern: {_usePattern}]"
+ LayerRangeString;
if (!string.IsNullOrEmpty(ProfileName)) result = $"{ProfileName}: {result}";
return result;
}
#endregion
#region Properties
public PixelArithmeticOperators Operator
{
get => _operator;
set
{
if(!RaiseAndSetIfChanged(ref _operator, value)) return;
RaisePropertyChanged(nameof(ValueEnabled));
RaisePropertyChanged(nameof(IsUsePatternVisible));
RaisePropertyChanged(nameof(IsThresholdVisible));
RaisePropertyChanged(nameof(IsApplyMethodEnabled));
RaisePropertyChanged(nameof(IsCorrodeVisible));
}
}
public bool IsApplyMethodEnabled =>
_operator is not (PixelArithmeticOperators.KeepRegion or PixelArithmeticOperators.DiscardRegion);
public PixelArithmeticApplyMethod ApplyMethod
{
get => _applyMethod;
set
{
if(!RaiseAndSetIfChanged(ref _applyMethod, value)) return;
RaisePropertyChanged(nameof(IsWallSettingVisible));
}
}
public bool IsWallSettingVisible => _applyMethod
is PixelArithmeticApplyMethod.ModelSurfaceAndInset
or PixelArithmeticApplyMethod.ModelInner
or PixelArithmeticApplyMethod.ModelWalls; //or PixelArithmeticApplyMethod.ModelWallsMinimum;
public uint WallThickness
{
get => _wallThicknessStart;
set
{
WallThicknessStart = value;
WallThicknessEnd = value;
}
}
public uint WallThicknessStart
{
get => _wallThicknessStart;
set => RaiseAndSetIfChanged(ref _wallThicknessStart, value);
}
public uint WallThicknessEnd
{
get => _wallThicknessEnd;
set => RaiseAndSetIfChanged(ref _wallThicknessEnd, value);
}
public bool WallChamfer
{
get => _wallChamfer;
set => RaiseAndSetIfChanged(ref _wallChamfer, value);
}
public PixelArithmeticIgnoreAreaOperator IgnoreAreaOperator
{
get => _ignoreAreaOperator;
set => RaiseAndSetIfChanged(ref _ignoreAreaOperator, value);
}
public uint IgnoreAreaThreshold
{
get => _ignoreAreaThreshold;
set => RaiseAndSetIfChanged(ref _ignoreAreaThreshold, value);
}
public bool IsCorrodeVisible => _operator is PixelArithmeticOperators.Corrode;
public short NoiseMinOffset
{
get => _noiseMinOffset;
set => RaiseAndSetIfChanged(ref _noiseMinOffset, value);
}
public short NoiseMaxOffset
{
get => _noiseMaxOffset;
set => RaiseAndSetIfChanged(ref _noiseMaxOffset, value);
}
public byte NoiseThreshold
{
get => _noiseThreshold;
set => RaiseAndSetIfChanged(ref _noiseThreshold, value);
}
public ushort NoisePixelArea
{
get => _noisePixelArea;
set => RaiseAndSetIfChanged(ref _noisePixelArea, Math.Max((byte)1, value));
}
public byte NoisePasses
{
get => _noisePasses;
set => RaiseAndSetIfChanged(ref _noisePasses, Math.Max((byte)1, value));
}
public byte Value
{
get => _value;
set
{
if(!RaiseAndSetIfChanged(ref _value, value)) return;
RaisePropertyChanged(nameof(ValuePercent));
}
}
// 255 - 100
//value - x
public float ValuePercent => (float) Math.Round(_value * 100f / byte.MaxValue, 2);
public bool ValueEnabled => _operator
is not PixelArithmeticOperators.BitwiseNot
and not PixelArithmeticOperators.KeepRegion
and not PixelArithmeticOperators.DiscardRegion
and not PixelArithmeticOperators.Corrode
;
public bool IsUsePatternVisible => _operator
is not PixelArithmeticOperators.Threshold
and not PixelArithmeticOperators.BitwiseNot
and not PixelArithmeticOperators.KeepRegion
and not PixelArithmeticOperators.DiscardRegion
and not PixelArithmeticOperators.Corrode
;
public bool UsePattern
{
get => _usePattern;
set => RaiseAndSetIfChanged(ref _usePattern, value);
}
public ThresholdType ThresholdType
{
get => _thresholdType;
set => RaiseAndSetIfChanged(ref _thresholdType, value);
}
public byte ThresholdMaxValue
{
get => _thresholdMaxValue;
set => RaiseAndSetIfChanged(ref _thresholdMaxValue, value);
}
public bool IsThresholdVisible => _operator is PixelArithmeticOperators.Threshold;
/*public bool AffectBackPixelsEnabled => _operator
is not PixelArithmeticOperators.Subtract
and not PixelArithmeticOperators.Multiply
and not PixelArithmeticOperators.Divide
and not PixelArithmeticOperators.BitwiseNot
and not PixelArithmeticOperators.BitwiseAnd
and not PixelArithmeticOperators.KeepRegion
and not PixelArithmeticOperators.DiscardRegion
and not PixelArithmeticOperators.Threshold
;*/
public ushort PatternAlternatePerLayersNumber
{
get => _patternAlternatePerLayersNumber;
set => RaiseAndSetIfChanged(ref _patternAlternatePerLayersNumber, value);
}
public bool PatternInvert
{
get => _patternInvert;
set => RaiseAndSetIfChanged(ref _patternInvert, value);
}
public string PatternText
{
get => _patternText;
set => RaiseAndSetIfChanged(ref _patternText, value);
}
public string PatternTextAlternate
{
get => _patternTextAlternate;
set => RaiseAndSetIfChanged(ref _patternTextAlternate, value);
}
[XmlIgnore]
public Matrix<byte> Pattern
{
get => _pattern;
set => RaiseAndSetIfChanged(ref _pattern, value);
}
[XmlIgnore]
public Matrix<byte>? PatternAlternate
{
get => _patternAlternate;
set => RaiseAndSetIfChanged(ref _patternAlternate, value);
}
public byte PatternGenMinBrightness
{
get => _patternGenMinBrightness;
set => RaiseAndSetIfChanged(ref _patternGenMinBrightness, value);
}
public byte PatternGenBrightness
{
get => _patternGenBrightness;
set
{
RaiseAndSetIfChanged(ref _patternGenBrightness, value);
RaisePropertyChanged(nameof(PatternGenBrightnessPercent));
}
}
public float PatternGenBrightnessPercent => Helpers.BrightnessToPercent(_patternGenBrightness);
public byte PatternGenInfillThickness
{
get => _patternGenInfillThickness;
set => RaiseAndSetIfChanged(ref _patternGenInfillThickness, value);
}
public byte PatternGenInfillSpacing
{
get => _patternGenInfillSpacing;
set => RaiseAndSetIfChanged(ref _patternGenInfillSpacing, value);
}
public KernelConfiguration Kernel { get; set; } = new();
#endregion
#region Constructor
public OperationPixelArithmetic() { }
public OperationPixelArithmetic(FileFormat slicerFile) : base(slicerFile) { }
#endregion
#region Methods
private Size GetMatSizeCropped(Mat? mat = null)
{
return _applyMethod == PixelArithmeticApplyMethod.All ? GetRoiSizeOrDefault(mat) : GetRoiSizeOrDefault(OriginalBoundingRectangle);
}
private Mat GetMatRoiCropped(Mat mat)
{
return _applyMethod == PixelArithmeticApplyMethod.All ? GetRoiOrDefault(mat) : GetRoiOrVolumeBounds(mat);
}
protected override bool ExecuteInternally(OperationProgress progress)
{
Mat? patternMat = null;
Mat? patternAlternateMat = null;
Mat patternMatMask = null!;
Mat patternAlternateMatMask = null!;
var anchor = new Point(-1, -1);
if (_usePattern && IsUsePatternVisible)
{
if (_pattern is null)
{
_pattern = new Matrix<byte>(2, 2)
{
[0, 0] = 0,
[0, 1] = 127,
[1, 0] = 127,
[1, 1] = 0,
};
_patternAlternate ??= new Matrix<byte>(2, 2)
{
[0, 0] = 127,
[0, 1] = 0,
[1, 0] = 0,
[1, 1] = 127,
};
}
_patternAlternate ??= _pattern;
var target = new Mat(GetMatSizeCropped(), DepthType.Cv8U, 1);
patternMat = target.NewBlank();
patternAlternateMat = target.NewBlank();
CvInvoke.Repeat(_pattern, (int)Math.Ceiling((double)target.Rows / _pattern.Rows), (int)Math.Ceiling((double)target.Cols / _pattern.Cols), patternMat);
CvInvoke.Repeat(_patternAlternate, (int)Math.Ceiling((double)target.Rows / _patternAlternate.Rows), (int)Math.Ceiling((double)target.Cols / _patternAlternate.Cols), patternAlternateMat);
patternMatMask = patternMat.Roi(target);
patternAlternateMatMask = patternAlternateMat.Roi(target);
/*if (_patternInvert)
{
CvInvoke.BitwiseNot(patternMatMask, patternMatMask);
CvInvoke.BitwiseNot(patternAlternateMatMask, patternAlternateMatMask);
}*/
}
else if (IsUsePatternVisible)
{
patternMatMask = EmguExtensions.InitMat(GetMatSizeCropped(), new MCvScalar(_value));
}
Parallel.For(LayerIndexStart, LayerIndexEnd + 1, CoreSettings.GetParallelOptions(progress), layerIndex =>
{
var layer = SlicerFile[layerIndex];
using (var mat = layer.LayerMat)
{
using var original = mat.Clone();
var originalRoi = GetMatRoiCropped(original);
var target = GetMatRoiCropped(mat);
Mat tempMat;
if (_usePattern && IsUsePatternVisible)
{
tempMat = IsNormalPattern((uint)layerIndex) ? patternMatMask : patternAlternateMatMask;
}
else
{
tempMat = patternMatMask;
}
Mat? applyMask;
int wallThickness = FileFormat.MutateGetIterationChamfer(
(uint)layerIndex,
LayerIndexStart,
LayerIndexEnd,
(int)_wallThicknessStart,
(int)_wallThicknessEnd,
_wallChamfer
);
switch (_applyMethod)
{
case PixelArithmeticApplyMethod.All:
applyMask = null;
break;
case PixelArithmeticApplyMethod.Model:
applyMask = target.Clone();
break;
case PixelArithmeticApplyMethod.ModelSurface:
case PixelArithmeticApplyMethod.ModelSurfaceAndInset:
if (layerIndex == SlicerFile.LastLayerIndex)
{
applyMask = target.Clone();
}
else
{
applyMask = new Mat();
// Difference
using var nextMat = SlicerFile[layerIndex + 1].LayerMat;
var nextMatRoi = GetMatRoiCropped(nextMat);
CvInvoke.Subtract(target, nextMatRoi, applyMask);
// 1px walls
using var erode = new Mat();
int iterations = 1;
var kernel = Kernel.GetKernel(ref iterations);
CvInvoke.Erode(target, erode, kernel, anchor, iterations, BorderType.Reflect101, default);
CvInvoke.Subtract(target, erode, erode);
CvInvoke.Add(applyMask, erode, applyMask);
// Inset from walls
if (_applyMethod == PixelArithmeticApplyMethod.ModelSurfaceAndInset && (wallThickness-1) > 0)
{
iterations = wallThickness - 1;
kernel = Kernel.GetKernel(ref iterations);
CvInvoke.Dilate(applyMask, erode, kernel, anchor, iterations, BorderType.Reflect101, default);
erode.CopyTo(applyMask, target);
}
}
break;
case PixelArithmeticApplyMethod.ModelInner:
{
if (wallThickness <= 0)
{
applyMask = target.Clone();
break;
}
applyMask = new Mat();
int iterations = wallThickness;
var kernel = Kernel.GetKernel(ref iterations);
CvInvoke.Erode(target, applyMask, kernel, anchor, iterations, BorderType.Reflect101, default);
break;
}
case PixelArithmeticApplyMethod.ModelWalls:
{
if (wallThickness <= 0) // No effect, skip
{
progress.LockAndIncrement();
return;
}
using var erode = new Mat();
applyMask = target.Clone();
int iterations = wallThickness;
var kernel = Kernel.GetKernel(ref iterations);
CvInvoke.Erode(target, erode, kernel, anchor, iterations, BorderType.Reflect101, default);
applyMask.SetTo(EmguExtensions.BlackColor, erode);
break;
}
/*case PixelArithmeticApplyMethod.ModelWallsMinimum:
{
if (wallThickness <= 0) // No effect, skip
{
progress.LockAndIncrement();
return;
}
using var erode = new Mat();
using var erodeInv = new Mat();
applyMask = target.Clone();
target.Save($"D:\\wallmin\\original{layerIndex}.png");
CvInvoke.Erode(target, erode, kernel, anchor, wallThickness, BorderType.Reflect101, default);
erode.Save($"D:\\wallmin\\erode{layerIndex}.png");
CvInvoke.Dilate(erode, erode, kernel, anchor, wallThickness, BorderType.Reflect101, default);
erode.Save($"D:\\wallmin\\dilate{layerIndex}.png");
//CvInvoke.BitwiseXor(target, erode, applyMask);
//applyMask.Save($"D:\\wallmin\\bitwiseXor{layerIndex}.png");
CvInvoke.BitwiseNot(erode, erodeInv);
erodeInv.Save($"D:\\wallmin\\erodeInv{layerIndex}.png");
CvInvoke.BitwiseXor(target, erode, erode, erodeInv);
erode.Save($"D:\\wallmin\\BitwiseXor{layerIndex}.png");
applyMask.SetTo(EmguExtensions.BlackColor, erode);
applyMask.Save($"D:\\wallmin\\applymask{layerIndex}.png");
break;
}*/
default:
throw new ArgumentOutOfRangeException();
}
switch (_operator)
{
case PixelArithmeticOperators.Set:
tempMat.CopyTo(target, applyMask);
break;
case PixelArithmeticOperators.Add:
CvInvoke.Add(target, tempMat, target, applyMask);
break;
case PixelArithmeticOperators.Subtract:
CvInvoke.Subtract(target, tempMat, target, applyMask);
break;
case PixelArithmeticOperators.Multiply:
CvInvoke.Multiply(target, tempMat, target);
if (_applyMethod != PixelArithmeticApplyMethod.All) ApplyMask(originalRoi, target, applyMask);
break;
case PixelArithmeticOperators.Divide:
CvInvoke.Divide(target, tempMat, target);
if (_applyMethod != PixelArithmeticApplyMethod.All) ApplyMask(originalRoi, target, applyMask);
break;
/*case PixelArithmeticOperators.Exponential:
CvInvoke.Pow(target, _value, tempMat);
if(!_affectBackPixels) ApplyMask(original, mat, original);
break;*/
case PixelArithmeticOperators.Minimum:
CvInvoke.Min(target, tempMat, target);
if (_applyMethod != PixelArithmeticApplyMethod.All) ApplyMask(originalRoi, target, applyMask);
break;
case PixelArithmeticOperators.Maximum:
CvInvoke.Max(target, tempMat, target);
if (_applyMethod != PixelArithmeticApplyMethod.All) ApplyMask(originalRoi, target, applyMask);
break;
case PixelArithmeticOperators.BitwiseNot:
CvInvoke.BitwiseNot(target, target, applyMask);
break;
case PixelArithmeticOperators.BitwiseAnd:
CvInvoke.BitwiseAnd(target, tempMat, target, applyMask);
break;
case PixelArithmeticOperators.BitwiseOr:
CvInvoke.BitwiseOr(target, tempMat, target, applyMask);
break;
case PixelArithmeticOperators.BitwiseXor:
CvInvoke.BitwiseXor(target, tempMat, target, applyMask);
break;
case PixelArithmeticOperators.AbsDiff:
CvInvoke.AbsDiff(target, tempMat, target);
if (_applyMethod != PixelArithmeticApplyMethod.All) ApplyMask(originalRoi, target, applyMask);
break;
case PixelArithmeticOperators.Threshold:
var tempThreshold = _thresholdType;
if (_thresholdType is ThresholdType.Otsu or ThresholdType.Triangle) tempThreshold = ThresholdType.Binary | tempThreshold;
CvInvoke.Threshold(target, target, _value, _thresholdMaxValue, tempThreshold);
if (_applyMethod != PixelArithmeticApplyMethod.All) ApplyMask(originalRoi, target, applyMask);
break;
case PixelArithmeticOperators.Corrode:
var span = mat.GetDataByteSpan();
var random = new Random();
var bounds = HaveROI ? ROI : layer.BoundingRectangle;
for (var y = bounds.Y; y < bounds.Bottom; y += _noisePixelArea)
for (var x = bounds.X; x < bounds.Right; x += _noisePixelArea)
{
byte zoneBrightness = 0;
for (var y1 = y; y1 < y + _noisePixelArea && y1 < bounds.Bottom && zoneBrightness < byte.MaxValue; y1++)
{
var pixelPos = mat.GetPixelPos(x, y1);
for (var x1 = x; x1 < x + _noisePixelArea && x1 < bounds.Right && zoneBrightness < byte.MaxValue; x1++)
{
zoneBrightness = Math.Max(zoneBrightness, span[pixelPos++]);
}
}
if (zoneBrightness <= _noiseThreshold) continue;
byte brightness = zoneBrightness;
for (ushort i = 0; i < _noisePasses; i++)
{
brightness = (byte)Math.Clamp(random.Next(_noiseMinOffset, _noiseMaxOffset + 1) + brightness, byte.MinValue, byte.MaxValue);
}
//byte brightness = (byte)Math.Clamp(RandomNumberGenerator.GetInt32(_noiseMinOffset, _noiseMaxOffset + 1) + zoneBrightness, byte.MinValue, byte.MaxValue);
for (var y1 = y; y1 < y + _noisePixelArea && y1 < bounds.Bottom; y1++)
{
var pixelPos = mat.GetPixelPos(x, y1);
for (var x1 = x; x1 < x + _noisePixelArea && x1 < bounds.Right; x1++)
{
if (span[pixelPos] <= _noiseThreshold) continue;
span[pixelPos++] = brightness;
}
}
}
if (_applyMethod is not PixelArithmeticApplyMethod.All and not PixelArithmeticApplyMethod.Model) ApplyMask(originalRoi, target, applyMask);
// old method
/*if (HaveROI)
{
for (var y = ROI.Y; y < ROI.Bottom; y++)
for (var x = ROI.X; x < ROI.Right; x++)
{
var pos = mat.GetPixelPos(x, y);
if (span[pos] <= _noiseThreshold) continue;
span[pos] = (byte)Math.Clamp(RandomNumberGenerator.GetInt32(_noiseMinOffset, _noiseMaxOffset + 1) + span[pos], byte.MinValue, byte.MaxValue);
}
if (_applyMethod
is not PixelArithmeticApplyMethod.All
and not PixelArithmeticApplyMethod.Model)
ApplyMask(originalRoi, target, applyMask);
}
else // Whole image
{
var spanMask = applyMask is null ? span : applyMask.GetDataByteSpan();
for (var i = 0; i < span.Length; i++)
{
//if (span[i] <= _noiseThreshold || spanMask[i] == 0) continue;
//span[i] = (byte)Math.Clamp(RandomNumberGenerator.GetInt32(_noiseMinOffset, _noiseMaxOffset + 1) + span[i], byte.MinValue, byte.MaxValue);
span[i] = (byte)Math.Clamp(random.Next(_noiseMinOffset, _noiseMaxOffset + 1) + span[i], byte.MinValue, byte.MaxValue);
}
}*/
break;
case PixelArithmeticOperators.KeepRegion:
{
using var targetClone = target.Clone();
original.SetTo(EmguExtensions.BlackColor);
mat.SetTo(EmguExtensions.BlackColor);
targetClone.CopyTo(target);
break;
}
case PixelArithmeticOperators.DiscardRegion:
target.SetTo(EmguExtensions.BlackColor);
break;
default:
throw new NotImplementedException();
}
switch (_ignoreAreaOperator)
{
case PixelArithmeticIgnoreAreaOperator.SmallerThan:
originalRoi.CopyAreasSmallerThan(_ignoreAreaThreshold, target);
break;
case PixelArithmeticIgnoreAreaOperator.LargerThan:
originalRoi.CopyAreasLargerThan(_ignoreAreaThreshold, target);
break;
default:
throw new ArgumentOutOfRangeException(nameof(_ignoreAreaOperator));
}
ApplyMask(originalRoi, target);
SlicerFile[layerIndex].LayerMat = mat;
if (applyMask is not null && !ReferenceEquals(applyMask, target)) applyMask.Dispose();
}
progress.LockAndIncrement();
});
patternMat?.Dispose();
patternAlternateMat?.Dispose();
return !progress.Token.IsCancellationRequested;
}
public bool IsNormalPattern(uint layerIndex) => layerIndex / _patternAlternatePerLayersNumber % 2 == 0;
public bool IsAlternatePattern(uint layerIndex) => !IsNormalPattern(layerIndex);
public void PresetElephantFootCompensation()
{
SelectBottomLayers();
Operator = PixelArithmeticOperators.Set;
ApplyMethod = PixelArithmeticApplyMethod.ModelWalls;
//Value = 190;
//WallThickness = 20;
WallChamfer = false;
UsePattern = false;
}
public void PresetPixelDimming()
{
Operator = PixelArithmeticOperators.Subtract;
ApplyMethod = PixelArithmeticApplyMethod.ModelInner;
//WallThickness = 20;
WallChamfer = false;
UsePattern = true;
}
public void PresetPixelLightening()
{
PresetPixelDimming();
Operator = PixelArithmeticOperators.Add;
}
public void PresetFuzzySkin()
{
Operator = PixelArithmeticOperators.Corrode;
ApplyMethod = PixelArithmeticApplyMethod.ModelSurfaceAndInset;
NoiseMinOffset = -200;
NoiseMaxOffset = 64;
WallThickness = 4;
IgnoreAreaOperator = PixelArithmeticIgnoreAreaOperator.SmallerThan;
IgnoreAreaThreshold = 5000;
}
public void PresetStripAntiAliasing()
{
Operator = PixelArithmeticOperators.Threshold;
ApplyMethod = PixelArithmeticApplyMethod.All;
UsePattern = false;
Value = 127;
ThresholdMaxValue = 255;
ThresholdType = ThresholdType.Binary;
}
public void PresetHealAntiAliasing()
{
Operator = PixelArithmeticOperators.Threshold;
ApplyMethod = PixelArithmeticApplyMethod.All;
UsePattern = false;
Value = 119;
//ThresholdMaxValue = 255;
ThresholdType = ThresholdType.ToZero;
}
public void PresetHalfBrightness()
{
Value = 128;
}
public unsafe void LoadPatternFromImage(Mat mat, bool isAlternatePattern = false)
{
var result = new string[mat.Height];
var span = mat.GetBytePointer();
Parallel.For(0, mat.Height, CoreSettings.ParallelOptions, y =>
{
result[y] = string.Empty;
var pixelPos = mat.GetPixelPos(0, y);
for (int x = 0; x < mat.Width; x++)
{
result[y] += $"{span[pixelPos++]} ";
}
result[y] = result[y].Trim();
});
StringBuilder sb = new();
foreach (var s in result)
{
sb.AppendLine(s);
}
if (isAlternatePattern)
{
PatternTextAlternate = sb.ToString();
}
else
{
PatternText = sb.ToString();
}
}
public void LoadPatternFromImage(string filepath, bool isAlternatePattern = false)
{
try
{
using var mat = CvInvoke.Imread(filepath, ImreadModes.Grayscale);
LoadPatternFromImage(mat, isAlternatePattern);
}
catch (Exception e)
{
Debug.WriteLine(e);
}
}
public void GeneratePattern(string pattern)
{
if (pattern == "Chessboard")
{
PatternText = string.Format(
"{0} {1}{2}" +
"{1} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
PatternTextAlternate = string.Format(
"{1} {0}{2}" +
"{0} {1}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
return;
}
if (pattern == "Sparse")
{
PatternText = string.Format(
"{1} {0} {0} {0}{2}" +
"{0} {0} {1} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
PatternTextAlternate = string.Format(
"{0} {0} {1} {0}{2}" +
"{1} {0} {0} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
return;
}
if (pattern == "Crosses")
{
PatternText = string.Format(
"{1} {0} {1} {0}{2}" +
"{0} {1} {0} {0}{2}" +
"{1} {0} {1} {0}{2}" +
"{0} {0} {0} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
PatternTextAlternate = string.Format(
"{0} {0} {0} {0}{2}" +
"{1} {0} {1} {0}{2}" +
"{0} {1} {0} {0}{2}" +
"{1} {0} {1} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
return;
}
if (pattern == "Strips")
{
PatternText = string.Format(
"{1}{2}" +
"{0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
PatternTextAlternate = string.Format(
"{0}{2}" +
"{1}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
return;
}
if (pattern == "Pyramid")
{
PatternText = string.Format(
"{0} {0} {1} {0} {0} {0}{2}" +
"{0} {1} {0} {1} {0} {0}{2}" +
"{1} {0} {1} {0} {1} {0}{2}" +
"{0} {0} {0} {0} {0} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
PatternTextAlternate = string.Format(
"{0} {1} {0} {1} {0} {1}{2}" +
"{0} {0} {1} {0} {1} {0}{2}" +
"{0} {0} {0} {1} {0} {0}{2}" +
"{0} {0} {0} {0} {0} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
return;
}
if (pattern == "Rhombus")
{
PatternText = string.Format(
"{0} {1} {0} {0}{2}" +
"{1} {0} {1} {0}{2}" +
"{0} {1} {0} {0}{2}" +
"{0} {0} {0} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
PatternTextAlternate = string.Format(
"{0} {0} {0} {0}{2}" +
"{0} {1} {0} {0}{2}" +
"{1} {0} {1} {0}{2}" +
"{0} {1} {0} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
return;
}
if (pattern == "Hearts")
{
PatternText = string.Format(
"{0} {1} {0} {1} {0} {0}{2}" +
"{1} {0} {1} {0} {1} {0}{2}" +
"{1} {0} {0} {0} {1} {0}{2}" +
"{0} {1} {0} {1} {0} {0}{2}" +
"{0} {0} {1} {0} {0} {0}{2}" +
"{0} {0} {0} {0} {0} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
PatternTextAlternate = string.Format(
"{0} {0} {0} {0} {0} {0}{2}" +
"{0} {0} {1} {0} {1} {0}{2}" +
"{0} {1} {0} {1} {0} {1}{2}" +
"{0} {1} {0} {0} {0} {1}{2}" +
"{0} {0} {1} {0} {1} {0}{2}" +
"{0} {0} {0} {1} {0} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
return;
}
if (pattern == "Slashes")
{
PatternText = string.Format(
"{1} {0} {0}{2}" +
"{0} {1} {0}{2}" +
"{0} {0} {1}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
PatternTextAlternate = string.Format(
"{0} {0} {1}{2}" +
"{0} {1} {0}{2}" +
"{1} {0} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
return;
}
if (pattern == "Waves")
{
PatternText = string.Format(
"{1} {0} {0}{2}" +
"{0} {0} {1}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
PatternTextAlternate = string.Format(
"{0} {0} {1}{2}" +
"{1} {0} {0}"
, _patternGenMinBrightness, _patternGenBrightness, "\n");
return;
}
if (pattern == "Solid")
{
PatternText = _patternGenBrightness.ToString();
PatternTextAlternate = null!;
return;
}
}
public void GenerateInfill(string pattern)
{
if (pattern == "Rectilinear")
{
PatternText = ($"255\n".Repeat(_patternGenInfillSpacing) + $"0\n".Repeat(_patternGenInfillThickness)).Trim('\n', '\r');
PatternTextAlternate = null!;
return;
}
if (pattern == "Square grid")
{
var p1 = "255 ".Repeat(_patternGenInfillSpacing) + "0 ".Repeat(_patternGenInfillThickness);
p1 = p1.Trim() + "\n";
p1 += p1.Repeat(_patternGenInfillThickness);
var p2 = "0 ".Repeat(_patternGenInfillSpacing) + "0 ".Repeat(_patternGenInfillThickness);
p2 = p2.Trim() + '\n';
p2 += p2.Repeat(_patternGenInfillThickness);
p2 = p2.Trim('\n', '\r');
PatternText = p1 + p2;
PatternTextAlternate = null!;
return;
}
if (pattern == "Waves")
{
var p1 = string.Empty;
var pos = 0;
for (sbyte dir = 1; dir >= -1; dir -= 2)
{
while (pos >= 0 && pos <= _patternGenInfillSpacing)
{
p1 += "255 ".Repeat(pos);
p1 += "0 ".Repeat(_patternGenInfillThickness);
p1 += "255 ".Repeat(_patternGenInfillSpacing - pos);
p1 = p1.Trim() + '\n';
pos += dir;
}
pos--;
}
PatternText = p1.Trim('\n', '\r');
PatternTextAlternate = null!;
return;
}
if (pattern == "Lattice")
{
var p1 = string.Empty;
var p2 = string.Empty;
var zeros = Math.Max(0, _patternGenInfillSpacing - _patternGenInfillThickness * 2);
// Pillar
for (int i = 0; i < _patternGenInfillThickness; i++)
{
p1 += "0 ".Repeat(_patternGenInfillThickness);
p1 += "255 ".Repeat(zeros);
p1 += "0 ".Repeat(_patternGenInfillThickness);
p1 = p1.Trim() + '\n';
}
for (int i = 0; i < zeros; i++)
{
p1 += "255 ".Repeat(_patternGenInfillSpacing);
p1 = p1.Trim() + '\n';
}
for (int i = 0; i < _patternGenInfillThickness; i++)
{
p1 += "0 ".Repeat(_patternGenInfillThickness);
p1 += "255 ".Repeat(zeros);
p1 += "0 ".Repeat(_patternGenInfillThickness);
p1 = p1.Trim() + '\n';
}
// Square
for (int i = 0; i < _patternGenInfillThickness; i++)
{
p2 += "0 ".Repeat(_patternGenInfillSpacing);
p2 = p2.Trim() + '\n';
}
for (int i = 0; i < zeros; i++)
{
p2 += "0 ".Repeat(_patternGenInfillThickness);
p2 += "255 ".Repeat(zeros);
p2 += "0 ".Repeat(_patternGenInfillThickness);
p2 = p2.Trim() + '\n';
}
for (int i = 0; i < _patternGenInfillThickness; i++)
{
p2 += "0 ".Repeat(_patternGenInfillSpacing);
p2 = p2.Trim() + '\n';
}
PatternText = p1.Trim('\n', '\r');
PatternTextAlternate = p2.Trim('\n', '\r'); ;
return;
}
}
#endregion
#region Equality
protected bool Equals(OperationPixelArithmetic other)
{
return _operator == other._operator && _applyMethod == other._applyMethod && _wallThicknessStart == other._wallThicknessStart && _wallThicknessEnd == other._wallThicknessEnd && _wallChamfer == other._wallChamfer && _ignoreAreaOperator == other._ignoreAreaOperator && _ignoreAreaThreshold == other._ignoreAreaThreshold && _value == other._value && _usePattern == other._usePattern && _thresholdType == other._thresholdType && _thresholdMaxValue == other._thresholdMaxValue && _patternAlternatePerLayersNumber == other._patternAlternatePerLayersNumber && _patternInvert == other._patternInvert && _patternText == other._patternText && _patternTextAlternate == other._patternTextAlternate && _patternGenMinBrightness == other._patternGenMinBrightness && _patternGenBrightness == other._patternGenBrightness && _patternGenInfillThickness == other._patternGenInfillThickness && _patternGenInfillSpacing == other._patternGenInfillSpacing && _noiseMinOffset == other._noiseMinOffset && _noiseMaxOffset == other._noiseMaxOffset && _noiseThreshold == other._noiseThreshold && _noisePixelArea == other._noisePixelArea && _noisePasses == other._noisePasses;
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((OperationPixelArithmetic) obj);
}
public override int GetHashCode()
{
var hashCode = new HashCode();
hashCode.Add((int) _operator);
hashCode.Add((int) _applyMethod);
hashCode.Add(_wallThicknessStart);
hashCode.Add(_wallThicknessEnd);
hashCode.Add(_wallChamfer);
hashCode.Add((int) _ignoreAreaOperator);
hashCode.Add(_ignoreAreaThreshold);
hashCode.Add(_value);
hashCode.Add(_usePattern);
hashCode.Add((int) _thresholdType);
hashCode.Add(_thresholdMaxValue);
hashCode.Add(_patternAlternatePerLayersNumber);
hashCode.Add(_patternInvert);
hashCode.Add(_patternText);
hashCode.Add(_patternTextAlternate);
hashCode.Add(_patternGenMinBrightness);
hashCode.Add(_patternGenBrightness);
hashCode.Add(_patternGenInfillThickness);
hashCode.Add(_patternGenInfillSpacing);
hashCode.Add(_noiseMinOffset);
hashCode.Add(_noiseMaxOffset);
hashCode.Add(_noiseThreshold);
hashCode.Add(_noisePixelArea);
hashCode.Add(_noisePasses);
return hashCode.ToHashCode();
}
#endregion
}
|