Skip to content

ImageEnhancement.h

Go to the source code of this file.

Image Enhancement is a function that improves the quality of an image.

SAIGE VISION uses a model trained with high-quality image data that corresponds to low-quality images to enhance the quality of low-quality images.

Like Segmentation and OCR functions, you can set the Inspection Size using the SaigeHandleConfig structure when creating a Handle.

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// ExampleIenRuntime.cpp:62

SaigeInferenceHandle handle = nullptr;
SaigeHandleConfig config;
unsigned int handleFlags = 0;
/*config.inspectionSizeWidth = 640;
config.inspectionSizeHeight = 1100;
handleFlags |= SAIGE_SET_INSPECTION_SIZE;*/

if (optimize) {
    handleFlags |= SAIGE_OPTIMIZE_HANDLE;
}
retval = SaigeCreateInferenceHandle(&handle, kProjectTypeIEN, trainedModelPath.c_str(),
                                    deviceIndex, &config, handleFlags);
if (retval < 0) {
    std::cerr << "SaigeCreateInferenceHandle failed - " << SaigeStrError(retval) << std::endl;
    return retval;
}

Inference Options

Image Enhancement has the following inference options.

Inference Results

The inspection results of Image Enhancement are returned as an array of unsigned char that has the same size as the input image.

218
219
220
221
222
223
224
225
226
227
228
229
230
// ExampleIenRuntime.cpp:220

unsigned char* enhanced_image;
long long imreadTime, inferenceTime, postProcessingTime;

retval = SaigeGetInferenceResultEnhancedImage(result, &enhanced_image);
if (retval < 0) {
    std::cerr << "SaigeGetInferenceResultEnhancedImage() failed - " << SaigeStrError(retval)
              << std::endl;
    SaigeDestroyInferenceHandle(handle);
    SaigeDestroyInferenceResult(result);
    return retval;
}