I have sample image processing code which applies a convolution filter over an image using following kernel:
float kernel[] = {-1,0,1};
and the application of filter:
new ConvolveOp(new Kernel(1,3, kernel), ConvolveOp.EDGE_NO_OP, null).filter(copy, img);
I am wondering how ConvolveOp will behave, dealing with a non-square kernel matrix? I far as I know we must use a square matrix with odd number of rows in Convolution algorithm.
PS. I thought that it (java) may pad it with zeros (e.g. {0,0,0,-1,0,1,0,0,0}) but I a more sophisticated case we can also have a kernel of this form with no run-time error:
float data[] = {
-1,0,1,
-1,0,1,
-1,0,1,
-1,0,1
};
which cannot be padded to become square with odd number of rows.
thanks
There is nothing that says that a convolution kernel has to be a square matrix.