Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🖼️ Image Processing in Java

A collection of image manipulation and procedural painting utilities built in Java, developed as part of a Codecademy Java course project.

Images are represented as 2D arrays of packed ARGB integers, enabling direct pixel-level manipulation without external graphics libraries.


Features

Image Filters

Method Description
negativeColor Inverts all RGB channels to produce a color negative
trimBorders Removes a border of N pixels from all four edges
stretchHorizontally Doubles image width by duplicating each pixel
shrinkVertically Halves image height by sampling every other row
invertImage Flips the image 180° (both axes)
colorFilter Applies an additive RGB shift with automatic clamping

Painting & Procedural Art

Method Description
paintRandomImage Fills a canvas with random opaque colors
paintRectangle Draws a filled rectangle at a given position and color
generateRectangles Generates N random rectangles for procedural artwork

Getting Started

Prerequisites

  • Java 21+ (uses Math.clamp)
  • A Java IDE or the JDK installed

Running the Project

  1. Clone the repository:

    git clone https://github.com/henriquek-btdg/image-processing-java.git
    cd image-processing-java
  2. Add a .jpg image of your choice to the project root and update the filename in main():

    int[][] imageData = imgToTwoD("./your-image.jpg");

    You can also load an image directly from a URL:

    int[][] imageData = imgToTwoD("https://example.com/image.jpg");
  3. Compile and run:

    javac ImageProcessing.java
    java ImageProcessing

Output images will be saved to the project root directory.


Usage

You can load images from a local file or a public URL:

// Local file
int[][] imageData = imgToTwoD("./apple.jpg");

// Remote URL
int[][] imageData = imgToTwoD("https://example.com/image.png");

Filters can be applied individually or chained together:

// Single filter
int[][] result = negativeColor(imageData);

// Chained filters
int[][] result = stretchHorizontally(
    colorFilter(
        negativeColor(trimBorders(imageData, 50)),
        200, 20, 40
    )
);

twoDToImage(result, "./output.jpg");

Project Structure

image-processing-java/
├── ImageProcessing.java   # Main class with all methods
├── apple.jpg              # Sample input image
├── flower.jpg             # Sample input image
├── kitten.jpg             # Sample input image
└── README.md

Built With

  • Java SE — core language
  • javax.imageio — image I/O
  • java.awt.Color — pixel color utilities

License

This project was developed for educational purposes as part of a Codecademy Java course.

About

A collection of image manipulation and procedural painting utilities in Java. Made as part of my Java studies.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages