Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Squaring elements of a matrix and summing them

I am new to java and opencv . I have a matrix(destination) and now I want to square every element of it and add all of them together after squaring. how can I do that?

Mat destination = new Mat(footGrayMat.rows(),footGrayMat.cols(),footGrayMat.type());
Mat kernel = new Mat(5,5, CvType.CV_32F);

float[] data = {-1,-3,-4,-3,-1,-3,0,6,0,-3,-4,6,20,6,-4,-3,0,6,0,-3,-1,-3,-4,-3,-1};
kernel.put(0,0,data);

Imgproc.filter2D(footGrayMat, destination, -1, kernel);