Skip to content

Commit 338deb1

Browse files
authored
Merge pull request eugenp#920 from pared/introduce_openimaj
refactor packages & introduce OpenIMAJ
2 parents e3b3dff + e04a15b commit 338deb1

4 files changed

Lines changed: 45 additions & 8 deletions

File tree

‎imageprocessing/pom.xml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@
88
<artifactId>imageprocessing</artifactId>
99
<version>1.0-SNAPSHOT</version>
1010

11+
<properties>
12+
<core-image.version>1.3.5</core-image.version>
13+
<ij.version>1.51h</ij.version>
14+
</properties>
15+
1116
<dependencies>
1217
<dependency>
1318
<groupId>net.imagej</groupId>
1419
<artifactId>ij</artifactId>
15-
<version>1.51h</version>
20+
<version>${ij.version}</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.openimaj</groupId>
24+
<artifactId>core-image</artifactId>
25+
<version>${core-image.version}</version>
1626
</dependency>
1727
</dependencies>
18-
1928
</project>

imageprocessing/src/main/java/imagej/DrawRect.java renamed to imageprocessing/src/main/java/com/baeldung/imageprocessing/imagej/ImageJRectExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
package imagej;
1+
package com.baeldung.imageprocessing.imagej;
22

33
import ij.IJ;
44
import ij.ImagePlus;
55
import ij.process.ImageProcessor;
66

77
import java.awt.*;
88

9-
public class DrawRect {
9+
public class ImageJRectExample {
1010
public static void main(String[] args) {
11-
ImagePlus imp = IJ.openImage(DrawRect.class.getClassLoader().getResource("lena.jpg").getPath());
11+
ImagePlus imp = IJ.openImage(ImageJRectExample.class.getClassLoader().getResource("lena.jpg").getPath());
1212
drawRect(imp);
1313
imp.show();
1414
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.baeldung.imageprocessing.openimaj;
2+
3+
import org.openimaj.image.DisplayUtilities;
4+
import org.openimaj.image.ImageUtilities;
5+
import org.openimaj.image.MBFImage;
6+
import org.openimaj.math.geometry.point.Point2d;
7+
import org.openimaj.math.geometry.point.Point2dImpl;
8+
import org.openimaj.math.geometry.shape.Polygon;
9+
10+
import java.io.IOException;
11+
import java.util.Arrays;
12+
13+
public class OpenIMAJRectExample {
14+
public static void main(String[] args) throws IOException {
15+
MBFImage image = ImageUtilities.readMBF(OpenIMAJRectExample.class.getClassLoader().getResource("lena.jpg"));
16+
drawRectangle(image);
17+
DisplayUtilities.display(image);
18+
}
19+
20+
private static void drawRectangle(MBFImage image) {
21+
Point2d tl = new Point2dImpl(10, 10);
22+
Point2d bl = new Point2dImpl(10, image.getHeight()-10);
23+
Point2d br = new Point2dImpl(image.getWidth()-10, image.getHeight()-10);
24+
Point2d tr = new Point2dImpl(image.getWidth() - 10, 10);
25+
Polygon polygon = new Polygon(Arrays.asList(tl, bl, br, tr));
26+
image.drawPolygon(polygon, 4, new Float[] {new Float(0),new Float(0),new Float(255.0)});
27+
}
28+
}

imageprocessing/src/main/java/swing/DrawRect.java renamed to imageprocessing/src/main/java/com/baeldung/imageprocessing/swing/SwingRectExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package swing;
1+
package com.baeldung.imageprocessing.swing;
22

33
import javax.imageio.ImageIO;
44
import javax.swing.*;
@@ -7,15 +7,15 @@
77
import java.io.File;
88
import java.io.IOException;
99

10-
public class DrawRect {
10+
public class SwingRectExample {
1111
public static void main(String[] args) throws IOException {
1212
BufferedImage image = loadImage();
1313
drawRectangle(image);
1414
displayImage(image);
1515
}
1616

1717
private static BufferedImage loadImage() throws IOException {
18-
String imagePath = DrawRect.class.getClassLoader().getResource("lena.jpg").getPath();
18+
String imagePath = SwingRectExample.class.getClassLoader().getResource("lena.jpg").getPath();
1919
return ImageIO.read(new File(imagePath));
2020
}
2121

0 commit comments

Comments
 (0)