Code Monkey home page Code Monkey logo

imagelab-public's Introduction

Image Lab - A Cross Stitch Application.

The source code of this project is private as this is an academic project. If you need access to the code, kindly contact the author.

About

Image Lab lets you manipulate images by applying various color transformation effects, filters and color density reduction effects to images. You can now create cross-stitch pattern, pixelate your images and create mosaic art of the images.

List of features

  • A Graphical User Interface to work with images.
  • Load images from disk.
  • Blur the images.
  • Sharpen the images.
  • Apply greyscale effect to images.
  • Apply sepia effect to images.
  • Reduce color density of images by dithering.
  • Apply Mosaic effect images
  • Adjust density for mosaic by providing number of seeds the image should have.
  • Apply Pixelation effect to images.
  • Adjust density of pixelation by providing number of seeds/squares the image should have.
  • Write the converted/manipulated images to disk.
  • Create batch file to execute all the commands at once.
  • Load batch file from disk to execute all the commands in the file at once.

Cross Stitch Features

  • Generate a cross stitch version of image.
  • Cross Stitch Image will have only floss colors. (Total 489 floss colors).
  • Create Cross Stitch Image from custom palette of floss colors.
  • Replace a color in the cross stitch pattern by your own color.
  • Remove a particular color from the cross stitch image.
  • See pattern of cross stitch overlayed on the top of cross stitch image.
  • Save cross stitch image to disk
  • Save cross stitch pattern to the disk.

Getting Started

p5-CrossStitchApplication jar file is used for running this project.

Usage

There are two ways to use this application
1) Use Interactive Graphical User Interface.
2) Use a batch file to execute all the commands at once.

Interactive Method.

java -jar p5-CrossStitchApplication -interactive

This will launch a graphical user interface (GUI)
GUI will have a menu to perform various operations.

Menu :

  • File - Provides menu items to deal with file read/save related operations. (Shortcut - ALT + F)
  • Effects - Provides menu items to apply various effects on the images. (Shortcut - ALT + E)

    File Menu Items :

  • Load Image - Loads the image from the disk. (Shortcut - CTRL + I)
  • Save Image - Saves the image to the disk. (Shortcut - CTRL + S)
  • Create Batch File - Allows to enter commands for batch execution. (Shortcut - CTRL + F)
  • Execute Batch File - Loads the batch file from disk to run a batch execution (Shortcut - CTRL + E)
  • Save Cross Stitch Pattern - Saves the cross stitch pattern to the disk. (Shortcut - CTRL + P)
  • Exit - Closes the Application ((Shortcut - CTRL + Q)

    Effects Menu Items :

  • Blur Effect - Blurs the image. (Shortcut - SHIFT + B)
  • Sharpen Effect - Sharpens the image. (Shortcut - SHIFT + S)
  • Sepia Effect - Applies sepia effect. (Shortcut - SHIFT + I)
  • GreyScale Effect - Converts the image to greyscale. (Shortcut - SHIFT + G)
  • Dither Effect - Color Density Reduction dither effect is applied. (Shortcut - SHIFT + D)
  • Pixelate Effect - Pixelates the image. (Shortcut - SHIFT + P)
  • Mosaic Effect - Creates the mosaic version of image. (Shortcut - SHIFT + M)
  • Cross Stitch Pattern - Creates the cross stitch version of image. (Shortcut - SHIFT + C)

    How to use the program

    1. Load Image
      Click File -> Load Image
    2. Apply blur effect
      Click Effects -> Blur Effect
    3. Apply Sepia effect
      Click Effects -> Sepia Effect
    4. Apply GreyScale effect
      Click Effects -> GreyScale Effect
    5. Apply Dither effect
      Click Effects -> Dither Effect
      Enter the intensity of dither as desired.
      Click OK.
    6. Apply Pixelate effect
      Click Effects -> Pixelate Effect
      Enter the number of square.
      Click OK.
    7. Apply Mosaic effect
      Click Effects -> Mosaic Effect
      Enter the number of seeds.
      Click OK.
    8. Aply Cross Stitch effect
      Click Effects -> Cross Stitch Pattern
      Enter the number of square in pattern.
      Select number of colors from which pattern is to be generated. Leave blank and Continue if all colors are needed.
      Click OK.

    How to replace color

  • Once the cross stitch pattern is generated, click on any square to replace the color.
  • Click Replace Color.
  • Select the color to be replaced from the combo box.
  • Click OK.

    How to remove color

  • Once the cross stitch pattern is generated, click on any square to replace the color.
  • Click Remove Color.

    See Cross Stitch Pattern and Legend.

  • Once the cross stitch pattern is generated, click on any square to replace the color.
  • Click Show Pattern Overlay.
  • Cross Stitch Pattern will be overlayed on top of cross stitch image and legend will be show at the bottom.

    Create Batch File.

  • Click File.
  • Click Create Batch File.
  • Enter commands.
  • Click Execute.

    Batch File Method.

    java -jar p5-CrossStitchApplication batch-commands.txt
    

    where p5-CrossStitchApplication is the runnable jar file containing the driver for the project and batch-commands contains all the commands that can be use to apply effects on the images.

    List of Commands and their Usage ( Create batch file using these commands )
    1) load <filepath> 
    - filepath is the path of image to be loaded.
    
    2) blur
    - Applies blur effect on the image. It takes no parameter.
    
    3) sharpen
    - Applies sharpen effect on the image. It takes no parameter.
    
    4) greyscale
    - Applies greyscale effect on the image. It takes no parameter.
    
    5) sepia
    - Applies sepia effect on the image. It takes no parameter.
    
    6) dither <number of colors>
    - Applies dither effect on the image. 
    - Take numeric parameter indicating the number of colors the image has to be reduced in.
    
    7) mosaic <number of seeds> 
    - Applies mosaic effect on the image.
    - Take numeric parameter indicating the total number of seeds that can exist in the resultant image.
    
    8) pixelate <number of squares>
    - Applies pixelate effect on the image. 
    - Take a numeric parameter indicating the total number of squares across a image.
    
    9) pattern <number of squares>
    - Applies pixelate effect on the image based on number of squares provided in parameter.
    - Generates cross stitch pattern of pixelated image.
    - Take a numeric parameter indicating the total number of squares across a image.
    
    10) Save <filepath>
    - Saves the image. Takes string as parameter to indicate the path and name to save the image.
    
    11) quit
    - quits the program execution.
    
    12) q
    - Alternative to quit command. It also terminates the execution.
    

    Example Usage

    Run 1 :

    java -jar p5-crossStitchApplication input.txt
    

    Applies all the commands specifies in the input.txt file and generates the images and pattern.

    The above example shows usage where :

    • Image is loaded
    • Effect is applied
    • Image is saved.
    • to apply next effect we repeat the cycle.

    Run 2 :

    java -jar p5-crossStitchApplication input.txt
    

    The above example shows usage where multiple effects are applied before saving the image. It follow something like :

    • load beach.jpg
    • blur
    • greyscale
    • save beach-new.jpg

    Here the image will first be blurred and then greyscaled. The output will be greyscaled image that is blur.

    Run 3 :

    java -jar p5-crossStitchApplication -interactive 
    

    Here a interactive graphical user interface will be displayed.

    Commands example :

    load beach.jpg
    dither 8
    save beach-dither.jpg
    load beach.jpg
    blur
    save beach-blur.jpg
    load beach.jpg
    greyscale
    save beach-greyscale.jpg
    load beach.jpg
    sepia
    save beach-sepia.jpg
    load beach.jpg
    sharpen
    save beach-sharpen.jpg
    load beach.jpg
    mosaic 570
    save beach-mosaic.jpg
    load beach.jpg
    pixelate 30
    save beach-pixelate.jpg
    load beach.jpg
    pattern 30
    save beach-pattern.txt
    quit            
    

    Support command line syntax

  • -interactive
  • -script [batch_file_path]

    Change Log

    • Added View to interact with controller and model.
    • Added Graphical User Interface using swing.
    • GUI will display the results.
    • Cross stitch image will be displayed having floss colors only.
    • A single color can be removed from the cross stitch pattern.
    • A single color can be replaced with another color.
    • User can select custom palette of cross stitch floss colors to generated colors from.
    • Pattern can be overlayed on top of cross stitch image.

    Design/Model Changes

    • Added JList to allow user to create custom palette to be used for cross stitch image.
    • Added JComboBox to allow user to select a single color which can be replaced from cross stitch pattern.
    • Added various method in IView interface to help all the operation supported by application.
    • Added RemoveColor and ReplaceColor commands in controller for reusability.
    • Added DmcImage class which represents cross stitch image and pattern. This makes it easy to perform operations like removeColor and replaceColor as DmcImage acts as AbstractDataType.
    • Controller will have constructor to support batch and view execution modes.

    Assumptions

    • Each channel can have maximum of 8 bits i.e maximum of 256 colors in each channel.
    • The number of colors that the image has to be reduced to for dithering is for each channel. For example - if the image has to be reduced to 2 colors ... it will be 2 colors each for R,G,B.
    • Pixelation can generate perfect squares ( ex. 10x10 ) or squares whose width x height differs by only 1 (10x11, 11x10,etc) provided that the number of offset pixels are less than number super-pixels.
    • Parameter for pixelation indicates the total number of super pixels across the width.
    • Applying effect changes the image. If any new effect is applied, it will be applied on the changed effect. If new effect is to be applied on original effect, then original image has to be loaded again. For example. If blur is applied on image and then greyscale is applied, the resultant image will be a image that is greyscale in color and blurred.
    • Each command will be on a new line in batch file.
    • Setting console encoding to UTF-8 in run configurations.

    Limitations

    • The intensity of blur,sharpen, greyscale, sepia cannot be adjusted.
    • Application supports UTF-8 character encoding. If the operating system does not have default encoding as UTF-8 , then use JAVA_TOOL_OPTION=-Dfile.encoding=UTF8 as envrionment variable.

    Resources Reference / Citation

    Author

    • Meet Patel
  • imagelab-public's People

    Contributors

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