- 2023-08-18OpenCV3.2图像分割 实例7:基于分水岭图像分割
1#include<opencv2/opencv.hpp>2#include<iostream>34usingnamespacecv;5usingnamespacestd;67MatwatershedCluster(Mat&image,int&numSegments);8//参数分别为分割后图像,分割块数,输入原图9voidcreateDisplaySegments(Mat&se
- 2023-08-18OpenCV3.2图像分割 实例8:Grabcut原理与演示应用
1#include<opencv2/opencv.hpp>2#include<iostream>3#include<math.h>45usingnamespacecv;6usingnamespacestd;78intnumRun=0;9Rectrect;10boolinit=false;11Matsrc,image;12Matmask,bgMo
- 2023-08-18OpenCV3.2图像分割 实例9:K-Means-证件照背景替换
1#include<opencv2/opencv.hpp>2#include<iostream>34usingnamespacecv;5usingnamespacestd;67Matmat_to_samples(Mat&image);8intmain(intargc,char**argv){9Matsrc=imread("tx.png");
- 2023-08-18OpenCV3.2图像分割 实例10:绿幕视频背景替换
1#include<opencv2/opencv.hpp>2#include<iostream>34usingnamespacecv;5usingnamespacestd;67Matreplace_and_blend(Mat&frame,Mat&mask);8Matbackground_01;//背景19Matbackground_02;//背景210intma
- 2023-08-18OpenCV3.2图像分割 实例2:KMeans对随机生成数据进行分类
1#include<opencv2/opencv.hpp>2#include<iostream>34usingnamespacecv;5usingnamespacestd;67intmain(intargc,char**argv){8Matimg(500,600,CV_8UC3);//定义一张图9RNGrng(12345);//定义随机数10//不同类定义为不同
- 2023-08-18OpenCV3.2图像分割 实例4:GMM(高斯混合模型)样本数据训练与预言
1#include<opencv2/opencv.hpp>2#include<iostream>34usingnamespacecv;5usingnamespacecv::ml;6usingnamespacestd;78intmain(intargc,char**argv){9Matimg=Mat::zeros(500,500,CV_8UC3);10RNGrng(123