Pure C Image Processing Library - Learn from Scratch
A lightweight, educational image processing library in pure C with zero external dependencies. Perfect for learning DFT/FFT, convolution, edge detection, morphology, and frequency domain filtering from scratch.
Why Piciem?
- Educational - Clean, readable code with examples
- Lightweight - No OpenCV, no NumPy, just standard C library
- Learn by doing - Build algorithms, don't just use them
- Embedded-friendly - Small footprint, easy to port
| Brightness (+50) | Contrast (×1.5) | Invert |
|---|---|---|
![]() |
![]() |
![]() |
| Simple (t=128) | Otsu |
|---|---|
![]() |
![]() |
| Histogram Equalization | Sobel |
|---|---|
![]() |
![]() |
| DFT (4.39s) | FFT (0.02s) |
|---|---|
![]() |
![]() |
| Input | Output |
|---|---|
![]() |
![]() |
| Input | Output |
|---|---|
![]() |
![]() |
Parameters: D0=30, γL=0.8, γH=1.5, n=2
| Original | Gaussian Blur | Noisy (5%) | Median Denoised |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
| Original | Low Pass (Butterworth, cutoff=30) |
|---|---|
![]() |
![]() |
Low pass filter attenuates high frequencies, resulting in a smoothed/blurred image.
| Binary | Eroded | Dilated |
|---|---|---|
![]() |
![]() |
![]() |
| Opening | Closing |
|---|---|
![]() |
![]() |
lpgm_file_read()- Read PGM (P2/P5)lpgm_file_write()- Write PGM
lpgm_brightness()-out = in + δlpgm_contrast()-out = (in-128)×α + 128lpgm_invert()-out = 255 - inlpgm_threshold()- Binary thresholdlpgm_otsu_threshold()- Automatic threshold
lpgm_convolve()- NxN kernel convolutionlpgm_median_filter()- Median filterlpgm_add_salt_pepper_noise()- Add noiselpgm_gamma()- Gamma correction
lpgm_histogram_equalization()- Histogram equalizationlpgm_sobel()- Edge detection
lpgm_dft()/lpgm_dft2()- DFT, O(n²)lpgm_fft()/lpgm_fft2()- FFT, O(n log n)lpgm_filter_ideal_lowpass/highpass()- Ideal filterlpgm_filter_butterworth_lowpass/highpass()- Butterworth filterlpgm_filter_gaussian_lowpass/highpass()- Gaussian filter
lpgm_erode()- Erosionlpgm_dilate()- Dilationlpgm_opening()- Opening (erosion + dilation)lpgm_closing()- Closing (dilation + erosion)
git clone https://github.com/uzunenes/piciem.git
cd piciem
make
sudo make installcd examples/edge_detection
make
./sobel.out ../pgm_io/lena_ascii.pgmpiciem/
├── include/pigiem.h
├── src/
│ ├── pgm_io.c
│ ├── image.c
│ ├── dft.c
│ ├── fft.c
│ └── utils.c
├── examples/
│ ├── basic_operations/
│ ├── thresholding/
│ ├── filters/
│ ├── noise/
│ ├── histogram/
│ ├── edge_detection/
│ ├── frequency_domain/
│ ├── frequency_filters/
│ ├── morphology/
│ └── homomorphic_filtering/
└── docs/images/
#include <pigiem.h>
int main(void)
{
lpgm_t pgm;
lpgm_image_t edges;
lpgm_file_read("input.pgm", &pgm);
edges = lpgm_sobel(&pgm.im);
pgm.im = edges;
lpgm_file_write(&pgm, "output.pgm");
lpgm_image_destroy(&edges);
lpgm_file_destroy(&pgm);
return 0;
}gcc -o example example.c -lpigiem -lmContributions are welcome! Feel free to open issues or submit pull requests.
If you find this library useful for learning image processing, please consider giving it a star!
MIT






















