refactor packages & introduce OpenIMAJ
This commit is contained in:
parent
1a17166d36
commit
ac20dd32d0
|
@ -14,6 +14,11 @@
|
|||
<artifactId>ij</artifactId>
|
||||
<version>1.51h</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openimaj</groupId>
|
||||
<artifactId>core-image</artifactId>
|
||||
<version>1.3.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,4 +1,4 @@
|
|||
package imagej;
|
||||
package com.baeldung.imageprocessing.imagej;
|
||||
|
||||
import ij.IJ;
|
||||
import ij.ImagePlus;
|
||||
|
@ -6,9 +6,9 @@ import ij.process.ImageProcessor;
|
|||
|
||||
import java.awt.*;
|
||||
|
||||
public class DrawRect {
|
||||
public class ImageJRectExample {
|
||||
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);
|
||||
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.swing.*;
|
||||
|
@ -7,7 +7,7 @@ import java.awt.image.BufferedImage;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class DrawRect {
|
||||
public class SwingRectExample {
|
||||
public static void main(String[] args) throws IOException {
|
||||
BufferedImage image = loadImage();
|
||||
drawRectangle(image);
|
||||
|
@ -15,7 +15,7 @@ public class DrawRect {
|
|||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue