mirror of https://github.com/me50/kukemuna.git
automated commit by submit50
This commit is contained in:
parent
01b1cf22da
commit
3662745235
25
helpers.c
25
helpers.c
|
|
@ -1,5 +1,5 @@
|
||||||
#include <math.h>
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
// Convert image to grayscale
|
// Convert image to grayscale
|
||||||
void grayscale(int height, int width, RGBTRIPLE image[height][width])
|
void grayscale(int height, int width, RGBTRIPLE image[height][width])
|
||||||
|
|
@ -8,7 +8,8 @@ void grayscale(int height, int width, RGBTRIPLE image[height][width])
|
||||||
{
|
{
|
||||||
for (int j = 0; j < width; j++)
|
for (int j = 0; j < width; j++)
|
||||||
{
|
{
|
||||||
int avg = round((image[i][j].rgbtBlue + image[i][j].rgbtGreen + image[i][j].rgbtRed) / (float) 3);
|
int avg = round((image[i][j].rgbtBlue + image[i][j].rgbtGreen + image[i][j].rgbtRed) /
|
||||||
|
(float) 3);
|
||||||
image[i][j].rgbtBlue = image[i][j].rgbtGreen = image[i][j].rgbtRed = avg;
|
image[i][j].rgbtBlue = image[i][j].rgbtGreen = image[i][j].rgbtRed = avg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -22,9 +23,12 @@ void sepia(int height, int width, RGBTRIPLE image[height][width])
|
||||||
{
|
{
|
||||||
for (int j = 0; j < width; j++)
|
for (int j = 0; j < width; j++)
|
||||||
{
|
{
|
||||||
int sepiaRed = round(.393 * image[i][j].rgbtRed + .769 * image[i][j].rgbtGreen + .189 * image[i][j].rgbtBlue);
|
int sepiaRed = round(.393 * image[i][j].rgbtRed + .769 * image[i][j].rgbtGreen +
|
||||||
int sepiaGreen = round(.349 * image[i][j].rgbtRed + .686 * image[i][j].rgbtGreen + .168 * image[i][j].rgbtBlue);
|
.189 * image[i][j].rgbtBlue);
|
||||||
int sepiaBlue = round(.272 * image[i][j].rgbtRed + .534 * image[i][j].rgbtGreen + .131 * image[i][j].rgbtBlue);
|
int sepiaGreen = round(.349 * image[i][j].rgbtRed + .686 * image[i][j].rgbtGreen +
|
||||||
|
.168 * image[i][j].rgbtBlue);
|
||||||
|
int sepiaBlue = round(.272 * image[i][j].rgbtRed + .534 * image[i][j].rgbtGreen +
|
||||||
|
.131 * image[i][j].rgbtBlue);
|
||||||
|
|
||||||
if (sepiaRed > 255)
|
if (sepiaRed > 255)
|
||||||
{
|
{
|
||||||
|
|
@ -88,8 +92,7 @@ void blur(int height, int width, RGBTRIPLE image[height][width])
|
||||||
{
|
{
|
||||||
for (int j = 0; j < width; j++)
|
for (int j = 0; j < width; j++)
|
||||||
{
|
{
|
||||||
float sumRed = 0, sumGreen = 0, sumBlue = 0;
|
int sumRed = 0, sumGreen = 0, sumBlue = 0, count = 0;
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
for (int k = (i - 1); k <= (i + 1); k++)
|
for (int k = (i - 1); k <= (i + 1); k++)
|
||||||
{
|
{
|
||||||
|
|
@ -97,10 +100,10 @@ void blur(int height, int width, RGBTRIPLE image[height][width])
|
||||||
{
|
{
|
||||||
if ((k >= 0 && k <= (height - 1)) && (l >= 0 && l <= (width - 1)))
|
if ((k >= 0 && k <= (height - 1)) && (l >= 0 && l <= (width - 1)))
|
||||||
{
|
{
|
||||||
sumRed += copy[k][l].rgbtRed;
|
sumRed += copy[k][l].rgbtRed;
|
||||||
sumGreen += copy[k][l].rgbtGreen;
|
sumGreen += copy[k][l].rgbtGreen;
|
||||||
sumBlue += copy[k][l].rgbtBlue;
|
sumBlue += copy[k][l].rgbtBlue;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue