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
Erode1.java
import java.awt.image.*; import java.io.*; import javax.swing.*; public class Erode1 { public static void main(String[] args) { // load the image String file1 = "char.png"; String filename = (args.length>0)? args[0]: file1; 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.doErode(f1.img); String cmt = "eroded"; ImageFrame f2 = new ImageFrame(outp,cmt); f2.setLocation(140+f1.getWidth(),100); f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f2.writeImage("erode1","png"); } }
Maintained by John Loomis, updated Sat Mar 16 18:00:49 2019