Merge pull request #920 from pared/introduce_openimaj
refactor packages & introduce OpenIMAJ
This commit is contained in:
commit
338deb18e4
|
@ -8,12 +8,21 @@
|
||||||
<artifactId>imageprocessing</artifactId>
|
<artifactId>imageprocessing</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<core-image.version>1.3.5</core-image.version>
|
||||||
|
<ij.version>1.51h</ij.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.imagej</groupId>
|
<groupId>net.imagej</groupId>
|
||||||
<artifactId>ij</artifactId>
|
<artifactId>ij</artifactId>
|
||||||
<version>1.51h</version>
|
<version>${ij.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openimaj</groupId>
|
||||||
|
<artifactId>core-image</artifactId>
|
||||||
|
<version>${core-image.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -1,4 +1,4 @@
|
||||||
package imagej;
|
package com.baeldung.imageprocessing.imagej;
|
||||||
|
|
||||||
import ij.IJ;
|
import ij.IJ;
|
||||||
import ij.ImagePlus;
|
import ij.ImagePlus;
|
||||||
|
@ -6,9 +6,9 @@ import ij.process.ImageProcessor;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class DrawRect {
|
public class ImageJRectExample {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ImagePlus imp = IJ.openImage(DrawRect.class.getClassLoader().getResource("lena.jpg").getPath());
|
ImagePlus imp = IJ.openImage(ImageJRectExample.class.getClassLoader().getResource("lena.jpg").getPath());
|
||||||
drawRect(imp);
|
drawRect(imp);
|
||||||
imp.show();
|
imp.show();
|
||||||
}
|
}
|
|
@ -0,0 +1,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[] {new Float(0),new Float(0),new Float(255.0)});
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package swing;
|
package com.baeldung.imageprocessing.swing;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -7,7 +7,7 @@ import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class DrawRect {
|
public class SwingRectExample {
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
BufferedImage image = loadImage();
|
BufferedImage image = loadImage();
|
||||||
drawRectangle(image);
|
drawRectangle(image);
|
||||||
|
@ -15,7 +15,7 @@ public class DrawRect {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BufferedImage loadImage() throws IOException {
|
private static BufferedImage loadImage() throws IOException {
|
||||||
String imagePath = DrawRect.class.getClassLoader().getResource("lena.jpg").getPath();
|
String imagePath = SwingRectExample.class.getClassLoader().getResource("lena.jpg").getPath();
|
||||||
return ImageIO.read(new File(imagePath));
|
return ImageIO.read(new File(imagePath));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue