Мое приложение фильтра со следующими строками кода для создания эффекта размытия на изображениях дает ошибку времени выполнения в C - PullRequest
0 голосов
/ 05 марта 2020

Я использую алгоритм размытия рамки для создания фильтра размытия изображений, используя C. Однако я получаю некоторые ошибки во время выполнения, хотя моя программа успешно компилируется. Я получаю следующую ошибку.

помощники. c: 143: 72: ошибка времени выполнения: индекс 600 выходит за пределы для помощников типа 'RGBTRIPLE [width]'. c: 143: 158 : ошибка времени выполнения: индекс 600 выходит за пределы для помощников типа 'RGBTRIPLE [ширина]'. c: 146: 76: ошибка времени выполнения: индекс 600 выходит за границы для помощников типа 'RGBTRIPLE [ширина]'
помощники. c: 146: 166: ошибка времени выполнения: индекс 600 выходит за пределы для помощников типа 'RGBTRIPLE [ширина]'. c: 149: 74: ошибка времени выполнения: индекс 600 выходит за пределы для помощников типа 'RGBTRIPLE [ширина]'. c: 149: 162: ошибка времени выполнения: индекс 600 выходит за границы для помощников типа 'RGBTRIPLE [ширина]'
. c: 207: 72: ошибка времени выполнения: индекс 600 выходит за пределы для типа 'RGBTRIPLE [ width] 'helpers. c: 207: 158: ошибка времени выполнения: индекс 600 выходит за пределы для помощников типа' RGBTRIPLE [width] '. c: 207: 334: ошибка времени выполнения: индекс 600 выходит за пределы для типа' RGBTRIPLE [ширина] '
помощники. c: 210: 76: ошибка времени выполнения: индекс 600 выходит за пределы для помощников типа' RGBTRIPLE [ширина] '. c: 210: 16 6: ошибка времени выполнения: индекс 600 выходит за пределы для помощников типа 'RGBTRIPLE [ширина]'. c: 210: 350: ошибка времени выполнения: индекс 600 выходит за границы для помощников типа 'RGBTRIPLE [ширина]'
помощники. c: 213: 74: ошибка времени выполнения: индекс 600 выходит за пределы для помощников типа 'RGBTRIPLE [ширина]'. c: 213: 342: ошибка времени выполнения: индекс 600 выходит за границы для типа 'RGBTRIPLE [ширина]'

Ошибка действительно жалуется на следующие строки кода:

 else
            {
                red_sum = image[image_row][image_column].rgbtRed + image[image_row][image_column+1].rgbtRed + image[image_row+1][image_column].rgbtRed + image[image_row+1][image_column+1].rgbtRed + image[image_row+1][image_column-1].rgbtRed + image[image_row][image_column-1].rgbtRed;
                red_average = my_average(6.0, red_sum);

                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column+1].rgbtGreen + image[image_row+1][image_column-1].rgbtGreen + image[image_row][image_column-1].rgbtGreen;
                green_average = my_average(6.0, green_sum);

                blue_sum = image[image_row][image_column].rgbtBlue + image[image_row][image_column+1].rgbtBlue + image[image_row+1][image_column].rgbtBlue + image[image_row+1][image_column+1].rgbtBlue + image[image_row+1][image_column-1].rgbtBlue + image[image_row][image_column-1].rgbtBlue;
                blue_average = my_average(6.0, blue_sum);

                image_copy[image_row][image_column].rgbtRed = red_average;
                image_copy[image_row][image_column].rgbtGreen = green_average;
                image_copy[image_row][image_column].rgbtBlue = blue_average;
            }

и здесь:

else
    {
        if (image_column != 0 && image_column != column_end)
        {
            red_sum = image[image_row][image_column].rgbtRed + image[image_row][image_column+1].rgbtRed + image[image_row-1][image_column].rgbtRed + image[image_row-1][image_column+1].rgbtRed + image[image_row-1][image_column-1].rgbtRed + image[image_row][image_column-1].rgbtRed + image[image_row+1][image_column].rgbtRed + image[image_row+1][image_column+1].rgbtRed + image[image_row+1][image_column-1].rgbtRed;
            red_average = my_average(9.0, red_sum);

            green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column+1].rgbtGreen + image[image_row-1][image_column-1].rgbtGreen + image[image_row][image_column-1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column+1].rgbtGreen + image[image_row+1][image_column-1].rgbtGreen;
            green_average = my_average(9.0, green_sum);

            blue_sum = image[image_row][image_column].rgbtBlue + image[image_row][image_column+1].rgbtBlue + image[image_row-1][image_column].rgbtBlue + image[image_row+1][image_column-1].rgbtBlue + image[image_row-1][image_column-1].rgbtBlue + image[image_row][image_column-1].rgbtBlue + image[image_row+1][image_column].rgbtBlue + image[image_row+1][image_column+1].rgbtBlue + image[image_row+1][image_column-1].rgbtBlue;
            blue_average = my_average(9.0, blue_sum);

            image_copy[image_row][image_column].rgbtRed = red_average;
            image_copy[image_row][image_column].rgbtGreen = green_average;
            image_copy[image_row][image_column].rgbtBlue = blue_average;
        }

Большинство из которых имеет дело с обработкой середины и ребер обрабатываемого изображения.

Редактировать: Вот определение моих циклов:

    for (int image_row = 0; image_row < height; image_row++)
{
    int row_end = image_row - 1;
    for (int image_column = 0; image_column < width; image_column++)
    {
        int column_end = image_column-1;
        if (image_row == 0)
        {
            if (image_column == 0)
            {
                red_sum = image[image_row][image_column].rgbtRed + image[image_row][image_column+1].rgbtRed + image[image_row+1][image_column].rgbtRed + image[image_row+1][image_column+1].rgbtRed;
                red_average = my_average(4.0, red_sum);

                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column+1].rgbtGreen;
                green_average = my_average(4.0, green_sum);

                blue_sum = image[image_row][image_column].rgbtBlue + image[image_row][image_column+1].rgbtBlue + image[image_row+1][image_column].rgbtBlue + image[image_row+1][image_column+1].rgbtBlue;
                blue_average = my_average(4.0, blue_sum);

                image_copy[image_row][image_column].rgbtRed = red_average;
                image_copy[image_row][image_column].rgbtGreen = green_average;
                image_copy[image_row][image_column].rgbtBlue = blue_average;
            }
            else if (image_column == column_end)
            {
                red_sum = image[image_row][column_end].rgbtRed + image[image_row][column_end-1].rgbtRed + image[image_row+1][column_end].rgbtRed + image[image_row+1][column_end-1].rgbtRed;
                red_average = my_average(4.0, red_sum);

                green_sum = image[image_row][column_end].rgbtGreen + image[image_row][column_end-1].rgbtGreen + image[image_row+1][column_end].rgbtGreen + image[image_row+1][column_end-1].rgbtGreen;
                green_average = my_average(4.0, green_sum);

                blue_sum = image[image_row][column_end].rgbtBlue + image[image_row][column_end-1].rgbtBlue + image[image_row+1][column_end].rgbtBlue + image[image_row+1][column_end-1].rgbtBlue;
                blue_average = my_average(4.0, blue_sum);

                image_copy[image_row][image_column].rgbtRed = red_average;
                image_copy[image_row][image_column].rgbtGreen = green_average;
                image_copy[image_row][image_column].rgbtBlue = blue_average;
            }
            else
            {
                red_sum = image[image_row][image_column].rgbtRed + image[image_row][image_column+1].rgbtRed + image[image_row+1][image_column].rgbtRed + image[image_row+1][image_column+1].rgbtRed + image[image_row+1][image_column-1].rgbtRed + image[image_row][image_column-1].rgbtRed;
                red_average = my_average(6.0, red_sum);

                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column+1].rgbtGreen + image[image_row+1][image_column-1].rgbtGreen + image[image_row][image_column-1].rgbtGreen;
                green_average = my_average(6.0, green_sum);

                blue_sum = image[image_row][image_column].rgbtBlue + image[image_row][image_column+1].rgbtBlue + image[image_row+1][image_column].rgbtBlue + image[image_row+1][image_column+1].rgbtBlue + image[image_row+1][image_column-1].rgbtBlue + image[image_row][image_column-1].rgbtBlue;
                blue_average = my_average(6.0, blue_sum);

                image_copy[image_row][image_column].rgbtRed = red_average;
                image_copy[image_row][image_column].rgbtGreen = green_average;
                image_copy[image_row][image_column].rgbtBlue = blue_average;
            }
        }
        else if (image_row == row_end)
        {
            if (image_column == 0)
            {
                red_sum = image[image_row][image_column].rgbtRed + image[image_row][image_column+1].rgbtRed + image[image_row-1][image_column].rgbtRed + image[image_row-1][image_column+1].rgbtRed;
                red_average = my_average(4.0, red_sum);

                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column+1].rgbtGreen;
                green_average = my_average(4.0, green_sum);

                blue_sum = image[image_row][image_column].rgbtBlue + image[image_row][image_column+1].rgbtBlue + image[image_row-1][image_column].rgbtBlue + image[image_row-1][image_column+1].rgbtBlue;
                blue_average = my_average(4.0, blue_sum);

                image_copy[image_row][image_column].rgbtRed = red_average;
                image_copy[image_row][image_column].rgbtGreen = green_average;
                image_copy[image_row][image_column].rgbtBlue = blue_average;
            }
            else if (image_column == column_end)
            {
                red_sum = image[image_row][image_column].rgbtRed + image[image_row][image_column-1].rgbtRed + image[image_row-1][image_column].rgbtRed + image[image_row-1][image_column-1].rgbtRed;
                red_average = my_average(4.0, red_sum);

                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column-1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column-1].rgbtGreen;
                green_average = my_average(4.0, green_sum);

                blue_sum = image[image_row][image_column].rgbtBlue + image[image_row][image_column-1].rgbtBlue + image[image_row-1][image_column].rgbtBlue + image[image_row-1][image_column-1].rgbtBlue;
                blue_average = my_average(4.0, blue_sum);
                image_copy[image_row][image_column].rgbtRed = red_average;
                image_copy[image_row][image_column].rgbtGreen = green_average;
                image_copy[image_row][image_column].rgbtBlue = blue_average;
            }
            else
            {
                red_sum = image[image_row][image_column].rgbtRed + image[image_row][image_column+1].rgbtRed + image[image_row-1][image_column].rgbtRed + image[image_row-1][image_column+1].rgbtRed + image[image_row-1][image_column-1].rgbtRed + image[image_row][image_column-1].rgbtRed;
                red_average = my_average(6.0, red_sum);

                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column+1].rgbtGreen + image[image_row-1][image_column-1].rgbtGreen + image[image_row][image_column-1].rgbtGreen;
                green_average = my_average(6.0, green_sum);

                blue_sum = image[image_row][image_column].rgbtBlue + image[image_row][image_column+1].rgbtBlue + image[image_row-1][image_column].rgbtBlue + image[image_row+1][image_column-1].rgbtBlue + image[image_row-1][image_column-1].rgbtBlue + image[image_row][image_column-1].rgbtBlue;
                blue_average = my_average(6.0, blue_sum);
                image_copy[image_row][image_column].rgbtRed = red_average;
                image_copy[image_row][image_column].rgbtGreen = green_average;
                image_copy[image_row][image_column].rgbtBlue = blue_average;
            }
        }
        else
        {
            if (image_column != 0 && image_column != column_end)
            {
                red_sum = image[image_row][image_column].rgbtRed + image[image_row][image_column+1].rgbtRed + image[image_row-1][image_column].rgbtRed + image[image_row-1][image_column+1].rgbtRed + image[image_row-1][image_column-1].rgbtRed + image[image_row][image_column-1].rgbtRed + image[image_row+1][image_column].rgbtRed + image[image_row+1][image_column+1].rgbtRed + image[image_row+1][image_column-1].rgbtRed;
                red_average = my_average(9.0, red_sum);

                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column+1].rgbtGreen + image[image_row-1][image_column-1].rgbtGreen + image[image_row][image_column-1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column+1].rgbtGreen + image[image_row+1][image_column-1].rgbtGreen;
                green_average = my_average(9.0, green_sum);

                blue_sum = image[image_row][image_column].rgbtBlue + image[image_row][image_column+1].rgbtBlue + image[image_row-1][image_column].rgbtBlue + image[image_row+1][image_column-1].rgbtBlue + image[image_row-1][image_column-1].rgbtBlue + image[image_row][image_column-1].rgbtBlue + image[image_row+1][image_column].rgbtBlue + image[image_row+1][image_column+1].rgbtBlue + image[image_row+1][image_column-1].rgbtBlue;
                blue_average = my_average(9.0, blue_sum);

                image_copy[image_row][image_column].rgbtRed = red_average;
                image_copy[image_row][image_column].rgbtGreen = green_average;
                image_copy[image_row][image_column].rgbtBlue = blue_average;
            }
            else if (image_column == 0)
            {
                red_sum = image[image_row][image_column].rgbtRed + image[image_row][image_column+1].rgbtRed + image[image_row-1][image_column].rgbtRed + image[image_row-1][image_column+1].rgbtRed + image[image_row+1][image_column].rgbtRed + image[image_row+1][image_column+1].rgbtRed;
                red_average = my_average(6.0, red_sum);

                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column+1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column+1].rgbtGreen;
                green_average = my_average(9.0, green_sum);

                blue_sum = image[image_row][image_column].rgbtBlue + image[image_row][image_column+1].rgbtBlue + image[image_row-1][image_column].rgbtBlue + image[image_row-1][image_column+1].rgbtBlue + image[image_row+1][image_column].rgbtBlue + image[image_row+1][image_column+1].rgbtBlue;
                blue_average = my_average(9.0, blue_sum);

                image_copy[image_row][image_column].rgbtRed = red_average;
                image_copy[image_row][image_column].rgbtGreen = green_average;
                image_copy[image_row][image_column].rgbtBlue = blue_average;
            }
            else
            {
                red_sum = image[image_row][image_column].rgbtRed + image[image_row][image_column-1].rgbtRed + image[image_row-1][image_column].rgbtRed + image[image_row-1][image_column-1].rgbtRed + image[image_row+1][image_column].rgbtRed + image[image_row+1][image_column-1].rgbtRed;
                red_average = my_average(6.0, red_sum);

                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column-1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column-1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column-1].rgbtGreen;
                green_average = my_average(9.0, green_sum);

                blue_sum = image[image_row][image_column].rgbtBlue + image[image_row][image_column-1].rgbtBlue + image[image_row-1][image_column].rgbtBlue + image[image_row][image_column-1].rgbtBlue + image[image_row+1][image_column].rgbtBlue + image[image_row+1][image_column-1].rgbtBlue;
                blue_average = my_average(9.0, blue_sum);

                image_copy[image_row][image_column].rgbtRed = red_average;
                image_copy[image_row][image_column].rgbtGreen = green_average;
                image_copy[image_row][image_column].rgbtBlue = blue_average;
            }
        }
    }
}

Обновление: Я ценю любую помощь, которая мне помогала. Теперь, когда коды работают, любые предложения по областям текущего кода, которые можно улучшить для повторного использования.

1 Ответ

1 голос
/ 06 марта 2020

Неприятные маленькие опечатки ...

Я убрал строки, которые явно не могли вызвать проблемы. Осталось несколько обращений к массиву. Затем я применил некоторое приличное выравнивание ваших линий.

Если вы делаете то же самое с 3 значениями тройки, линии должны выглядеть одинаково. Если вы посмотрите на него поближе, этот шаблон будет разбит в 3 местах, где 1 вызывает бесконечный доступ, тогда как 2 других дают неправильные результаты. К сожалению, я не знаю, почему вы сообщили о нескольких строках.

for (int image_row = 0; image_row < height; image_row++)
{
    int row_end = image_row - 1;
    int column_end = image_column-1;

    for (int image_column = 0; image_column < width; image_column++)
    {
        if (image_row == 0)
        {   // top
            if (image_column == 0)
            {   // top left
                red_sum   = image[image_row][image_column].rgbtRed   + image[image_row][image_column+1].rgbtRed   + image[image_row+1][image_column].rgbtRed   + image[image_row+1][image_column+1].rgbtRed;
                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column+1].rgbtGreen;
                blue_sum  = image[image_row][image_column].rgbtBlue  + image[image_row][image_column+1].rgbtBlue  + image[image_row+1][image_column].rgbtBlue  + image[image_row+1][image_column+1].rgbtBlue;
            }
            else if (image_column == column_end)
            {   // top right
                red_sum   = image[image_row][column_end].rgbtRed   + image[image_row][column_end-1].rgbtRed   + image[image_row+1][column_end].rgbtRed   + image[image_row+1][column_end-1].rgbtRed;
                green_sum = image[image_row][column_end].rgbtGreen + image[image_row][column_end-1].rgbtGreen + image[image_row+1][column_end].rgbtGreen + image[image_row+1][column_end-1].rgbtGreen;
                blue_sum  = image[image_row][column_end].rgbtBlue  + image[image_row][column_end-1].rgbtBlue  + image[image_row+1][column_end].rgbtBlue  + image[image_row+1][column_end-1].rgbtBlue;
            }
            else
            {   // top middle
                red_sum   = image[image_row][image_column].rgbtRed   + image[image_row][image_column+1].rgbtRed   + image[image_row+1][image_column].rgbtRed   + image[image_row+1][image_column+1].rgbtRed   + image[image_row+1][image_column-1].rgbtRed   + image[image_row][image_column-1].rgbtRed;
                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column+1].rgbtGreen + image[image_row+1][image_column-1].rgbtGreen + image[image_row][image_column-1].rgbtGreen;
                blue_sum  = image[image_row][image_column].rgbtBlue  + image[image_row][image_column+1].rgbtBlue  + image[image_row+1][image_column].rgbtBlue  + image[image_row+1][image_column+1].rgbtBlue  + image[image_row+1][image_column-1].rgbtBlue  + image[image_row][image_column-1].rgbtBlue;
            }
        }
        else if (image_row == row_end)
        {   // bottom
            if (image_column == 0)
            {   // bottom left
                red_sum   = image[image_row][image_column].rgbtRed   + image[image_row][image_column+1].rgbtRed   + image[image_row-1][image_column].rgbtRed   + image[image_row-1][image_column+1].rgbtRed;
                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column+1].rgbtGreen;
                blue_sum  = image[image_row][image_column].rgbtBlue  + image[image_row][image_column+1].rgbtBlue  + image[image_row-1][image_column].rgbtBlue  + image[image_row-1][image_column+1].rgbtBlue;
            }
            else if (image_column == column_end)
            {   // bottom right
                red_sum   = image[image_row][image_column].rgbtRed   + image[image_row][image_column-1].rgbtRed   + image[image_row-1][image_column].rgbtRed   + image[image_row-1][image_column-1].rgbtRed;
                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column-1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column-1].rgbtGreen;
                blue_sum  = image[image_row][image_column].rgbtBlue  + image[image_row][image_column-1].rgbtBlue  + image[image_row-1][image_column].rgbtBlue  + image[image_row-1][image_column-1].rgbtBlue;
            }
            else
            {   // bottom middle
                red_sum   = image[image_row][image_column].rgbtRed   + image[image_row][image_column+1].rgbtRed   + image[image_row-1][image_column].rgbtRed   + image[image_row-1][image_column+1].rgbtRed   + image[image_row-1][image_column-1].rgbtRed   + image[image_row][image_column-1].rgbtRed;
                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column+1].rgbtGreen + image[image_row-1][image_column-1].rgbtGreen + image[image_row][image_column-1].rgbtGreen;
                blue_sum  = image[image_row][image_column].rgbtBlue  + image[image_row][image_column+1].rgbtBlue  + image[image_row-1][image_column].rgbtBlue  + image[image_row+1][image_column-1].rgbtBlue  + image[image_row-1][image_column-1].rgbtBlue  + image[image_row][image_column-1].rgbtBlue;
            }                                                                                                                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ image_row+1 is out of bounds!
        }
        else
        {   // middle
            if (image_column != 0 && image_column != column_end)
            {   middle middle
                red_sum   = image[image_row][image_column].rgbtRed   + image[image_row][image_column+1].rgbtRed   + image[image_row-1][image_column].rgbtRed   + image[image_row-1][image_column+1].rgbtRed   + image[image_row-1][image_column-1].rgbtRed   + image[image_row][image_column-1].rgbtRed   + image[image_row+1][image_column].rgbtRed   + image[image_row+1][image_column+1].rgbtRed   + image[image_row+1][image_column-1].rgbtRed;
                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column+1].rgbtGreen + image[image_row-1][image_column-1].rgbtGreen + image[image_row][image_column-1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column+1].rgbtGreen + image[image_row+1][image_column-1].rgbtGreen;
                blue_sum  = image[image_row][image_column].rgbtBlue  + image[image_row][image_column+1].rgbtBlue  + image[image_row-1][image_column].rgbtBlue  + image[image_row+1][image_column-1].rgbtBlue  + image[image_row-1][image_column-1].rgbtBlue  + image[image_row][image_column-1].rgbtBlue  + image[image_row+1][image_column].rgbtBlue  + image[image_row+1][image_column+1].rgbtBlue  + image[image_row+1][image_column-1].rgbtBlue;
            }                                                                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ wrong, but not out of bounds
            else if (image_column == 0)
            {   middle left
                red_sum   = image[image_row][image_column].rgbtRed   + image[image_row][image_column+1].rgbtRed   + image[image_row-1][image_column].rgbtRed   + image[image_row-1][image_column+1].rgbtRed   + image[image_row+1][image_column].rgbtRed   + image[image_row+1][image_column+1].rgbtRed;
                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column+1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column+1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column+1].rgbtGreen;
                blue_sum  = image[image_row][image_column].rgbtBlue  + image[image_row][image_column+1].rgbtBlue  + image[image_row-1][image_column].rgbtBlue  + image[image_row-1][image_column+1].rgbtBlue  + image[image_row+1][image_column].rgbtBlue  + image[image_row+1][image_column+1].rgbtBlue;
            }
            else
            {   middle right
                red_sum   = image[image_row][image_column].rgbtRed   + image[image_row][image_column-1].rgbtRed   + image[image_row-1][image_column].rgbtRed   + image[image_row-1][image_column-1].rgbtRed   + image[image_row+1][image_column].rgbtRed   + image[image_row+1][image_column-1].rgbtRed;
                green_sum = image[image_row][image_column].rgbtGreen + image[image_row][image_column-1].rgbtGreen + image[image_row-1][image_column].rgbtGreen + image[image_row-1][image_column-1].rgbtGreen + image[image_row+1][image_column].rgbtGreen + image[image_row+1][image_column-1].rgbtGreen;
                blue_sum  = image[image_row][image_column].rgbtBlue  + image[image_row][image_column-1].rgbtBlue  + image[image_row-1][image_column].rgbtBlue  + image[image_row][image_column-1].rgbtBlue    + image[image_row+1][image_column].rgbtBlue  + image[image_row+1][image_column-1].rgbtBlue;
            }                                                                                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ wrong, but not out of bounds.
        }
    }
}
...