I want to create a dilation image using a kernel that runs through the entire image and checks if the kernel zone has 0, if so, it gives the new image a pixel of 255. My code is giving me an all black dst and I don't know why. This is the code:
Mat vcpi_binary_dilate(Mat src)
{
    if (src.empty())
    {
        cout << "Failed to load image.";
        return src;
    }
    Mat dst(src.rows, src.cols, CV_8UC1, Scalar(0));
    const int kernnel = 3;
    int array[kernnel * kernnel] = {};
    for (int y = kernnel / 2; y < src.cols - kernnel / 2; y++)
    {
        for (int x = kernnel / 2; x < src.rows - kernnel / 2; x++)
            for (int yk = -kernnel / 2; yk <= kernnel / 2; yk++)
            {
                for (int xk = -kernnel / 2; xk <= kernnel / 2; xk++)
                {
                    if (src.at<uchar>(y + yk, x + xk) == 0)
                    {
                        dst.at<uchar>(y + yk, x + xk) = 255;
                    }
                }
            }
    }
    imshow("Image ", src);
    imshow("Image dilate", dst);
    waitKey(0);
    return dst;
}
I hope to have an output image of this type.
 
     
    