can we create a 5*5 kernel np array in c++
I have made a 5*5 kernel using np array in python. how should I create it in c++?
kernel_sharpen_3 = np.array([[-1, -1, -1, -1, -1],
[-1, 2, 2, 2, -1],
[-1, 2, 2, 2, -1],
[-1, 2, 2, 2, -1],
[-1, -1, -1, -1, -1]]) / 8
rescaled_image = cv2.filter2D(rescaled_image, -1, kernel_sharpen_3)
Edit: Python output
C++ code:
float k[] = { -1, -1, -1, -1, -1,
-1, 2, 2, 2, -1,
-1, 2, 2, 2, -1,
-1, 2, 2, 2, -1,
-1, -1, -1, -1, -1 };
Mat kernel_sharp(5, 5, CV_32F, k);
kernel /= 8;
filter2D(rescaled_image, rescaled_image, -1,kernel_sharp);
C++ Output: