|
structuring element 0 1 0 1 1 1 0 1 0 |
|
See bwOps.java which does the work.
Mathematical Morphology, Wikipedia article
Binary Image Morphology in my ECE563 class notes
Morphological Image Processing
– The University of Auckland
Dilate1.java
import java.awt.image.*;
import java.io.*;
import javax.swing.*;
public class Dilate1 {
public static void main(String[] args) {
int mag = 3;
// load the image
String file1 = "char.png";
String filename = (args.length>0)? args[0]: file1;
//BufferedImage img = showImage.readImage(filename);
ImageFrame f1 = new ImageFrame(filename);
f1.setLocation(100,100);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//int mask[][] = {{0,1,1,1,0},{1,1,1,1,1},{1,1,1,1,1},{1,1,1,1,1},{0,1,1,1,0}};
int mask[][] = {{0,1,0},{1,1,1},{0,1,0}};
bwOps c = new bwOps(mask);
c.showMatrix(mask,"structuring element");
BufferedImage outp = c.doDilate(f1.img);
String cmt = "dilated";
ImageFrame f2 = new ImageFrame(outp,cmt);
f2.setLocation(140+f1.getWidth(),100);
f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f2.writeImage("dilate1","png");
}
}
Maintained by John Loomis, updated Sat Mar 16 18:08:01 2019