Code Monkey home page Code Monkey logo

filters's Introduction

Build Status

Image

Repository with filters for image.

Simple usage

First you should clone and compile the project.

$ git clone https://github.com/janczer/filters
$ cd filters
$ sbt compile
$ sbt package

After that you will have file filters_2.12-X.X.jar in target/scala-2.12/.

Simple script for test this library:

import janczer.filters.Filters
import java.io.File
import javax.imageio.ImageIO

def test() {
  val photoIn = ImageIO.read(new File("test.jpg"))

  ImageIO.write(Filters.mirror(photoIn, true, true), "jpg", new File("mirror.jpg"))
}

test()

This is the way how you can run it:

$ scala -classpath "filters_2.12-0.2.jar" test.scala

Table of contents

  1. Mirror image
  2. Gray filter
  3. Sepia filter
  4. Inverse filter
  5. Split image to RGB channels
  6. Color accent filter
  7. Histogram
  8. Median filter
  9. Noise filter
  10. Sort zig zag

Mirror image

Function mirror get 3 parameters:

def mirror(img: BuffereImage, ox: Boolean, oy: Boolean): BuffereImage
  • img - Image object
  • ox - if true when image mirrored horizontally
  • oy - if true when image mirrored vertically

And you will have one file mirror.jpg.

Original ox=true, oy = false ox = false, oy = true ox = true, oy = true
eagle eagle eagle eagle

Gray filter

Function gray get 2 parameters:

def gray(img: BufferedImage, typ: String): BufferedImage
  • img - Image object
  • typ - type of filter gray (avarage, lightness, luminosity)

And you will have one file gray.jpg.

Original Avarage Lightness luminosity
eagle eagle eagle eagle

Sepia filter

Sepia filter work on gray scale images.

Function sepia get 2 parameters:

def sepia(img: BufferedImage, sp: Int): BufferedImage
  • img - Image object
  • sp - factor of sepia effect (20-40)

And you will have one file sepia.jpg.

Original Factor 20 Factor 40
eagle eagle eagle

Inverse filter

Function inverse get 1 parameter:

def inverse(img: BufferedImage): BufferedImage
  • img - Image object

And you will have one file inverse.jpg.

Original Inverse
eagle eagle

Split image to RGB channels

Function rgb get 3 parameters:

def rgb_channels(img: BufferedImage, r: Boolean, g: Boolean, b: Boolean): BufferedImage
  • img - Image object
  • r - Show only red channel
  • g - Show only green channel
  • b - Show only blue channel

And you will have 3 files red.jpg, green.jpg and blue.jpg.

Original Only red Only green Only blue
eagle eagle eagle eagle

Color accent filter

Function color_accent get 3 parameters:

def color_accent(img: BufferedImage, hue: Int, range: Int): BufferedImage
  • img - Image object
  • hue - Color in HSV
  • range - Range around color hue
Original Hue = 0, Range = 50 Hue = 70, Range = 50 Hue = 200, Range = 50
poppies eagle eagle eagle

Histogram

Function histogram get 1 parameter:

def histogram(img: BufferedImage, grid: Boolean): BufferedImage
  • img - Image object
  • grid - If true image will be have grid
Original Histogram
eagle eagle
poppies poppies
poppies gray poppies

Median filter

Function median get 1 parameter:

def median(img: BufferedImage): BufferedImage
  • img - Image object
Original Median filter
poppies gray poppies

Noise filter

Function noise get 1 parameter:

def noise(img: BufferedImage): BufferedImage
  • img - Image object
Original Noise filter
poppies gray poppies

Sort zig zag

More about this filter you can read on my blog.

Function sort_zig_zag get 2 parameters:

def sort_zig_zag(img: BufferedImage, gray: Boolean): BufferedImage
  • img - Image object
  • gray - if true then function transfor image to gray
Original color gray
poppies gray poppies poppies

Test

To run test:

$ sbt clean test

To get coverage report:

$ sbt clean coverage test && sbt coverageReport

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.