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.
| 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 |
| 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 |
- Java 21+ (uses
Math.clamp) - A Java IDE or the JDK installed
-
Clone the repository:
git clone https://github.com/henriquek-btdg/image-processing-java.git cd image-processing-java -
Add a
.jpgimage of your choice to the project root and update the filename inmain():int[][] imageData = imgToTwoD("./your-image.jpg");
You can also load an image directly from a URL:
int[][] imageData = imgToTwoD("https://example.com/image.jpg");
-
Compile and run:
javac ImageProcessing.java java ImageProcessing
Output images will be saved to the project root directory.
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");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
- Java SE — core language
javax.imageio— image I/Ojava.awt.Color— pixel color utilities
This project was developed for educational purposes as part of a Codecademy Java course.