图片的轮廓

得到图片的轮廓

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;
	}

}


 

 

posted on 2012-10-22 10:28  小-强-斋-太  阅读(119)  评论(0编辑  收藏  举报

导航