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