Skip to content

emiliamihut/Advanced-Image-Editor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Image Manipulation Application

An image editor for PGM/PPM (P2, P3, P5, P6) that loads images, selects areas, crops, rotates by 90/180/270 degrees, applies filters (EDGE, SHARPEN, BLUR, GAUSSIAN_BLUR), builds histograms, performs histogram equalization, and saves results. Operations are modular with explicit memory management.

Features

  • Load and save ASCII/binary formats (P2/P3/P5/P6) including headers and pixel matrices.
  • Selection: select_area(x1,y1,x2,y2) with bounds validation and normalized coordinate order; select_all for full image.
  • Crop: keep only the selected region, reallocate pixel matrix, update dimensions and selection.
  • Rotate: 90/180/270 degrees for whole image or square selection, with angle normalization (mod 360).
  • Filters: EDGE, SHARPEN, BLUR, GAUSSIAN_BLUR via convolution kernel and divisor, skipping borders and clamping output.
  • Histogram: grayscale only, bins as power of two, bin size = (max_val+1)/bins, star-bar scaled to requested width.
  • Equalize: grayscale contrast via cumulative histogram mapping new = (cum_freq/total_pixels) * 255.

Data Structures

  • pixel: r,g,b for color or l for grayscale intensity.
  • image: pixels matrix, width, height, max_val, format, selection coordinates x1,y1,x2,y2.

Commands

  • LOAD: parse format, dimensions, max pixel value; read pixels (ASCII/binary); grayscale mapped to l, color to r,g,b.
  • SELECT: select_area(x1,y1,x2,y2) validates bounds and normalizes coordinates; select_all covers entire image.
  • CROP: allocate new matrix for selection, free old matrix, update image size and selection.
  • ROTATE: 0/90/180/270; selection must be square for partial rotate; index remaps for each angle; rotate_full/rotate_select variants.
  • APPLY: EDGE | SHARPEN | BLUR | GAUSSIAN_BLUR; build kernel/divisor, skip borders, normalize and clamp.
  • HISTOGRAM: grayscale only; bins = power of 2; bin size = (max_val+1)/bins; star-bar scaled by requested width.
  • EQUALIZE: compute histogram and CDF; map value = (cum_freq/total_pixels) * 255.
  • SAVE: write chosen ASCII/binary format with header and pixel matrix.

I/O and Robustness

  • Input buffer is cleared after each command using a getchar loop to discard leftovers.
  • Parameters parsed via sscanf to validate counts and detect extra characters; invalid inputs are handled gracefully.
  • Main loop reads commands, dispatches operations, and guards incomplete/invalid cases.

Usage

  1. Run the program and enter commands (e.g., LOAD, SELECT, CROP, ROTATE 90, APPLY BLUR, HISTOGRAM, EQUALIZE, SAVE, EXIT).
  2. For LOAD/SAVE, specify the format and path; operations like SELECT and ROTATE accept parameters as described above.
  3. After each command, input leftovers are cleared to prevent blocking on subsequent reads.

Implementation Notes

  • Angles: negative angles adjusted by +360, then modulo 360.
  • Rotation mappings:
    • 90°: new[i][j] = old[new_w - j - 1][i]
    • 180°: new[i][j] = old[new_h - i - 1][new_w - j - 1]
    • 270°: new[i][j] = old[j][new_h - i - 1]
  • Filters: convolution with kernel and divisor, clamp outputs to valid range.

Formats

  • ASCII: P2 (grayscale), P3 (color).
  • Binary: P5 (grayscale), P6 (color).

Requirements

  • Standard C toolchain to build and run the console application.

About

Image editor for PGM/PPM (P2, P3, P5, P6) that loads images, selects areas, crops, rotates (90/180/270), applies filters (EDGE, SHARPEN, BLUR, GAUSSIAN_BLUR), builds histograms, equalizes grayscale, and saves results.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors