Giter VIP home page Giter VIP logo

imagetobraille's Introduction

Image To Braille

A tool that converts images to Braille text and vice versa.

How to install

You can clone this repo, copy the contents of ImageToBraille.java or download the jar file.

How to use it

As a standalone app

Call the jar file like this: java -jar ImageToBraille.jar C:\path\to\image.png <arguments>

Argument Role
<path> If the target is a text file, then the output will be an image, otherwise the output will be the braille text.
noinvert Dots correspond to dark pixels, used for white backgrounds.
width <value> height <value> Size the image before processing. You must specify both width and height, not just one of them.
contrast <number between 1 and 254> Sets the luminance at which the pixel becomes darker or lighter.
output <path to file> Writes the result to a text file.

You can add a dash before the arguments but this will not change anything.

As a library

As a util class, you can use static access to methods.

Here are a few examples:

Turn an image into Braille text

List<String> lines = ImageToBraille.fromPath("C:/path/to/image.png", true, 128);

You can also resize the image:

List<String> lines = ImageToBraille.fromPath("C:/path/to/image2.png", 200, 250, false, 156);

Or use an image object:

BufferedImage image = ImageIO.read(new  File("C:/path/to/image3.png");
List<String> lines = ImageToBraille.fromPath(image, false, 156);

To turn Braille text to image

String brailleLines = "⠀⠀⠀⠀⠀⠀⢀⣠⣤⣶\n" +
		      "⣀⣀⣤⣴⣾⣿⣿⣿⣿\n";

BufferedImage image = ImageToBraille.fromBraille(brailleLines);

Also works if brailleLines is a list of string:

List<String> brailleLines = new ArrayList<String>();
brailleLines.add("⠀⠀⠀⠀⠀⠀⢀⣠⣤⣶");
brailleLines.add("⣀⣀⣤⣴⣾⣿⣿⣿⣿");
// More lines

BufferedImage image = ImageToBraille.fromBraille(brailleLines);

And then you can save it with this (but you can do it differently):

ImageToBraille.save(image, false, "C:/path/to/image.png");

imagetobraille's People

Contributors

skyversemc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.