1. 程式人生 > >基於區域生長的二值化影象連通域標記

基於區域生長的二值化影象連通域標記

    //左
    if ((n > 0) && (obj == *(p + m*LineBytes + n - 1)) && (0 == *(pConnDomainMark + m*LineBytes + n - 1)))
    {
     *(pConnDomainMark + m*LineBytes + n - 1) = markvalue;
     CPoint pt(m, n-1);
     pMarkSeedList->AddTail(pt);
    }
    //左上
    if ((m > 0) && (n > 0) && (obj == *(p + (m-1)*LineBytes + n - 1)) && (0 == *(pConnDomainMark + (m-1)*LineBytes + n - 1)))
    {
     *(pConnDomainMark + (m-1)*LineBytes + n - 1) = markvalue;
     CPoint pt(m-1, n-1);
     pMarkSeedList->AddTail(pt);
    }
    //上
    if ((m > 0) && (obj == *(p + (m-1)*LineBytes + n)) && (0 == *(pConnDomainMark + (m-1)*LineBytes + n)))
    {
     *(pConnDomainMark + (m-1)*LineBytes + n) = markvalue;
     CPoint pt(m-1, n);
     pMarkSeedList->AddTail(pt);
    }
    //右上
    if ((m > 0) && (n < (width-1)) && (obj == *(p + (m-1)*LineBytes + n + 1)) && (0 == *(pConnDomainMark + (m-1)*LineBytes + n + 1)))
    {
     *(pConnDomainMark + (m-1)*LineBytes + n + 1) = markvalue;
     CPoint pt(m-1, n+1);
     pMarkSeedList->AddTail(pt);
    }
    //右
    if ((n < (width-1)) && (obj == *(p + m*LineBytes + n + 1)) && (0 == *(pConnDomainMark + m*LineBytes + n + 1)))
    {
     *(pConnDomainMark + m*LineBytes + n + 1) = markvalue;
     CPoint pt(m, n+1);
     pMarkSeedList->AddTail(pt);
    }
    //右下
    if ((m < (height-1)) && (n < (width-1)) && (obj == *(p + (m+1)*LineBytes + n + 1)) && (0 == *(pConnDomainMark + (m+1)*LineBytes + n + 1)))
    {
     *(pConnDomainMark + (m+1)*LineBytes + n + 1) = markvalue;
     CPoint pt(m+1, n+1);
     pMarkSeedList->AddTail(pt);
    }
    //下
    if ((m < (height-1)) && (obj == *(p + (m+1)*LineBytes + n)) && (0 == *(pConnDomainMark + (m+1)*LineBytes + n)))
    {
     *(pConnDomainMark + (m+1)*LineBytes + n) = markvalue;
     CPoint pt(m+1, n);
     pMarkSeedList->AddTail(pt);
    }
    //左下
    if ((m < (height-1)) && (n > 0) && (obj == *(p + (m+1)*LineBytes + n - 1)) && (0 == *(pConnDomainMark + (m+1)*LineBytes + n - 1)))
    {
     *(pConnDomainMark + (m+1)*LineBytes + n - 1) = markvalue;
     CPoint pt(m+1, n-1);
     pMarkSeedList->AddTail(pt);
    }
    pMarkSeedList->RemoveHead();
   }
  }
 }
 *pMaxMarkValue = markvalue;