首页 > 代码库 > 17.腐蚀

17.腐蚀

//腐蚀
int g_nErodeValue;
int g_nErodeType;
Mat g_mElement;
//这2个消息处理函数可以合并为1个
void on_ChangeErodeValue(int,void*)
{
	if(g_nErodeValue>0)
	{
		g_mElement=getStructuringElement(g_nErodeType,Size(g_nErodeValue,g_nErodeValue));
		erode(g_srcImage_Contrast,g_dstImage_Contrast,g_mElement);
		imshow("腐蚀滤波",g_dstImage_Contrast);
	}
}
void on_ChangeErodeType(int,void*)
{

	g_mElement=getStructuringElement(g_nErodeType,Size(g_nErodeValue,g_nErodeValue));
	erode(g_srcImage_Contrast,g_dstImage_Contrast,g_mElement);
	imshow("腐蚀滤波",g_dstImage_Contrast);

}
void Test_ErodeBlur()
{
	namedWindow("腐蚀滤波");
	namedWindow("原图");
	g_srcImage_Contrast=imread("D:\\OpenCV Projects\\OpenCV_Test_Image\\16.jpg");
	g_nErodeValue=http://www.mamicode.com/1;"erode_value","腐蚀滤波",&g_nErodeValue,30,on_ChangeErodeValue);
	createTrackbar("erode_type","腐蚀滤波",&g_nErodeType,2,on_ChangeErodeType);
	on_ChangeErodeValue(g_nErodeValue,0);
	on_ChangeErodeType(g_nErodeValue,0);
	imshow("原图",g_srcImage_Contrast);
}

技术分享

 

17.腐蚀