diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-11-03 23:05:47 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-11-03 23:05:47 +0200 |
| commit | 4b7ca7de06c5a9ec6fb3e11e5a4b01f2d20144f6 (patch) | |
| tree | 9274db40eb60533e7bf7324d36605ebeed681a77 /Software/Visual_Studio | |
| parent | 4250b16431fa600c6cf92ec9d2abd3f22f9cb409 (diff) | |
| download | Tango-4b7ca7de06c5a9ec6fb3e11e5a4b01f2d20144f6.tar.gz Tango-4b7ca7de06c5a9ec6fb3e11e5a4b01f2d20144f6.zip | |
PPC. Fine Tuning. Implement "Correct only Hue"
Related Work Items: #7324
Diffstat (limited to 'Software/Visual_Studio')
| -rw-r--r-- | Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs | 84 |
1 files changed, 48 insertions, 36 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs index 9540d4503..d5b324a40 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/VectorFineTuningDialogVM.cs @@ -1578,17 +1578,46 @@ namespace Tango.PPC.Jobs.Dialogs return; } - private bool CalculateSuggestionLAB( TrialsLogModel trial) + private bool CalculateSuggestionLAB(TrialsLogModel trial) { - if((MeasuredL != null && MeasuredA != null && MeasuredB != null ) + if ((MeasuredL != null && MeasuredA != null && MeasuredB != null) || IsManualFineTuning && (LightnessOffset != 0.0 || ChromaOffset != 0.0 || HueOffset != 0.0)) { - trial.NewSuggestionL = LimitToRange((trial.SuggestionL + (TargetL - (double)trial.VectorCorrectionL)),0, 100) ; - trial.NewSuggestionA = LimitToRange((trial.SuggestionA + (TargetA - (double)trial.VectorCorrectionA)), -128, 127); - trial.NewSuggestionB = LimitToRange((trial.SuggestionB + (TargetB - (double)trial.VectorCorrectionB)), -128, 127); - LogManager.Log($" Fine Tuning. Suggestion (calculated) LAB L:'{trial.NewSuggestionL}'A:'{trial.NewSuggestionA}' B:'{trial.NewSuggestionB}'."); - return true; + if (!IsManualFineTuning && CorrectOnlyHue) + { + var converter = new ColourfulConverter { WhitePoint = Illuminants.D65 }; + + LabColor labColorTarget = new LabColor(TargetL, TargetA, TargetB); + var LCH_target = converter.ToLChab(labColorTarget); + + + LabColor labColorSuggestion = new LabColor(ActiveLogModel.SuggestionL, ActiveLogModel.SuggestionA, ActiveLogModel.SuggestionB); + var LCH_suggestion = converter.ToLChab(labColorSuggestion); + + LabColor labColorNew = new LabColor((double)trial.VectorCorrectionL, (double)trial.VectorCorrectionA, (double)trial.VectorCorrectionB); + var LCH_new = converter.ToLChab(labColorNew); + + double L = LCH_suggestion.L; + double C = LCH_suggestion.C; + double H = LCH_suggestion.h + (LCH_target.h - LCH_new.h); + + LabColor lab = converter.ToLab(new LChabColor(L, C, H)); + trial.NewSuggestionL = lab.L; + trial.NewSuggestionA = lab.a; + trial.NewSuggestionB = lab.b; + + LogManager.Log($" Fine Tuning. Suggestion (calculated) LAB L:'{trial.NewSuggestionL}'A:'{trial.NewSuggestionA}' B:'{trial.NewSuggestionB}'."); + return true; + } + else + { + trial.NewSuggestionL = LimitToRange((trial.SuggestionL + (TargetL - (double)trial.VectorCorrectionL)), 0, 100); + trial.NewSuggestionA = LimitToRange((trial.SuggestionA + (TargetA - (double)trial.VectorCorrectionA)), -128, 127); + trial.NewSuggestionB = LimitToRange((trial.SuggestionB + (TargetB - (double)trial.VectorCorrectionB)), -128, 127); + LogManager.Log($" Fine Tuning. Suggestion (calculated) LAB L:'{trial.NewSuggestionL}'A:'{trial.NewSuggestionA}' B:'{trial.NewSuggestionB}'."); + return true; + } } return false; @@ -1607,43 +1636,26 @@ namespace Tango.PPC.Jobs.Dialogs return inclusiveMinimum; } + /// <summary> + /// Vectors the correction. + /// </summary> protected void VectorCorrection() { - if (ActiveLogModel == null || !IsValidLAB()) + if ( !IsValidLAB()) { - DL = DC = DH = 0; - ActiveLogModel.VectorCorrectionL = MeasuredL == null? TargetL : (double)MeasuredL; - ActiveLogModel.VectorCorrectionA = MeasuredA == null ? TargetA : (double)MeasuredA; - ActiveLogModel.VectorCorrectionB = MeasuredB == null ? TargetB : (double)MeasuredB; + ActiveLogModel.VectorCorrectionL = MeasuredL == null ? ActiveLogModel.SuggestionL : (double)MeasuredL; + ActiveLogModel.VectorCorrectionA = MeasuredA == null ? ActiveLogModel.SuggestionA : (double)MeasuredA; + ActiveLogModel.VectorCorrectionB = MeasuredB == null ? ActiveLogModel.SuggestionB : (double)MeasuredB; return; } - - if ( false == CorrectOnlyHue) - { - ActiveLogModel.VectorCorrectionL = (double)MeasuredL; - ActiveLogModel.VectorCorrectionA = (double)MeasuredA; - ActiveLogModel.VectorCorrectionB = (double)MeasuredB; - - return; - } - - LabColor labColor = new LabColor(ActiveLogModel.SuggestionL, ActiveLogModel.SuggestionA, ActiveLogModel.SuggestionB); - var converter = new ColourfulConverter { WhitePoint = Illuminants.D65 }; - var last_LCH = converter.ToLChab(labColor); - LabColor labColor1 = new LabColor((double)MeasuredL, (double)MeasuredA, (double)MeasuredB); - var measured_LCH = converter.ToLChab(labColor1); - double L = last_LCH.L; - double C = last_LCH.C; - double H = measured_LCH.h; - - LabColor lab = converter.ToLab( new LChabColor(L,C,H)); - ActiveLogModel.VectorCorrectionL = lab.L; - ActiveLogModel.VectorCorrectionA = lab.a; - ActiveLogModel.VectorCorrectionB = lab.b; + ActiveLogModel.VectorCorrectionL = (double)MeasuredL; + ActiveLogModel.VectorCorrectionA = (double)MeasuredA; + ActiveLogModel.VectorCorrectionB = (double)MeasuredB; + return; } - + #endregion } |
