Repository with filters for image.
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
- Mirror image
- Gray filter
- Sepia filter
- Inverse filter
- Split image to RGB channels
- Color accent filter
- Histogram
- Median filter
- Noise filter
- Sort zig zag
Function mirror
get 3 parameters:
def mirror(img: BuffereImage, ox: Boolean, oy: Boolean): BuffereImage
img
- Image objectox
- iftrue
when image mirrored horizontallyoy
- iftrue
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 |
---|---|---|---|
Function gray get 2 parameters:
def gray(img: BufferedImage, typ: String): BufferedImage
img
- Image objecttyp
- type of filter gray (avarage, lightness, luminosity)
And you will have one file gray.jpg
.
Original | Avarage | Lightness | luminosity |
---|---|---|---|
Sepia filter work on gray scale images.
Function sepia get 2 parameters:
def sepia(img: BufferedImage, sp: Int): BufferedImage
img
- Image objectsp
- factor of sepia effect (20-40)
And you will have one file sepia.jpg
.
Original | Factor 20 | Factor 40 |
---|---|---|
Function inverse get 1 parameter:
def inverse(img: BufferedImage): BufferedImage
img
- Image object
And you will have one file inverse.jpg
.
Original | Inverse |
---|---|
Function rgb get 3 parameters:
def rgb_channels(img: BufferedImage, r: Boolean, g: Boolean, b: Boolean): BufferedImage
img
- Image objectr
- Show only red channelg
- Show only green channelb
- Show only blue channel
And you will have 3 files red.jpg
, green.jpg
and blue.jpg
.
Original | Only red | Only green | Only blue |
---|---|---|---|
Function color_accent get 3 parameters:
def color_accent(img: BufferedImage, hue: Int, range: Int): BufferedImage
img
- Image objecthue
- Color in HSVrange
- Range around colorhue
Original | Hue = 0, Range = 50 | Hue = 70, Range = 50 | Hue = 200, Range = 50 |
---|---|---|---|
Function histogram get 1 parameter:
def histogram(img: BufferedImage, grid: Boolean): BufferedImage
img
- Image objectgrid
- If true image will be have grid
Original | Histogram |
---|---|
Function median get 1 parameter:
def median(img: BufferedImage): BufferedImage
img
- Image object
Original | Median filter |
---|---|
Function noise get 1 parameter:
def noise(img: BufferedImage): BufferedImage
img
- Image object
Original | Noise filter |
---|---|
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 objectgray
- if true then function transfor image to gray
Original | color | gray |
---|---|---|
To run test:
$ sbt clean test
To get coverage report:
$ sbt clean coverage test && sbt coverageReport