opencv 图像雾检测_opencv的图像去雾

这篇博客介绍了一个使用OpenCV进行图像雾检测和去除的C++实现过程。首先,从文件读取图像并转换为灰度图,然后通过中值滤波处理图像,接着计算暗通道和最大值,最后利用Luv颜色空间进行图像去雾操作,显示去雾后的图像。
摘要由CSDN通过智能技术生成

1 #include

2 #include

3 #include

4 #include

5 #include

6 #include

7 #include

8 #include

9

10 using namespacecv;11 using namespacestd;12 Mat Iimage;13 Mat Oimage;14 int MAX_KERNEL_LENGTH = 31;15 double p=0.2;16 intc1;17 intc2;18 intc3;19 intcloud()20 {21 inta;22 Iimage = imread("D:\\img\\train.bmp", CV_LOAD_IMAGE_COLOR); //Read the file

23

24

25 ///*测试代码开始*/

26 //for(int i=0;i<1;i++)27 //{28 //for(int j=0;j<200;j++)29 //{30 //cout<(i,j)[0]<

33 ///*测试代码结束*/

34 Mat M;35 cvtColor(Iimage,M,CV_BGR2GRAY);//得到灰度图

36 /*测试代码*/

37 imshow( "灰度", M );38

39 /*测试代码*/

40 //cvtColor( image, gray_image, CV_BGR2GRAY );//将RGB图像转化为灰度格式

41 for(int i=0;i(i);44 for(int j=0;j(i,j)[0](i,j)[1])47 {48 if(Iimage.at(i,j)[0](i,j)[2])49 {50 c1=Iimage.at(i,j)[0];51 c2=Iimage.at(i,j)[2];52 cp[j]=(int)Iimage.at(i,j)[0];53 }54 else

55 {56

57 cp[j]=(int)Iimage.at(i,j)[2];58 }59 }60 else

61 {62 if((float)Iimage.at(i,j)[1](i,j)[2])63 {64

65 cp[j]=(int)Iimage.at(i,j)[1];66

67 }68 else

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值