CIB image toolbox technical manual
5. Properties details
5.16. ProcessingStatus
Property-Name |
Data type |
Type |
ProcessingStatus |
JSON |
Get |
Provides information about the state of processing, which operation was or is conducted, in what area and if the operation was successful.
Syntax
ProcessingStatus=Operation:<operation>, PageRange: <pagerange>, RequiredRange:<requiredrange>, Status: <status>
<operation>: Convertion | |
<pagerange>: <number> | <number>-<number>
<requiredrange>: <number> | <number>-<number>
<sstatus>: OK | NOK
Example
ProcessingStatus={Operation":"Convertion", "PageRange": "0","RequiredRange": "0", "Status": "OK" };{ "Operation": "Convertion", "PageRange":
"1", "RequiredRange": "1", "Status":"OK" } ;{ "Operation": "Convertion","PageRange": "0-1", "RequiredRange": "2","Status": "OK" }
Although the input for PageRange in the jobinterface starts with number 1 (e.g. “1-4”, the PageRange of the ProcessingStatus starts with (e.g. “0-3”).
Image Processing Library usage
Filters
For using filters you should perform next steps:
1. Include header for filters:
#include "ImageProcessing_Filtration.h"
2. Create default utilities sets and copy them to new ProcessingProfile:
UtilitiesSets sets = UtilitiesSetsCreator::CreateUtilitiesSets();
ProcessingProfile profile;
profile.m_Utilities = sets.utilities;
profile.m_DebugUtilities = sets.debugUtilities;
3. Create profile parser and parse selected profile:
shared_ptr<ProfileParser> profileParser(ProfileParserCreator::CreateProfileParser());
profileParser->ParseProfile(profileFileName, profile);
4. Load image for processing:
RasterImage imageToProcess;
shared_ptr< IPL::IOStreams::ImageDecoder > imageDecoder(
IPL::IOStreams::ImageDecodersFabric::CreateImageDecoder());
IPL::IOStreams::InputStream inputStream(inputFileName);
imageToProcess = imageDecoder->decode(inputStream);
5. Create default filter creator (fabric):
shared_ptr<ImageFilterCreator> filterCreator(
ImageFilterCreatorsSelector::SelectImageFilterCreator() );
6. Create filters:
int binarizationFilterType = IFK_SAVOULA_BINARIZER;
int noiseFilterType =IFK_HUANG_BILATERAL_FILTER;
shared_ptr<ImageFilter> binarizationFilter(
filterCreator->CreateFilter(binarizationFilterType, profile) );
shared_ptr<ImageFilter> noiseFilter(
filterCreator->CreateFilter(noiseFilterType, profile) );
7. Process image:
RasterImage processedImage;
processedImage = binarizationFilter->apply(noiseFilter->apply(imageToProcess));
8. Show processing result:
profile.m_DebugUtilities->ShowImage("Window Title for Processed Image", processedImage);
9. And store it:
shared_ptr< IPL::IOStreams::ImageEncoder > encoder( IPL::IOStreams::ImageEncodersFabric::CreateImageEncoder(IPL::IOStreams::IEK_JPG_ENCODER));
IPL::IOStreams::OutputStream outputStream(inputFileName + ".proc" + ".jpg");
encoder->encode(processedImage, outputStream);
Look for sample FiltrationSample() in ImageProcessing_sample.cpp.
Segmenters
For using segmenters you should perform next steps:
1. Include header for segmenters:
#include "ImageProcessing_Segmentation.h"
2. Create default utilities sets and copy them to new ProcessingProfile:
UtilitiesSets sets = UtilitiesSetsCreator::CreateUtilitiesSets();
ProcessingProfile profile;
profile.m_Utilities = sets.utilities;
profile.m_DebugUtilities = sets.debugUtilities;
3. Create profile parser and parse selected profile:
shared_ptr<ProfileParser> profileParser(ProfileParserCreator::CreateProfileParser());
profileParser->ParseProfile(profileFileName, profile);
4. Load image for processing and create array for results:
RasterImage imageToProcess;
RasterImageArray results;
profile.m_DebugUtilities->ReadImageFromFile(inputFileName, imageToProcess);
5. Create default segmenter creator (fabric)
shared_ptr<ImageSegmenterCreator> segmenter_creator(
ImageSegmenterCreatorsSelector::SelectImageSegmenterCreator() );
6. Create segmenter:
int segmenterType = ISK_RANGES_SEGMENTER;
shared_ptr<ImageSegmenter> segmenter(
segmenter_creator->CreateSegmenter(segmenterType, profile));
7. Process image:
segmenter->segment(imageToProcess, results);
8. Save processing result to files:
for (size_t imageNo = 0; imageNo < results.size(); ++imageNo) {
profile.m_DebugUtilities->WriteImageToFile(results[imageNo],
inputFileName + ".layer_" + std::to_string(imageNo) + ".jpg");
}
or
shared_ptr<IPL::IOStreams::ImageEncoder> encoder(
IPL::IOStreams::ImageEncodersFabric::CreateImageEncoder(IPL::IOStreams::IEK_JPG_ENCODER));
for (size_t imageNo = 0; imageNo < results.size(); ++imageNo) { IPL::IOStreams::OutputStream outoutStream(
inputFileName + ".layer_" + std::to_string(imageNo) + ".jpg"); encoder->encode(results[imageNo], outoutStream);
}
Look for sample SegmentationSample() in ImageProcessing_sample.cpp.
User defined filters[edit | edit source]
For developing new filter (or segmenter) you should perform next steps:
1. Include header for filters:
#include "ImageProcessing_Filtration.h"
2. Create new class which inherits class ImageFilter (or ImageSegmenter for segmenters).
3. Create implementations of methods for new class:
virtual bool Initialize(ProcessingProfile& profile);
virtual RasterImage::RasterImagePtr apply(RasterImage& image) final;
For using of new filter (or segmenter) you should perform next steps:
1. Create default filter creator (fabric):
shared_ptr<ImageFilterCreator> filterCreator(
ImageFilterCreatorsSelector::SelectImageFilterCreator() );
2. Create lambda for new filter creation:
ImageFilterCreator::ImageFilterCreationProcedure newFilterCreationProcedure =
[](ProcessingProfile& profile) -> ImageFilter*
{
return new UserDefinedImageFilter(profile);
};
3. Add new filter to fabric:
uint32_t newFilterKey = filterCreator->AddFilter(newFilterCreationProcedure);
4. Create profile and set processing parameters
ProcessingProfile profile;
profile["UserDefinedImageFilter/Parameter1"] = "1";
5. Create instance of user defined filter
shared_ptr<ImageFilter> userDefinedFilter(
filterCreator->CreateFilter(newFilterKey, profile) );
6. Process image by filters
processedImage = userDefinedFilter->apply(noiseFilter->apply(imageToProcess)); Look for sample class UserDefinedImageFilter and UserDefinedImageFilter_sample() in ImageProcessing_sample.cpp.
Usage of DLL interface
CIB Job interface
Functions of this interface described in IPL_Interface.h.
Interface for doXisafe
For usage of the library from doXisafe ScenarioExecuter is available. It can be used by calling function CibImageProcessingRunScenario() declared in IPL_ScenarioExecuter_Interface.h.
Improvement functionality using plugins
IPL functionality can be improved by external module which are separated dynamically loading libraries.
Plugin interface
For developing IPL plugin you should implement functions declared in file IPL_Plugin_Interface.h as .dll (for Windows) or .so (for Linux):
PluginInterfaceVersionType GetPluginInterfaceVersion();
bool InitializePlugin(const std::string& pluginParametersString);
RasterImage* RunPlugin(RasterImage& inputImage);
bool DestroyPlugin();
Also library IPL_Plugin_Base.lib should be linked to your plugin.
Plugin usage
For using of plugin special filter was implemented. Key of this filter is IPL::Filtration::IFK_PLUGIN_FILTER.
Plugin file and corresponding processing parameters should be defined in processing profile
<ExternalFilter>
<PluginFileName>IPL_Plugin_sample.dll</PluginFileName>
<PluginParametersString>1</PluginParametersString>
</ExternalFilter>
or manually by correction of properties map
profile["PluginFileName/PluginParametersString"] = "0";
Processing profiles
Processing profiles are used for describing of processing parameters for implemented filters. Profile is a file in XML format with next structure (order of descriptions and filters/segmenters parameters does not matter):
<ProcessingProfile> <Filter1> <Filter1_Parameter1>Filter1_Parameter1_Value</Filter1_Parameter1> ... <Filter1_ParameterN>Filter1_ParameterN_Value</Filter1_ParameterN> </Filter1> ... <FilterM> <FilterM_Parameter1>FilterM_Parameter1_Value</FilterM_Parameter1> ... <FilterM_ParameterK>FilterM_ParameterK_Value</FilterM_ParameterK> </FilterM> <Merger1> <Merger1_Parameter1>Merger1_Parameter1_Value</Merger1_Parameter1> ... <Merger1_ParameterY>Merger1_ParameterY_Value</Merger1_ParameterY> </Merger1> ... <MergerL> <MergerL_Parameter1>MergerL_Parameter1_Value</MergerL_Parameter1> ... <MergerL_ParameterX>MergerL_ParameterX_Value</MergerL_ParameterX> </MergerM> <Segmenter1> <Segmenter1_Parameter1>Segmenter1_Parameter1_Value</Segmenter1_Parameter1> ... <Segmenter1_ParameterY>Segmenter1_ParameterY_Value</Segmenter1_ParameterY> </Segmenter1> ... <SegmenterL> <SegmenterL_Parameter1>SegmenterL_Parameter1_Value</SegmenterL_Parameter1> ... <SegmenterL_ParameterX>SegmenterL_ParameterX_Value</SegmenterL_ParameterX> </SegmenterM> </ProcessingProfile>