测地膨胀和膨胀重建—lhMorpRDilate

函数:lhMorpRDilate

说明:形态学测地膨胀和膨胀重建运算

参数:

src 输入图像

msk 掩模图像

dst 输出图像

se  结构元素

iterations测地膨胀的次数,当默认为-1时,为重建运算

源码:

void lhMorpRDilate(const IplImage* src, const IplImage* msk, IplImage* dst, IplConvKernel* se = NULL, int iterations=-1)

{

       assert(src != NULL && msk != NULL && dst != NULL && src != dst );

       if(iterations < 0)

       {

              //膨胀重建

              cvMin(src, msk, dst);

              cvDilate(dst, dst, se);

              cvMin(dst, msk, dst);

              IplImage*  temp1 = cvCreateImage(cvGetSize(src), 8, 1);

              IplImage*  temp2 = cvCreateImage(cvGetSize(src), 8, 1);

              do

              {

                     cvCopy(dst, temp1);

                     cvDilate(dst, dst, se);

                     cvMin(dst, msk, dst);

                     cvCmp(temp1, dst, temp2, CV_CMP_NE );

              }

              while(cvSum(temp2).val[0] != 0);

              cvReleaseImage(&temp1);

              cvReleaseImage(&temp2);

              return;    

       }

       else if (iterations == 0)

       {

              cvCopy(src, dst);

       }

       else

       {

              //普通测地膨胀 p136(6.1)

              cvMin(src, msk, dst);

              cvDilate(dst, dst, se);

              cvMin(dst, msk, dst);

              for(int i=1; i<iterations; i++)

              {

                     cvDilate(dst, dst, se);

                     cvMin(dst, msk, dst);

              }

       }

}

你可能感兴趣的:(null,DST)