得到图片的轮廓
import java.awt.image.BufferedImage; import java.awt.image.ConvolveOp; import java.awt.image.Kernel; public class ImageProfile { //获取图片的边界轮廓 public BufferedImage getPicEdge(BufferedImage originalPic) { int imageWidth = originalPic.getWidth(); int imageHeight = originalPic.getHeight(); BufferedImage newPic = new BufferedImage(imageWidth, imageHeight,BufferedImage.TYPE_INT_RGB); float[] elements = { 0.0f, -1.0f, 0.0f, -1.0f, 4.0f, -1.0f, 0.0f,-1.0f, 0.0f }; Kernel kernel = new Kernel(3, 3, elements); ConvolveOp cop = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); cop.filter(originalPic, newPic); return newPic; } }