vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/* Sample - Filtering
|
||||
* Target is to apply filtering using F-transform
|
||||
* on the image "input.png". Two different kernels
|
||||
* are used, where bigger radius (100 in this case)
|
||||
* means higher level of blurriness.
|
||||
*
|
||||
* Image "output1_filter.png" is created from "input.png"
|
||||
* using "kernel1" with radius 3.
|
||||
*
|
||||
* Image "output2_filter.png" is created from "input.png"
|
||||
* using "kernel2" with radius 100.
|
||||
*
|
||||
* Both kernels are created from linear function, using
|
||||
* linear interpolation (parameter ft:LINEAR).
|
||||
*/
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/fuzzy.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Input image
|
||||
Mat I = imread("input.png");
|
||||
|
||||
// Kernel creation
|
||||
Mat kernel1, kernel2;
|
||||
|
||||
ft::createKernel(ft::LINEAR, 3, kernel1, 3);
|
||||
ft::createKernel(ft::LINEAR, 100, kernel2, 3);
|
||||
|
||||
// Filtering
|
||||
Mat output1, output2;
|
||||
|
||||
ft::filter(I, kernel1, output1);
|
||||
ft::filter(I, kernel2, output2);
|
||||
|
||||
// Save output
|
||||
|
||||
imwrite("output1_filter.png", output1);
|
||||
imwrite("output2_filter.png", output2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/* Sample - Inpainting
|
||||
* Target is to apply inpainting using F-transform
|
||||
* on the image "input.png". The image is damaged
|
||||
* by various types of corruption:
|
||||
*
|
||||
* input1 = image & mask1
|
||||
* input2 = image & mask2
|
||||
* input3 = image & mask3
|
||||
*
|
||||
* Three algorithms "ft::ONE_STEP", "ft::MULTI_STEP"
|
||||
* and "ft::ITERATIVE" are demonstrated on the
|
||||
* appropriate type of damage.
|
||||
*
|
||||
* ft::ONE_STEP
|
||||
* "output1_inpaint.png": input1, mask1
|
||||
*
|
||||
* ft::MULTI_STEP
|
||||
* "output2_inpaint.png": input2, mask2
|
||||
* "output3_inpaint.png": input3, mask3
|
||||
*
|
||||
* ft::ITERATIVE
|
||||
* "output4_inpaint.png": input3, mask3
|
||||
*
|
||||
* Linear kernel with radius 2 is used for all
|
||||
* samples.
|
||||
*/
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
#include "opencv2/fuzzy.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Input image
|
||||
Mat I = imread("input.png");
|
||||
|
||||
// Various masks
|
||||
Mat mask1 = imread("mask1.png", IMREAD_GRAYSCALE);
|
||||
Mat mask2 = imread("mask2.png", IMREAD_GRAYSCALE);
|
||||
Mat mask3 = imread("mask3.png", IMREAD_GRAYSCALE);
|
||||
|
||||
// Apply the damage
|
||||
Mat input1, input2, input3;
|
||||
|
||||
I.copyTo(input1, mask1);
|
||||
I.copyTo(input2, mask2);
|
||||
I.copyTo(input3, mask3);
|
||||
|
||||
// Inpaint with various algorithm
|
||||
Mat output1, output2, output3, output4;
|
||||
|
||||
ft::inpaint(input1, mask1, output1, 2, ft::LINEAR, ft::ONE_STEP);
|
||||
ft::inpaint(input2, mask2, output2, 2, ft::LINEAR, ft::MULTI_STEP);
|
||||
ft::inpaint(input3, mask3, output3, 2, ft::LINEAR, ft::MULTI_STEP);
|
||||
ft::inpaint(input3, mask3, output4, 2, ft::LINEAR, ft::ITERATIVE);
|
||||
|
||||
// Save output
|
||||
imwrite("output1_inpaint.png", output1);
|
||||
imwrite("output2_inpaint.png", output2);
|
||||
imwrite("output3_inpaint.png", output3);
|
||||
imwrite("output4_inpaint.png", output4);
|
||||
|
||||
// Save damaged input for comparison
|
||||
imwrite("input1.png", input1);
|
||||
imwrite("input2.png", input2);
|
||||
imwrite("input3.png", input3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 399 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
Reference in New Issue
Block a user