In the example below, the Hilbert matrix is initialized:
Mat H(100, 100, CV_64F); for(int i = 0; i < H.rows; i++) for(int j = 0; j < H.cols; j++) H.at<double>(i,j)=1./(i+j+1);
Keep in mind that the size identifier used in the at statement cannot be randomly selected. It depends on the image you are trying to get data from. The table below gives a more complete picture of this:
If the matrix is of type CV_8U, then use Mat.at<uchar>(y,x) .
If the matrix is of type CV_8S, use Mat.at<schar>(y,x) .
If the matrix is of type CV_16U, use Mat.at<ushort>(y,x) .
If the matrix is of type CV_16S, use Mat.at<short>(y,x) .
If the matrix is of type CV_32S, use Mat.at<int>(y,x) .
If the matrix is of type CV_32F, use Mat.at<float>(y,x) .
If the matrix is of type CV_64F, use Mat.at<double>(y,x) .
(taken from OpenCV Docs )
shahar_m
source share