@@ -16,19 +16,16 @@ void _mlir_ciface_corr_2d(MemRef<float, 2> *input, MemRef<float, 2> *kernel,
16
16
unsigned int centerY, int boundaryOption);
17
17
}
18
18
19
- bool equalImages (const Mat &img1, const Mat &img2)
20
- {
19
+ bool equalImages (const Mat &img1, const Mat &img2) {
21
20
if (img1.rows != img2.rows || img1.cols != img2.cols ) {
22
- std::cout << " Produced outputs by DIP and OpenCV differ. Image dimensions are not equal\n " ;
21
+ std::cout << " Produced outputs by DIP and OpenCV differ. Image dimensions "
22
+ " are not equal\n " ;
23
23
return 0 ;
24
24
}
25
25
26
- for (unsigned int y = 0 ; y < img1.rows ; ++y)
27
- {
28
- for (unsigned int x = 0 ; x < img1.cols ; ++x)
29
- {
30
- if (abs (img1.at <float >(x, y) - img2.at <float >(x, y)) > 10e-3 )
31
- {
26
+ for (unsigned int y = 0 ; y < img1.rows ; ++y) {
27
+ for (unsigned int x = 0 ; x < img1.cols ; ++x) {
28
+ if (abs (img1.at <float >(x, y) - img2.at <float >(x, y)) > 10e-3 ) {
32
29
std::cout << " Produced outputs by DIP and OpenCV differ.\n " ;
33
30
return 0 ;
34
31
}
@@ -37,9 +34,9 @@ bool equalImages(const Mat &img1, const Mat &img2)
37
34
return 1 ;
38
35
}
39
36
40
- void testKernelImpl (const Mat& inputImage, unsigned int kernelRows, unsigned int kernelCols, float * kernelArray,
41
- unsigned int x, unsigned int y)
42
- {
37
+ void testKernelImpl (const Mat & inputImage, unsigned int kernelRows,
38
+ unsigned int kernelCols, float *kernelArray, unsigned int x,
39
+ unsigned int y) {
43
40
// Define container sizes.
44
41
intptr_t sizesInput[2 ] = {inputImage.rows , inputImage.cols };
45
42
intptr_t sizesKernel[2 ] = {kernelRows, kernelCols};
@@ -60,31 +57,33 @@ void testKernelImpl(const Mat& inputImage, unsigned int kernelRows, unsigned int
60
57
_mlir_ciface_corr_2d (&input, &kernel, &output, x, y, 0 );
61
58
62
59
filter2D (inputImage, opencvOutput, CV_32FC1, kernel1, cv::Point (x, y), 1.0 ,
63
- cv::BORDER_REPLICATE);
60
+ cv::BORDER_REPLICATE);
64
61
65
62
// Define a cv::Mat with the output of corr_2d.
66
63
Mat dipOutput (inputImage.rows , inputImage.cols , CV_32FC1, output.getData ());
67
64
68
- if (!equalImages (dipOutput, opencvOutput))
69
- {
70
- std::cout << " Different images produced by OpenCV and DIP for kernel :\n " << kernel1 << " \n "
71
- " when anchor point was : (" << x << " , " << y << " ).\n " ;
65
+ if (!equalImages (dipOutput, opencvOutput)) {
66
+ std::cout << " Different images produced by OpenCV and DIP for kernel :\n "
67
+ << kernel1
68
+ << " \n "
69
+ " when anchor point was : ("
70
+ << x << " , " << y << " ).\n " ;
72
71
return ;
73
72
}
74
73
}
75
74
76
- void testKernel (const Mat& inputImage, unsigned int kernelRows, unsigned int kernelCols, float * kernelArray)
77
- {
75
+ void testKernel (const Mat & inputImage, unsigned int kernelRows,
76
+ unsigned int kernelCols, float *kernelArray) {
78
77
for (unsigned int y = 0 ; y < kernelRows; ++y)
79
78
for (unsigned int x = 0 ; x < kernelCols; ++x)
80
79
testKernelImpl (inputImage, kernelRows, kernelCols, kernelArray, x, y);
81
80
}
82
81
83
- int main (int argc, char **argv)
84
- {
82
+ int main (int argc, char **argv) {
85
83
// Read input image
86
84
Mat inputImage = imread (argv[1 ], IMREAD_GRAYSCALE);
87
85
88
86
for (auto kernel : kernelMap)
89
- testKernel (inputImage, get<1 >(kernel.second ), get<2 >(kernel.second ), get<0 >(kernel.second ));
87
+ testKernel (inputImage, get<1 >(kernel.second ), get<2 >(kernel.second ),
88
+ get<0 >(kernel.second ));
90
89
}
0 commit comments