https://github.com/g3th/pixel_energy
Calculating pixel Energy and Intensity for an entire image in Kotlin, using Java's standard image libraries
https://github.com/g3th/pixel_energy
command-line command-line-arguments image-processing imageio java-awt kotlin pixel-energy pixel-intensity seam-carving
Last synced: about 1 year ago
JSON representation
Calculating pixel Energy and Intensity for an entire image in Kotlin, using Java's standard image libraries
- Host: GitHub
- URL: https://github.com/g3th/pixel_energy
- Owner: g3th
- Created: 2023-10-12T02:23:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-13T02:20:13.000Z (over 2 years ago)
- Last Synced: 2025-01-15T10:27:10.704Z (about 1 year ago)
- Topics: command-line, command-line-arguments, image-processing, imageio, java-awt, kotlin, pixel-energy, pixel-intensity, seam-carving
- Language: Kotlin
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# Calculating Pixel Intensity
## Pixel Energy and Intensity Calculation
### Input original image and output the image after function calculation
In order to calculate the energy and intensity values of each pixel in an image, each pixel's RGB value must be calculated separately with an algorithm/function originally developed by Shai Avidan and Ariel Shamir.
By energy, one means determining the importance of pixels with a mathematical function, values which will be used when resizing an image with the Seam Carving algorithm.
The dual-gradient energy function is:

The square of x is calculated by:

and y is:

Borders are calculated with:

For instance, if x = 0 and y = 0, "left" would be x, "right" would be x + 2, "up" would be y and "down" would be y + 2. Everything should be calculated with Double precision, until the final calculation for pixel intensity:
``` I = (255.0 * energy / maxEnergy).toInt()```
where "maxEnergy" is the largest Energy value in the entire image.
The project uses javax.ImageIO and java.awt libraries, using methods such as "Color" in order to return an RGB value which can then easily be converted to individual Red - Green and Blue values. This simplifies matters greatly, but the project is still fairly complicated.
Compile with:
```kotlinc main.kt conditionals.kt -include-runtime -d test.jar```
Run with command line arguments, i.e.:
```java -jar test.jar -in ~/Desktop/test.png -out test-energy.png```