From 2c8d257f294df4532707fdac28642d458a71c6d6 Mon Sep 17 00:00:00 2001 From: saumya1317 Date: Wed, 22 Oct 2025 15:17:02 +0530 Subject: [PATCH] feat: fix brightness filter implementation for proper GCC compatibility and argument parsing --- README.md | 8 -------- filter.c | 34 +++++++++++++--------------------- helpers.c | 17 ----------------- helpers.h | 8 ++++---- 4 files changed, 17 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index be21640..971857d 100644 --- a/README.md +++ b/README.md @@ -113,14 +113,6 @@ For a pixel along the edge or corner, like pixel 15, we would still look for all If you apply the above algorithm to each pixel in the image, the result should look like a blurry, out-of-focus version of the original. -### 5.) Threshold Filter (Black & White) -- **Flag:** `-t` -- **Description:** Converts each pixel in the image to pure black or white based on its intensity. If the average of red, green, and blue is greater than or equal to 128, the pixel becomes white (255,255,255); otherwise, it becomes black (0,0,0). -- **Usage example:** -```sh -./filter -t input.bmp output.bmp -``` - ### 6.) Brightness Adjustment Filter - **Flag:** `-B ` - **Description:** Increases or decreases the brightness of the image by adding a fixed value to each pixel's R, G, and B channels. The value should be an integer—positive to increase, negative to decrease. diff --git a/filter.c b/filter.c index aaad81c..53b9145 100644 --- a/filter.c +++ b/filter.c @@ -7,20 +7,20 @@ int main(int argc, char *argv[]) { // Define allowable filters - char *filters = "bgrsitB"; + char *filters = "bgrsivB:"; char filterArr[argc-3]; + int filterCount = 0; // gets all filter flags and checks validity - for(int i=0; i= 128) { - image[i][j].rgbtRed = 255; - image[i][j].rgbtGreen = 255; - image[i][j].rgbtBlue = 255; - } else { - image[i][j].rgbtRed = 0; - image[i][j].rgbtGreen = 0; - image[i][j].rgbtBlue = 0; - } - } - } -} - void brightness(int height, int width, RGBTRIPLE image[height][width], int value) { for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { diff --git a/helpers.h b/helpers.h index 317efb3..b553162 100644 --- a/helpers.h +++ b/helpers.h @@ -15,8 +15,8 @@ void reflect(int height, int width, RGBTRIPLE image[height][width]); // Blur image void blur(int height, int width, RGBTRIPLE image[height][width]); -// Threshold filter (black and white) -void threshold(int height, int width, RGBTRIPLE image[height][width]); - // Brightness adjustment filter -void brightness(int height, int width, RGBTRIPLE image[height][width], int value); \ No newline at end of file +void brightness(int height, int width, RGBTRIPLE image[height][width], int value); + +// Vignette filter +void vignette(int height, int width, RGBTRIPLE image[height][width]); \ No newline at end of file