Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Wind9 = (3,3,CV_8UC1, (0)); won't compile. for sure you wanted: Wind9 = Mat(3,3,CV_8UC1, Scalar(0));

the missing Scalar is also the reason for the crash, it thinks, you're giving it a pointer.

in the long run, you should avoid using for-loops like that, it is very error-prone, and you're defeating any builtin optimization. you can easily use a ROI like this:

Mat Source = imread("saltpepper1.png", IMREAD_GRAYSCALE);
cv::Mat Wind9 = Source(Rect(39,39,3,3)); // center is 40,40

Wind9 = (3,3,CV_8UC1, (0)); won't compile. for sure you wanted: wanted:

Wind9 = Mat(3,3,CV_8UC1, Scalar(0));

the missing Scalar is also the reason for the crash, it thinks, you're giving it a pointer.

in the long run, you should avoid using for-loops like that, it is very error-prone, and you're defeating any builtin optimization. you can easily use a ROI like this:

Mat Source = imread("saltpepper1.png", IMREAD_GRAYSCALE);
cv::Mat Wind9 = Source(Rect(39,39,3,3)); // center is 40,40