Skip to content

luiz/onedeefy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is this

Suppose you want to treat an image as a single line. You can do that in many ways. Those ways are called pixel orderings. This library provides implementations for a few of them.

How to use

Download the jar available in the “Downloads” link above. Then, in the command line, run:

java -jar onedeefy-1.0.jar

to get more help. For instance, suppose you have a file called “background.jpg” and you want to convert it to 1D using a spiral ordering (see javadoc for class Spiral). Then you could run:

java -jar onedeefy-1.0.jar spiral background.jpg background-1D.jpg

This will result in a file called “background-1D.jpg” being created, and this file will be an image with a single line, formed by all the pixels of the original image.

To get the original image back, you need also to say its original size. Suppose it was 1024×768. Then you could run:

java -jar onedeefy-1.0.jar spiral background-1D.jpg 1024 768 background-2D.jpg

Oh, and you can also use it directly in your Java code. Simply add it to your classpath and call the linearize method on the class that implements the pixel ordering that you want to use.

Supported image formats

The supported image formats depend on your installed Java, but usually include the most common ones: JPG, PNG and BMP.

Collaborate

It’s easy to add your own way of ordering the pixels in an image. There are only two simple steps:

  1. Implement the interface Linearize:
package foo.bar.baz;
public final class MyOrdering implements Linearize {
    public BufferedImage linearize(BufferedImage image) {
        // your ordering algorithm here
    }
    public BufferedImage delinearize(BufferedImage image, int width, int height) {
        // the algorithm to reconstruct the original image here
    }
    public String getName() {
        return "a-nice-name-for-the-final-user";
    }
}
  1. Add the full name of your class to the file META-INF/services/br.ime.usp.lreal.onedeefy.Linearize (create it in your project if it doesn’t exist):
foo.bar.baz.MyOrdering

And done! It will become available as an algorithm in the command line interface.

About

A 1D/2D image converter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages