forked from eugenp/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenIMAJRectExample.java
More file actions
28 lines (24 loc) · 1.11 KB
/
OpenIMAJRectExample.java
File metadata and controls
28 lines (24 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.baeldung.imageprocessing.openimaj;
import org.openimaj.image.DisplayUtilities;
import org.openimaj.image.ImageUtilities;
import org.openimaj.image.MBFImage;
import org.openimaj.math.geometry.point.Point2d;
import org.openimaj.math.geometry.point.Point2dImpl;
import org.openimaj.math.geometry.shape.Polygon;
import java.io.IOException;
import java.util.Arrays;
public class OpenIMAJRectExample {
public static void main(String[] args) throws IOException {
MBFImage image = ImageUtilities.readMBF(OpenIMAJRectExample.class.getClassLoader().getResource("lena.jpg"));
drawRectangle(image);
DisplayUtilities.display(image);
}
private static void drawRectangle(MBFImage image) {
Point2d tl = new Point2dImpl(10, 10);
Point2d bl = new Point2dImpl(10, image.getHeight() - 10);
Point2d br = new Point2dImpl(image.getWidth() - 10, image.getHeight() - 10);
Point2d tr = new Point2dImpl(image.getWidth() - 10, 10);
Polygon polygon = new Polygon(Arrays.asList(tl, bl, br, tr));
image.drawPolygon(polygon, 4, new Float[] { 0f, 0f, 255.0f });
}
}