各位VB图像处理的大侠,请教以下去噪的问题!我用CCD摄像头拍摄了一组照片,可是在拍摄过程中由于背景的缘故,拍摄进去了很多“小白点”,我想知道怎么才能将其去掉,而且我拍摄的是白色的纤维,背景是黑色的,我想经过去掉小白点后就剩下白色的纤维和黑色的背景!怎么办呢?

解决方案 »

  1.   

    中值滤波弱化细小部分我的就是纤维很细的,如果弱化就找不到了!对了,陨落雁,我能不能看一下你的源码?谢谢啦![email protected]
      

  2.   

    Public Function AbstergeBits(mBitmap As cDIB, MyValue As Long, Wide As Long, Optional ByVal IsProgress As Boolean = False)
    'On Error Resume Next
    Dim I As Long, j As Long, SinValue As Single, Value As Single
    Dim fi As Long, fj  As Long, fs As Long, ChangeNum As Long
    Dim jj As Long, ii As Long, jj_ As Long, ii_ As Long
    Dim ScanLine As Long
    Dim PicBits() As Byte
    Dim ByteArray() As Byte
    Dim TempBits() As Long
    Dim MColor As Long, Color As Long
    Dim n As Long, n_ As Long, v As Long, Wide_ As Long, Half As Long
    Dim sWidth As Long, sHeight As Long
    Dim wi As Long, wj As Long, wi_ As Long, wj_ As Long
    Dim DataSize As LongDataSize = mBitmap.SizeImageWide_ = -Wide
    n = (Wide * 2 + 1) ^ 2
    Half = (n - 1) / 2 + 1
    n_ = HalfReDim TempBits(n)
    ScanLine = mBitmap.mWidth * 4mBitmap.MapArray PicBits
    ReDim ByteArray(0 To mBitmap.SizeImage) As ByteFor I = 0 To DataSize - 3 Step 4
      For j = 0 To 2
        Color = PicBits(I + j)
        v = 0
        wi = I + Wide_ * ScanLine
        For fi = Wide_ To Wide
          'wi = I + fi * ScanLine
          jj_ = Wide_ * 4
          jj = jj_ + j
          For fj = Wide_ To Wide
            wj = wi + jj_
            If wj < DataSize And wj >= 0 Then
              TempBits(v) = PicBits(wi + jj)
            Else
              TempBits(v) = Color
            End If
            jj = jj + 4
            jj_ = jj_ + 4
            v = v + 1
          Next fj
          wi = wi + ScanLine
        Next fi
        For fi = 0 To n_
          fs = fi
          For fj = fi + 1 To n
            If TempBits(fj) < TempBits(fs) Then fs = fj
          Next fj
          ChangeNum = TempBits(fi)
          TempBits(fi) = TempBits(fs)
          TempBits(fs) = ChangeNum
        Next fi
        MColor = TempBits(Half)
        ByteArray(I + j) = MColor + (Color - MColor) * SinValue
      Next j
      ByteArray(I + 3) = PicBits(I + 3)
    Next I
    mBitmap.UnMapArray ByteArrayAbstergeBits = True
    End Function说明,图象是32位的,MapArray是我类模块的一个功能,将其拷贝到一个数组中,按BGRA|BGRA|BGRA……这样的顺序排列,Wide是模板宽度,速度一般