C:\ece595_06\class16>java Convolve2 test3.png 0 23 46 69 93 116 139 162 186 209 232 0 23 46 69 93 116 139 162 186 209 232 0 23 49 155 225 229 191 165 186 209 232 0 23 145 232 232 232 232 201 186 209 232 0 23 223 232 232 232 232 230 186 209 232 0 23 223 232 232 232 232 230 186 209 232 0 23 145 232 232 232 232 201 186 209 232 0 23 49 155 225 229 191 165 186 209 232 0 23 46 69 93 116 139 162 186 209 232 0 23 46 69 93 116 139 162 186 209 232 0 23 46 69 93 116 139 162 186 209 232 convolution mask 1 2 1 2 4 2 1 2 1 filtered image 5 23 46 69 92 116 139 162 185 209 226 5 23 51 88 121 141 152 165 185 209 226 5 29 80 142 185 196 187 180 188 209 226 5 46 129 199 226 228 218 201 195 209 226 5 62 165 224 232 232 229 215 200 209 226 5 62 165 224 232 232 229 215 200 209 226 5 46 129 199 226 228 218 201 195 209 226 5 29 80 142 185 196 187 180 188 209 226 5 23 51 88 121 141 152 165 185 209 226 5 23 46 69 92 116 139 162 185 209 226 5 23 46 69 92 116 139 162 185 209 226
Convolve2.javaimport java.awt.image.*;
import java.awt.color.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.JFrame;
public class Convolve2 {
public static void main(String [] args) {
String filename = "test3.png";
if (args.length>0) filename = args[0];
showImage f1 = new showImage(filename);
f1.setLocation(10,10);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
int w = f1.getWidth();
int h = f1.getHeight();
listImage.listGray(f1.img,filename);
//int mask[][] = { {-1, 0, 1},{-2, 0, 2},{-1, 0, 1} };
int mask[][] = { {1, 2, 1}, {2, 4, 2}, {1, 2, 1} };;
Convolve c = new Convolve(mask);
c.setScale(16);
c.showMatrix(mask,"convolution mask");
BufferedImage outp = c.doConvolve(f1.img);
showImage f2 = new showImage(outp,"gray version");
f2.setLocation(20+w,10);
f2.writeImage("out2","png");
listImage.listGray(f2.img,"filtered image");
}
}
Maintained by John Loomis, updated Tue Oct 15 08:45:03 2013