讀入圖片
Mat src1 = Highgui.imread(filepath);
Imgproc.cvtColor(src1, src1, Imgproc.COLOR_RGB2BGR);
Bitmap轉Mat
Bitmap feature_icon = GBitmap.getResBitmap(this, R.drawable.feature);
Utils.bitmapToMat(bmp, mat);
Mat轉Bitmap
Bitmap bmp= Bitmap.createBitmap(mat.width(), mat.height(),
Config.RGB_565);
Utils.matToBitmap(mat, bmp);
高斯模糊
Imgproc.GaussianBlur(mat1, mat2, new Size(5, 5), 0);
取輪廓
Imgproc.Canny(mat1, mIntermediateMat, 50, 50);
找輪廓
Imgproc.findContours(mIntermediateMat, MatOfPoint list, new Mat(),
Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
取輪廓周長
double contourarea = Imgproc.contourArea(MatOfPoint);
輪廓取矩形
Rect rect = Imgproc.boundingRect(MatOfPoint);
裁減圖片
Mat cut = src1.submat(rect);
沒有留言:
張貼留言