原图
结果图
//包含头文件
#include <opencv2/opencv.hpp>
//命名空间
using namespace cv;
using namespace std;
//全局函数声明部分
//我的腐蚀运算
Mat Erode(Mat src, Mat Mask, uint32_t x0, uint32_t y0)
{
uint32_t x = 0, y = 0;
Mat dst(src.rows, src.cols, CV_8U, Scalar(0));
for (x = 0; x < src.cols; ++x)
{
for (y = 0; y < src.rows; ++y)
{
uint8_t dst_P = 255;
for (uint32_t xm = 0; xm < Mask.cols; ++xm)
{
for (uint32_t ym = 0; ym < Mask.rows; ++ym)
{
if (dst_P && Mask.at<uchar>(Point(xm, ym)) && (x + xm) < src.cols && (y + ym) < src.rows)
if (dst_P > src.at<uchar>(Point