Skip to content

janczer/filters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages