The basic image processing sample script is located in the ucp_tutorial/vp/vp_samples/script/01_basic_processing directory.
The sample shows how to perform related processing on the picture, including picture filtering, picture morphological processing,
picture equalization, the detailed implementation method, please combine with the sample source code to compare the practice.
In this sample, direct execution of the sample script performs the default picture processing flow: filtering with sepFilter2D, detecting morphological edges, and picture equalization. If you want to change the processing flow of the picture, you can control the flow of the execution by appending parameter when executing the sample script, the rules for appending parameters are as follows:
Included among these:
A list of all available append parameters can also be obtained with the append -help command.
The result of the picture processing is saved in the vp_samples/script/01_basic_processing directory after the algorithm is executed, and the contents of the generated object for this sample are as follows:
The execution flow of the sample is shown below:
As shown in the execution flowchart of the sample, the processing of the picture by the sample can be roughly divided into the following four stages:
Filtering of the noised picture. According to the different filtering algorithms, they can be categorized into bilinear filtering, box filtering, gaussian filtering, median filtering, two-dimensional filtering, and separated two-dimensional filtering.
Morphological processing of filtered picture. According to the processing methods can be categorized as corrosion, expansion, open operation, closed operation, and detection of edges.
Histogram equalization of morphologically processed pictures.
Image filter
In the image filter section, the sample encapsulates the six filtering algorithms in the corresponding functions, and uses std::map to establish the connection between the strings and the filtering functions.
As shown below, the parameter filter_op holds the mapping between the keywords and the functions.
During the execution of the sample code, according to the different append keywords in the argv parameter, it is automatically adapted to the corresponding filtering algorithm. The core logic is as follows:
Take sepFilter2D filtering algorithm as an example, the processing effect on the noise-added pictures is shown as belows:
Before filtering:

After filtering:

Morphological process
Morphological processing operators include erosion, dilation, open and close operations, top-hat, black-hat, and so on. In this example, by calling the hbVPDilate and hbVPErode interfaces.
This example encapsulates some of these morphological functions, please check the function source code for the specific implementation. Similar to the filtering session, the morphology_op parameter is created here to store the link between the string and the morphology function. The code is as follows:
The same string adaptation is used for scheduling morphological functions, and the core logic is as follows:
Taking the morphological gradient edge algorithm (the edge function in the example) as an example, the effect on the filtered image is shown as belows:
Filtered picture:

Morphological gradient edge detection picture:

Histogram equalization
In order to enhance the contrast and bring out the details of the picture, the sample performs histogram equalization on the morphology processed picture through the equalizeHist function. The equalization effect is shown as belows:
Original picture:

Equalized effect picture:
