图像形态学处理(击中击不中变换 ) 终于搞懂了

#include"matrix.h"

#include"iostream.h"

voidmain(void)

{

         grayimag A, G;

         A.GetGray("D:\\grayimag_test\\原图\\击中击不中.bmp");

         A.ViewImag();

                  

         int x,y,u,v;

        

        

         G.GetGray("D:\\grayimag_test\\原图\\击中正方子图.bmp");

         if(G.HitMiss01(A,x,y,u,v))

         {

                   grayimag B=A;

                   B.Clip(x,y,u,v);

                   grayimag C(A.Height(),A.Width());

                   B.Cover(C,x,y);        

                   C.ViewImag();

         }          

         else

                   cout<<"没找到正方子图"<

 

         G.GetGray("D:\\grayimag_test\\原图\\击中圆子图.bmp");

         if(G.HitMiss01(A,x,y,u,v))

         {

                   grayimag B=A;

                   B.Clip(x,y,u,v);

                   grayimag C(A.Height(),A.Width());

                   B.Cover(C,x,y);

                   C.ViewImag();

         }

         else

                   cout<<"没找到圆方子图"<

 

         G.GetGray("D:\\grayimag_test\\原图\\击中三角子图.bmp");

         if(G.HitMiss01(A,x,y,u,v))

         {

                   grayimag B=A;

                   B.Clip(x,y,u,v);

                   grayimag C(A.Height(),A.Width());

                   B.Cover(C,x,y);

                   C.ViewImag();

         }

         else

                   cout<<"没找到三角子图"<

 

 

         G.GetGray("D:\\grayimag_test\\原图\\击中7子图.bmp");

         if(G.HitMiss01(A,x,y,u,v))

         {

                   grayimag B=A;

                   B.Clip(x,y,u,v);

                   grayimag C(A.Height(),A.Width());

                   B.Cover(C,x,y);

                   C.ViewImag();

         }

         else

                   cout<<"没找到7子图"<

 

         G.GetGray("D:\\grayimag_test\\原图\\击中我子图.bmp");

         if(G.HitMiss01(A,x,y,u,v))

         {

                   grayimag B=A;

                   B.Clip(x,y,u,v);

                   grayimag C(A.Height(),A.Width());

                   B.Cover(C,x,y);

                   C.ViewImag();

         }

         else

                   cout<<"没找到我子图"<

 

 

 

         G.GetGray("D:\\grayimag_test\\原图\\击中A子图.bmp");

         if(G.HitMiss01(A,x,y,u,v))

         {

                   grayimag B=A;

                   B.Clip(x,y,u,v);

                   grayimag C(A.Height(),A.Width());

                   B.Cover(C,x,y);

                   C.ViewImag();

         }

         else

                   cout<<"没找到A子图"<

 

 

    G.GetGray("D:\\grayimag_test\\原图\\击中3子图.bmp");

         if(G.HitMiss01(A,x,y,u,v))

         {

                   grayimag B=A;

                   B.Clip(x,y,u,v);

                   grayimag C(A.Height(),A.Width());

                   B.Cover(C,x,y);

                   C.ViewImag();

         }

         else

                   cout<<"没找到3子图"<

}

图像形态学处理(击中击不中变换 ) 终于搞懂了_第1张图片

#include"iostream.h"

#include"matrix.h"

voidmain(void)

{

         grayimag A, G;

         A.GetGray("D:\\grayimag_test\\原图\\击中击不中.bmp");

         A.ViewImag();

 

         int x,y,u,v;

        

         G.GetGray("D:\\grayimag_test\\原图\\击中缩小的正方子图.bmp");

         if(G.HitMiss01(A,x,y,u,v,5))

         {

                   cout<<"t=5  击中子图"<

        grayimag B=A;

                   B.Clip(x,y,u,v);

                   grayimagC(A.Height(),A.Width());

                   B.Cover(C,x,y);

                   C.ViewImag();          

         }

         else

                   cout<<"t=5  没击中子图"<

        

        

 

         if(G.HitMiss01(A,x,y,u,v,6))

         {

                   cout<<"t=6  击中子图"<

        grayimag B=A;

                   B.Clip(x,y,u,v);

                   grayimagC(A.Height(),A.Width());

                   B.Cover(C,x,y);

                   C.ViewImag();            

         }

         else

                   cout<<"t=6  没击中子图"<

        

}



你可能感兴趣的:(Halcon学习)