Skip to content

Commit 1c517c0

Browse files
author
Ferhat Aydogan
authored
Create README.md
1 parent 619f22e commit 1c517c0

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# JavaSimpleImageProcessing
2+
Image processing filters for java. All filters assumes the input image is grayscale. All filters has a nested "Configuration" class. To use a filter Configuration class of a filter must be created and given to the filter via its constructor or its setConfiguration method.
3+
4+
Filters are designed to be connected to each other to create a filter sequence.
5+
6+
All filters uses a floating point number for each color channel of a pixel.
7+
8+
# Using code
9+
Copy "com" folder under src into your src folder
10+
11+
# Sample Usage
12+
Lets create a box blur and take difference between blurred image and original image. Finaly increase the contrast to make differences visible with human eye.
13+
```
14+
______
15+
| |
16+
| In |
17+
|______|
18+
/ \
19+
____/_ \
20+
| | |
21+
| blur | |
22+
|______| |
23+
\ /
24+
_\___/_
25+
| |
26+
| dif |
27+
|_______|
28+
|
29+
____|_____
30+
| Fix |
31+
| Contrast |
32+
|__________|
33+
|
34+
__|___
35+
| |
36+
| Out |
37+
|______|
38+
```
39+
```java
40+
// create necessary filters to use
41+
int width = <image width>, height = <image height>;
42+
43+
BlockIn filterIn = new BlockIn(); // feed input from here
44+
BlockOut filterOut = new BlockOut(); // listen output from here
45+
46+
BoxBlurFilter.Configuration confBlur = new BoxBlurFilter.Configuration(3, 2);
47+
BoxBlurFilter filterBlur = new BoxBlurFilter(width, height).setConfiguration(confBlur);
48+
49+
DifferenceFilter.Configuration confDiff = new DifferenceFilter.Configuration(DifferenceFilter.Mode.ABSOLUTE_VALUE);
50+
DifferenceFilter differenceFilter = new DifferenceFilter(
51+
confDiff, width, height);
52+
53+
DivideFilter contrastFilter = new DivideFilter(width, height);
54+
contrastFilter.setConfiguration(DivideFilter.Configuration.newContrast());
55+
56+
// now connect the filters to each other
57+
58+
filterIn.connectOutput(0, differenceFilter, DifferenceFilter.INPUT_LEFTHAND);
59+
filterIn.connectOutput(filterBlur);
60+
filterBlur.connectOutput(0, differenceFilter, DifferenceFilter.INPUT_RIGHTHAND);
61+
differenceFilter.connectOutput(contrastFilter);
62+
contrastFilter.connectOutput(filterOut);
63+
64+
65+
// since we created our sequence, we can use this sequence any number of times
66+
ImageData anInput = new ImageData(new File("<input path>"));
67+
// handle result image
68+
filterOut.setListener(new BlockOut.Listener<ImageData>() {
69+
@Override
70+
public void resultIsReady(ImageData result) {
71+
ImageIO.write(result.toBufferedImage(), "PNG", new File("<outputPath>" + ".png"));
72+
}
73+
});
74+
// feed input image
75+
blockIn.setInput(anInput);
76+
```

0 commit comments

Comments
 (0)