Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void reflect(int height, int width, RGBTRIPLE image[height][width])
- {
- int row_loop = round(width / 2);
- for (int i = 0; i < height; i++)
- {
- for (int j = 1; j < row_loop; j++)
- {
- RGBTRIPLE tmp = image[i][j];
- image[i][j] = image[i][width - j];
- image[i][width - j] = tmp;
- }
- }
- return;
- }
- void blur(int height, int width, RGBTRIPLE image[height][width])
- {
- RGBTRIPLE copy[height][width];
- for (int i = 0; i < height; i++)
- {
- for (int j = 0; j < width; j++)
- {
- copy[i][j] = image[i][j];
- RGBTRIPLE average = blur_indiv(height, width, i, j, copy);
- image[i][j].rgbtRed = average.rgbtRed;
- image[i][j].rgbtGreen = average.rgbtGreen;
- image[i][j].rgbtBlue = average.rgbtBlue;
- }
- }
- return;
- }
- RGBTRIPLE blur_indiv(int height, int width, int h, int w, RGBTRIPLE image[h][w])
- {
- float counter = 1;
- RGBTRIPLE average;
- average = image[h][w];
- if (0 < (h - 1) <= height && 0 < (w - 1) <= width)
- {
- average.rgbtRed += image[h - 1][w - 1].rgbtRed;
- average.rgbtGreen += image[h - 1][w - 1].rgbtGreen;
- average.rgbtBlue += image[h - 1][w - 1].rgbtBlue;
- counter++;
- }
- if (0 < (h - 1) <= height && 0 < w <= width)
- {
- average.rgbtRed += image[h - 1][w].rgbtRed;
- average.rgbtGreen += image[h - 1][w].rgbtGreen;
- average.rgbtBlue += image[h - 1][w].rgbtBlue;
- counter++;
- }
- if (0 < (h - 1) <= height && 0 < (w + 1) <= width)
- {
- average.rgbtRed += image[h - 1][w + 1].rgbtRed;
- average.rgbtGreen += image[h - 1][w + 1].rgbtGreen;
- average.rgbtBlue += image[h - 1][w + 1].rgbtBlue;
- counter++;
- }
- if (0 < h <= height && 0 < (w - 1) <= width)
- {
- average.rgbtRed += image[h][w - 1].rgbtRed;
- average.rgbtGreen += image[h][w - 1].rgbtGreen;
- average.rgbtBlue += image[h][w - 1].rgbtBlue;
- counter++;
- }
- if (0 < h <= height && 0 < (w + 1) <= width)
- {
- average.rgbtRed += image[h][w + 1].rgbtRed;
- average.rgbtGreen += image[h][w + 1].rgbtGreen;
- average.rgbtBlue += image[h][w + 1].rgbtBlue;
- counter++;
- }
- if (0 < (h + 1) <= height && 0 < (w - 1) <= width)
- {
- average.rgbtRed += image[h + 1][w - 1].rgbtRed;
- average.rgbtGreen += image[h + 1][w - 1].rgbtGreen;
- average.rgbtBlue += image[h + 1][w - 1].rgbtBlue;
- counter++;
- }
- if (0 < (h + 1) <= height && 0 < w <= width)
- {
- average.rgbtRed += image[h + 1][w].rgbtRed;
- average.rgbtGreen += image[h + 1][w].rgbtGreen;
- average.rgbtBlue += image[h + 1][w].rgbtBlue;
- counter++;
- }
- if (0 < (h + 1) <= height && 0 < (w + 1) <= width)
- {
- average.rgbtRed += image[h + 1][w + 1].rgbtRed;
- average.rgbtGreen += image[h + 1][w + 1].rgbtGreen;
- average.rgbtBlue += image[h + 1][w + 1].rgbtBlue;
- counter++;
- }
- average.rgbtRed /= counter;
- average.rgbtGreen /= counter;
- average.rgbtBlue /= counter;
- return average;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement