this code is supposed to blur an image together with other supporting files as per CS50 Pset4. I am able to compile my code with no errors but when I try to run the program to get my filtered image, it says Segmentation fault (Core Dumped).

I understand that error refers to touching memory that I'm not supposed to but I couldn't figure out the problem with my code. New to coding so please do help!! thankss (:

    // Blur image
    void blur(int height, int width, RGBTRIPLE image[height][width])
    {
    RGBTRIPLE tmpimg[height][width];
    RGBTRIPLE sum;
    for(int i = 0; i < height; i++)
    {
        for(int j = 0; j < width; j++)
        {
            int counter = 0;
            sum.rgbtRed = 0;
            sum.rgbtGreen = 0;
            sum.rgbtBlue = 0;
            for(int a = -1; a < 2; a++)
            {
                for (int b = -1; b < 2; b++)
                {
                    if((i + a) > 0 || (i + a) < height - 1 || (j + b) > 0 || (j + b) < width - 1)
                    {
                        sum.rgbtRed += image[i + a][j + b].rgbtRed;
                        sum.rgbtGreen += image[i + a][j + b].rgbtGreen;
                        sum.rgbtBlue += image[i + a][j + b].rgbtBlue;
                        counter++;
                    }
                }
            }
            tmpimg[i][j].rgbtRed = round(sum.rgbtRed / counter);
            tmpimg[i][j].rgbtGreen = round(sum.rgbtGreen / counter);
            tmpimg[i][j].rgbtBlue = round(sum.rgbtBlue / counter);
        }
    }
    for(int i = 0; i < height; i++)
    {
        for(int j = 0; j < width; j++)
        {
            image[i][j] = tmpimg[i][j];
        }
    }
    return;
}