#include "helpers.h"
#include <math.h>
// Convert image to grayscale
void grayscale(int height, int width, RGBTRIPLE image[height][width])
{
// comb trw each row
for (int i = 0; i < height; i++)
{
// comb trw each colum
for (int j = 0; j < width; j++)
{
// convert pixels to floats
float Red = image[i][j].rgbtRed;
float Green = image[i][j].rgbtGreen;
float Blue = image[i][j].rgbtBlue;
// find the avrage value
int average = round((Red + Green + Blue) / 3);
image[i][j].rgbtRed = image[i][j].rgbtGreen = image[i][j].rgbtBlue = average;
}
}
return;
}
// Convert image to sepia
void sepia(int height, int width, RGBTRIPLE image[height][width])
{
// Watch each row
for (int i = 0; i < height; i++)
{
// Watch each colum
for (int j = 0; j < width; j++)
{
//converts pixels to floats
float originalRed[i][j] = image[i][j].rgbtRed;
float originalGreen[i][j] = image[i][j].rgbtGreen;
float originalBlue[i][j] = image[i][j].rgbtBlue;
// find the updated pixel value
int sepiaRed = round(0.393 * originalRed + 0.769 * originalGreen + 0.189 * originalBlue);
int sepiaGreen = round(0.349 * originalRed + 0.686 * originalGreen + 0.168 * originalBlue);
int sepiaBlue = round(0.272 * originalRed + 0.534 * originalGreen + 0.131 * originalBlue);
// update the pixel value if exceeds 255
if (sepiaRed > 255)
{
sepiaRed = 255;
}
if (sepiaGreen > 255)
{
sepiaGreen = 255;
}
if (sepiaBlue > 255)
{
sepiaBlue = 255;
}
image[i][j].rgbtRed = sepiaRed;
image[i][j].rgbtGreen = sepiaGreen;
image[i][j].rgbtBlue = sepiaBlue;
}
}
return;
}
// Reflect image horizontally
void reflect(int height, int width, RGBTRIPLE image[height][width])
{
return;
}
// Blur image
void blur(int height, int width, RGBTRIPLE image[height][width])
{
return;
}
and this is the error
filter-less/ $ make filter
helpers.c:35:15: error: variable-sized object may not be initialized
float originalRed[i][j] = image[i][j].rgbtRed;
^ ~~~~~~~~~~~~~~~~~~~
helpers.c:36:15: error: variable-sized object may not be initialized
float originalGreen[i][j] = image[i][j].rgbtGreen;
^ ~~~~~~~~~~~~~~~~~~~~~
helpers.c:37:15: error: variable-sized object may not be initialized
float originalBlue[i][j] = image[i][j].rgbtBlue;
^ ~~~~~~~~~~~~~~~~~~~~
3 errors generated.
make: *** [Makefile:2: filter] Error 1
filter-less/ $