This repository contains a simple C program for image processing using the STB Image library. The program loads an image, performs pixel manipulation, and saves the result as a new image.
- STB Image Library (already included in the repository)
-
Clone the repository:
git clone https://github.com/SaranDharshanSP/Image-Processing-Negative-Image-in-C.git cd your-repo
-
Compile the program:
gcc -o Image-Processing-Negative-Image-in-C image_processing.c -lm
-
Make sure you have an image named
amm.jpg
in the same directory as the executable. -
Run the compiled program:
./image_processing
The program will process the image, create a new image named
nan.jpg
, and save it in the same directory.
Input Image | Output Image |
---|---|
Input Image 1 | Output Image 1 |
Input Image 2 | Output Image 2 |
Input Image 3 | Output Image 3 |
Input Image 4 | Output Image 4 |
Input Image 5 | Output Image 5 |
Input Image 6 | Output Image 6 |
This program demonstrates basic image processing using the STB Image library. The following steps are performed:
- Load an image named
amm.jpg
. - Determine the image's width, height, and number of color channels.
- Allocate memory for a new image (
nimg
) to store the manipulated pixels. - Depending on the number of channels, invert pixel values:
- For grayscale images (1 or 2 channels), invert pixel values.
- For RGB images (3 channels), invert each channel's pixel value.
- Save the manipulated image as
nan.jpg
.
Contributions are welcome! If you'd like to contribute to this project, feel free to open an issue or submit a pull request.