Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void blur(int height, int width, RGBTRIPLE image[height][width])
- {
- // Create a copy of image
- RGBTRIPLE copy[height][width];
- for (int i = 0; i < height; i++)
- {
- for (int j = 0; j < width; j++)
- {
- copy[i][j] = image[i][j];
- }
- }
- for (int i = 0; i < height; i++)
- {
- for (int j = 0; j < width; j++)
- {
- int newRed = 0;
- int newGreen = 0;
- int newBlue = 0;
- float avgCount = 0.0;
- for (int k = -1; k <= 1; k++)
- {
- for (int l = -1; l <= -1; l++)
- {
- if (!(i + k == -1) && !(i + k == height) && !(j + l == -1) && !(j + l == width))
- {
- newRed += copy[(i+k)][(j+l)].rgbtRed;
- newGreen += copy[(i+k)][(j+l)].rgbtGreen;
- newBlue += copy[(i+k)][(j+l)].rgbtBlue;
- avgCount += 1.0;
- }
- }
- }
- image[i][j].rgbtRed = round(newRed / avgCount);
- image[i][j].rgbtGreen = round(newGreen / avgCount);
- image[i][j].rgbtBlue = round(newBlue / avgCount);
- }
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement