Skip to main content

Closing (闭运算) (VB 6.0)

Closing (闭运算) (VB 6.0)


介绍

闭运算(Closing)就是先增长N次,然后再侵蚀N次。

用法



Option Explicit

Private Sub Form_Load()
    Picture1.Picture = LoadPicture(App.Path & "\demo.bmp")
    Picture2.Picture = LoadPicture(App.Path & "\demo.bmp")
    Dim lngX As Long
    Dim lngY As Long
    Dim intS
    Dim intA, intB, intC
    Dim intD, intE, intF
    Dim intG, intH, intI
    Dim intCount
    Picture1.ScaleMode = 3
    Picture1.AutoRedraw = True
    Picture2.ScaleMode = 3
    Picture2.AutoRedraw = True
    Picture3.ScaleMode = 3
    Picture3.AutoRedraw = True
    For intCount = 0 To 1
        For lngY = 0 To Picture2.ScaleHeight
            For lngX = 0 To Picture2.ScaleWidth
                DoEvents
                intA = (Picture1.Point(lngX - 1, lngY - 1) And &HFF) - 255
                intB = (Picture1.Point(lngX, lngY - 1) And &HFF) - 255
                intC = (Picture1.Point(lngX + 1, lngY - 1) And &HFF) - 255
                intD = (Picture1.Point(lngX - 1, lngY) And &HFF) - 255
                intF = (Picture1.Point(lngX + 1, lngY) And &HFF) - 255
                intG = (Picture1.Point(lngX - 1, lngY + 1) And &HFF) - 255
                intH = (Picture1.Point(lngX, lngY + 1) And &HFF) - 255
                intI = (Picture1.Point(lngX + 1, lngY + 1) And &HFF) - 255
                intS = Abs(intA + intB + intC + intD + intE + intF + intG + intH + intI)
                If intS > 0 Then
                   intS = 0
                Else
                   intS = 255
                End If
                Picture2.PSet (lngX, lngY), RGB(intS, intS, intS)
            Next lngX
        Next lngY
        Set Picture1.Picture = Picture2.Image
    Next intCount
    Set Picture3.Picture = Picture2.Image
    SavePicture Picture3, App.Path & "\Temp.bmp"
    Picture3.Picture = LoadPicture(App.Path & "\Temp.bmp")
    For lngY = 0 To Picture1.ScaleHeight
        For lngX = 0 To Picture1.ScaleWidth
            DoEvents
            intA = (Picture3.Point(lngX - 1, lngY - 1) And &HFF) - 255
            intB = (Picture3.Point(lngX, lngY - 1) And &HFF) - 255
            intC = (Picture3.Point(lngX + 1, lngY - 1) And &HFF) - 255
            intD = (Picture3.Point(lngX - 1, lngY) And &HFF) - 255
            intE = (Picture3.Point(lngX, lngY) And &HFF) - 255
            intF = (Picture3.Point(lngX + 1, lngY) And &HFF) - 255
            intG = (Picture3.Point(lngX - 1, lngY + 1) And &HFF) - 255
            intH = (Picture3.Point(lngX, lngY + 1) And &HFF) - 255
            intI = (Picture3.Point(lngX + 1, lngY + 1) And &HFF) - 255
            intS = intA And intB And intC And intD And intF And intG And intH And intI
            If intS = 0 Then
               intS = 255
            Else
               intS = 0
            End If
            Picture2.PSet (lngX, lngY), RGB(intS, intS, intS)
        Next lngX
    Next lngY
    Picture1.Picture = LoadPicture(App.Path & "\demo.bmp")
End Sub

下载原始档及执行档:

例外

1. 如果执行档不能执行,请先安装vbrun60sp6.exe


参考

[2] Kuo-Jen, Lien, Digital Image Processing, ISBN: 9789574998333, Scholars Books Co., Ltd.

致谢

感谢 (维基自由百科, Kuo-Jen, Lien) 提供的知识。


Popular posts from this blog

Python 日期與時間的處理

Visual Basic 6.0 (VB6) 程式語言案例學習 (10. 條碼列印程式)

寫作:波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

Python 日期與時間的處理

Image

Visual Basic 6.0 (VB6) 程式語言案例學習 (10. 條碼列印程式)

Image

寫作:波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

Image

數位影像處理:最佳化處理策略之快速消除扭曲演算法

Image

Visual Basic 6.0 (VB6) 程式語言案例學習 (04. 人事考勤管理系統)

Image

用10種程式語言做影像二值化(Image binarization)

Visual Basic 6.0 (VB6) 程式語言案例學習 (07. 收據列印程式)

Image

Visual Basic .Net (VB.Net) 程式語言案例學習 (03. 場地預約系統)

Image

Visual Basic 6.0 (VB6) 程式語言案例學習 (11. 生產線拍照程式)

Image

Visual Basic .Net (VB.Net) 程式語言案例學習 (06. 題庫測驗系統)

Image