EyeQ Docs

Preset samples

Apply custom correction presets without automatic scene detection

The PresetSample projects show how to read correction parameters from a .preset file exported from Perfectly Clear Workbench and apply them to images. This is useful when you want consistent corrections across all images or when you've created custom correction profiles for specific use cases. This is the alternative to using AI-based scene detection and is typically used only in specialized workflows where you want to apply the same adjustments to every image.

Key functions

A summary of key functions and purposes:

FunctionPurpose
PFC_ReadPresetsLoad correction parameters from a .preset file
PFC_SetParamInitialize default correction parameters
PFC_AutoCorrectApply corrections using loaded parameters
PFC_Calc / PFC_ApplyTwo-step correction

C/C++ implementation

The following excerpts are from PresetSample.cpp.

Load preset parameters

Read correction settings from a preset file exported from Workbench. If the file cannot be loaded, then fall back to default parameters.

PFCPARAM param;

// Try to load preset from file
int ret = PFC_ReadPresets(param, "path/to/corrections.preset");

if (ret != 0) {
    // Preset failed to load, use defaults
    PFC_SetParam(param);
    
    if (ret == -2) {
        printf("Preset file not found, using defaults\n");
    } else if (ret == -9) {
        // This is a Scene Detection preset, not a single preset
        printf("File is an SD preset, use PFC_LoadScenePresets instead\n");
    }
}

Apply corrections with preset

Pass the loaded parameters to the correction function. Set the last parameter to false to use the preset instead of scene detection.

// Create AI engine for AI-based corrections (still needed for AI features)
PFCENGINE *pAiEngine = PFC_CreateEngine();
int aistatus = PFC_LoadAIEngine(pAiEngine, 
    AI_CORRECTIONS | AI_COLOR | AI_FACEMESH, 
    binPath.c_str());

// Apply corrections using preset parameters
// Last parameter 'false' means don't use scene detection
int status = PFC_AutoCorrect(&im, NULL, param, -1, NULL, false, NULL, pAiEngine, false);

if (status == APPLY_SUCCESS) {
    printf("Image processed successfully\n");
}

C# implementation

The C# implementation offers two approaches: a simple one-call method or a two-step calc/apply process that allows parameter inspection between steps.

Load preset file

Create a PerfectlyClear instance and load your preset file.

PerfectlyClearAdapter.PerfectlyClear Pfc = new PerfectlyClearAdapter.PerfectlyClear("C:\\path\\to\\sdk_license");

// Load preset file
int rc = Pfc.ReadPresets("path/to/corrections.preset");
if (rc != 0) {
    Console.WriteLine("Failed to load preset");
}

Two-step correction process

The two-step approach lets you inspect or modify parameters after analysis but before applying corrections.

// Load image
Bitmap bm = new Bitmap(inputFile);

// Step 1: Analyze image and calculate correction profile
ADPTRRETURNCODE calcResult = Pfc.Calc(ref bm, PFCFEATURE.CALC_ALL, -1, null);

// Optionally modify parameters here
// Pfc.m_Param.core.eContrastMode = CONTRASTMODE.HIGH_CONTRAST;

// Step 2: Apply corrections
PFCAPPLYSTATUS applyResult = Pfc.Apply(ref bm, 100);

// Save result
bm.Save(outputFile);

Simple one-call method

For straightforward processing, use AutoCorrect after loading the preset.

// Load preset
Pfc.ReadPresets("path/to/corrections.preset");

// Load and correct image in one call
Bitmap bm = new Bitmap(inputFile);
int result = Pfc.AutoCorrect(ref bm);
bm.Save(outputFile);

Source files

The code snippets can be found in the following files:

PlatformSamplePath
Linux/macOSPresetSampleLinux/PresetSample/PresetSample.cpp
Windows (C++)PresetSampleWin/PresetSample/PresetSample.cpp
Windows (C#)PresetSampleWin/CSharp_PresetSample/Program.cs
Windows (.NET Core)PresetSampleWin/DotNetCore_PresetSample/Program.cs

PFC-SDK Version 10.7.2.1269 built from 4fa849d8101945eea725a08dd0dae5101f090fa0 on 11-10-2025.

Copyright © 2026 EyeQ Imaging Inc. All rights reserved.

On this page