Where I was wrong in this row filtering code [closed]
Code :
int filter_size = 7;
int h = filter_size / 2;
int top, bottom, left, right;
top = bottom = left = right = h;
Scalar value(0, 0, 0);
copyMakeBorder(double_src, rowPaddedImage, 0, 0, left, right, BORDER_CONSTANT, value);
//Row filter
for (int i = 0; i < rowPaddedImage.rows; i++) //For img
{
for (int j = h; j < rowPaddedImage.cols - h; j++) //For img
{
b = g = r = 0.0;
for (int l = 0; l < f_size; l++)
{
colPaddedImage.at<Vec3d>(Point(i + h, j - h))[0] += rowPaddedImage.at<Vec3d>(Point(i, j - h + l))[0] * filter[l];
colPaddedImage.at<Vec3d>(Point(i + h, j - h))[1] += rowPaddedImage.at<Vec3d>(Point(i, j - h + l))[1] * filter[l];
colPaddedImage.at<Vec3d>(Point(i + h, j - h))[2] += rowPaddedImage.at<Vec3d>(Point(i, j - h + l))[2] * filter[l];
}//Kernel loop end
}
}
Have you got an error message?
i is for row and j for colum but Point(x,y) means x for column and y for row
This is the error message I got. OpenCV(3.4.1) Error: Assertion failed ((unsigned)pt.y < (unsigned)size.p[0]) in cv::Mat::at, file c:\opencv\3.4.1\build\install\include\opencv2\core\mat.inl.hpp, line 1128
I remove the Point() and just only write colPaddedImage.at<vec3d>(i+h, j-h)[0] and that solved my problem. Thank you very much. Could you explain to me what is the difference between using Point() function and not?
colPaddedImage.at<vec3d>(i+h, j-h)[0] < = > colPaddedImage.at<vec3d>(Point(j-h, i+h)[0]
.at<type>(row,col) < = > .at<type>(Point(col,row))
Thank you for your explanation!