Giter Site home page Giter Site logo

mosaicbuilder's Introduction

MosaicBuilder

Mosaic made of square image tiles. Each pixel of the input image is replaced by a tile.

Add the .jar file in your project.

MosaicBuilder.jar (Library JAR file.).

Library under development!

Comming soon:

  • Full multi-thread processing.
  • DeltaE color difference algorithm.
  • Better tile placement algorithm, to avoid sequencial repetition.
  • Graphic interface implementation (for non-programmer users).

Packs

MegaPack.zip (over 12.000 50x50 tiles).

DayZPack.zip (over 1.200 50x50 dayz-themed tiles).

TW3Pack.zip (over 1.200 50x50 the-witcher-3-themed tiles).

Samples

Using MegaPack

Guerrero, Flamengo's striker.

DayZ's most famous image.

Computer Science Institute - UFF

Using TW3Pack

Geralt de Rivia

Usage

Constructor

MosaicBuilder mosaicBuilder = new MosaicBuilder(tilePath, inputImagePath, tileDimension);

tilePath folder containing tiles.

inputImagePath path of the inputImage.

tileDimen Dimension of the tile. (e.g 50x50, 60x60, 40x40, ...).

Listener(Callback interface)

public interface MosaicBuilderListener{
      public void onMosaicFinished(BufferedImage img);
      public void onProgressChanged(int status);
}
public void onMosaicFinished(BufferedImage img);

is called when final image is done.

public void onProgressChanged(int status);

is called when the progress changes (e.g, init -> loading inputImage to memory).

Progress Status static constants

public static final int READING_INPUT_IMAGE_INTO_MEMORY;
public static final int READING_TILES_INTO_MEMORY;
public static final int SELECTING_TILES;
public static final int BUILDING_OUTPUT_IMAGE;

Exceptions

public class InvalidInputImagePath
public class InvalidOutputImagePath
public class InvalidTileFolderPath

Example

String tilePath = "D:\\SomeFolder\\my_pack_50x50";
String inputImagePath = "D:\\SomeFolder\\inputImage.jpg";
final String finalPath = "D:\\SomeFolder\\outPutImage.png";
int tileDimension = 50;

MosaicBuilder mosaicBuilder = new MosaicBuilder(tilePath, inputImagePath, tileDimension);

mosaicBuilder.setListener(new MosaicBuilder.MosaicBuilderListener() {
   @Override
   public void onMosaicFinished(BufferedImage img) {
       try {
           ImageIO.write(img, "png", new File(finalPath));
       } catch (IOException ex) {
           //TODO
           //Warn user, etc...
       }
   }

   @Override
   public void onProgressChanged(int status) {
       switch (status){
            case MosaicBuilder.BUILDING_OUTPUT_IMAGE:
                System.out.println("Building final image...");
                break;
             case MosaicBuilder.READING_INPUT_IMAGE_INTO_MEMORY:
                System.out.println("Reading input image into memory...");
                break;
             case MosaicBuilder.READING_TILES_INTO_MEMORY:
                System.out.println("Reading tiles into memory...");
                break;
             case MosaicBuilder.SELECTING_TILES:
                System.out.println("Selecting best tiles for each input image's pixel...");
                break;
       }
   }
});

        try{
            mosaicBuilder.build();
        }catch(InvalidInputImagePath e){
            //Show to user that somenthing gone wrong.
            System.out.println("Invalid input path: " + inputImagePath);
        }catch(InvalidTileFolderPath e){
            //Show to user that somenthing gone wrong.
            System.out.println("Invalid tile folder path: " + tilePath);
        }

Developed by

Max Fratane

mosaicbuilder's People

Contributors

mfrat 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.