Skip to content

Calculating pixel Energy and Intensity for an entire image in Kotlin, using Java's standard image libraries

Notifications You must be signed in to change notification settings

g3th/Pixel_Energy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Calculating pixel Energy and Intensity for an entire image in Kotlin, using Java's standard image libraries

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages