?? formsmoothdemo.frm
字號:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmmain
AutoRedraw = -1 'True
BorderStyle = 3 'Fixed Dialog
Caption = "對24位真彩色圖像加柔"
ClientHeight = 4080
ClientLeft = 60
ClientTop = 672
ClientWidth = 5868
LinkTopic = "Form1"
NegotiateMenus = 0 'False
ScaleHeight = 340
ScaleMode = 3 'Pixel
ScaleWidth = 489
ShowInTaskbar = 0 'False
Begin VB.PictureBox Picture2
AutoRedraw = -1 'True
AutoSize = -1 'True
FillColor = &H00000040&
FontTransparent = 0 'False
ForeColor = &H00FFFFFF&
Height = 3012
Left = 120
ScaleHeight = 247
ScaleMode = 3 'Pixel
ScaleWidth = 197
TabIndex = 3
Top = 480
Width = 2412
End
Begin VB.PictureBox Picture1
AutoRedraw = -1 'True
AutoSize = -1 'True
FillStyle = 0 'Solid
Height = 3012
Left = 3240
Negotiate = -1 'True
ScaleHeight = 247
ScaleMode = 3 'Pixel
ScaleWidth = 197
TabIndex = 2
Top = 480
Width = 2412
End
Begin MSComDlg.CommonDialog CommonDialog2
Left = 12000
Top = 8880
_ExtentX = 847
_ExtentY = 847
_Version = 393216
DefaultExt = "bmp"
DialogTitle = "保存處理后的圖像文件"
Filter = " ""Pictures (*.bmp;*.gif)|*.bmp;*.gif"""
InitDir = "d:\"
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 5640
Top = 9240
_ExtentX = 847
_ExtentY = 847
_Version = 393216
DialogTitle = "請選擇要打開的圖像文件名子"
Flags = 1
End
Begin MSComctlLib.ProgressBar ProgressBar1
Height = 372
Left = 1200
TabIndex = 0
Top = 3600
Width = 3816
_ExtentX = 6731
_ExtentY = 656
_Version = 393216
BorderStyle = 1
Appearance = 1
End
Begin VB.Label Label2
Caption = "原 圖"
Height = 492
Left = 1080
TabIndex = 4
Top = 240
Width = 1212
End
Begin VB.Label Label1
Caption = "柔 化 圖"
Height = 372
Left = 3960
TabIndex = 1
Top = 240
Width = 1692
End
Begin VB.Menu file
Caption = "文件(&F)"
WindowList = -1 'True
Begin VB.Menu open
Caption = "打開文件"
Shortcut = ^O
End
Begin VB.Menu save
Caption = "保存文件"
Shortcut = ^S
End
Begin VB.Menu mseperate
Caption = "-"
End
Begin VB.Menu exit
Caption = "退出系統"
Shortcut = ^X
End
End
Begin VB.Menu effect
Caption = "效果處理(&E)"
Visible = 0 'False
Begin VB.Menu m_frame
Caption = "加入像框"
End
Begin VB.Menu xxx
Caption = "-"
End
Begin VB.Menu character_extract
Caption = "特征提取"
Shortcut = ^B
End
Begin VB.Menu c
Caption = "-"
End
Begin VB.Menu smooth
Caption = "圖像柔化"
Begin VB.Menu common_smooth
Caption = "1/9柔化"
Shortcut = {F1}
End
Begin VB.Menu smooth10
Caption = "1/10柔化"
End
Begin VB.Menu smooth16
Caption = "1/16柔化(高斯柔化)"
End
Begin VB.Menu smooth8
Caption = "1/8柔化"
End
Begin VB.Menu smooth2
Caption = "1/2柔化"
End
Begin VB.Menu smooth_more
Caption = "自定義柔化"
Shortcut = {F2}
End
End
Begin VB.Menu jjj
Caption = "-"
End
Begin VB.Menu sharp
Caption = "圖像銳化"
Begin VB.Menu common_sharp
Caption = "H0銳化"
Shortcut = {F3}
End
Begin VB.Menu h1sharp
Caption = "H1銳化"
End
Begin VB.Menu h2sharp
Caption = "H2銳化(lpls銳化)"
End
Begin VB.Menu h3sharp
Caption = "H3銳化"
End
Begin VB.Menu h4sharp
Caption = "H4銳化"
End
Begin VB.Menu sobelsharp
Caption = "sobel銳化"
End
Begin VB.Menu prewittsharp
Caption = "Prewitt銳化"
End
Begin VB.Menu isotropicsharp
Caption = "Isotropic銳化"
End
Begin VB.Menu kirschsharp
Caption = "Kirsch銳化"
End
Begin VB.Menu wallissharp
Caption = "wallis銳化"
End
Begin VB.Menu f
Caption = "-"
End
Begin VB.Menu sharp_more
Caption = "自定義銳化"
Shortcut = {F4}
End
End
Begin VB.Menu ll
Caption = "-"
End
Begin VB.Menu inverse
Caption = "圖像反色"
Shortcut = ^I
End
Begin VB.Menu g
Caption = "-"
Index = 3
End
Begin VB.Menu m_strech
Caption = "縮放圖象"
End
Begin VB.Menu www
Caption = "-"
End
Begin VB.Menu emboss
Caption = "浮雕效果"
Shortcut = ^E
End
Begin VB.Menu h
Caption = "-"
End
Begin VB.Menu diffuse
Caption = "圖像擴散"
Shortcut = ^D
End
Begin VB.Menu i
Caption = "-"
End
Begin VB.Menu customize
Caption = "定制處理"
Enabled = 0 'False
Shortcut = ^C
End
Begin VB.Menu pp
Caption = "-"
End
Begin VB.Menu undo
Caption = "圖像恢復"
Shortcut = ^U
End
Begin VB.Menu m
Caption = "-"
End
Begin VB.Menu grayscale
Caption = "灰度圖像"
End
Begin VB.Menu colorfulimage
Caption = "彩色圖像"
Enabled = 0 'False
End
End
Begin VB.Menu move
Caption = "圖像移動(&M)"
Visible = 0 'False
Begin VB.Menu translation
Caption = "圖像平移"
Shortcut = ^M
End
Begin VB.Menu o
Caption = "-"
End
Begin VB.Menu rotate
Caption = "圖像旋轉"
Enabled = 0 'False
Shortcut = ^R
End
End
Begin VB.Menu mirror
Caption = "鏡像"
Visible = 0 'False
Begin VB.Menu mhorizon
Caption = "水平鏡像"
End
Begin VB.Menu vv
Caption = "-"
End
Begin VB.Menu mvertical
Caption = "垂直鏡像"
End
End
Begin VB.Menu depth
Caption = "提取部分圖像"
Visible = 0 'False
Begin VB.Menu partimage
Caption = "截取有效部分"
End
End
Begin VB.Menu mprocess
Caption = "特殊處理"
Visible = 0 'False
Begin VB.Menu mgetpoint
Caption = "輸入采樣點"
End
Begin VB.Menu a
Caption = "-"
End
Begin VB.Menu mgetoutline
Caption = "輪廓提取"
End
Begin VB.Menu p
Caption = "-"
End
Begin VB.Menu medge_trace
Caption = "輪廓跟蹤"
End
Begin VB.Menu mrecgonize
Caption = "缺陷識別"
End
Begin VB.Menu e
Caption = "-"
End
Begin VB.Menu msame_color
Caption = "圖像分割"
End
Begin VB.Menu dfa
Caption = "-"
End
Begin VB.Menu mshade
Caption = "投影"
Begin VB.Menu mver_shade
Caption = "豎直投影"
End
Begin VB.Menu fddd
Caption = "-"
End
Begin VB.Menu mhori_shade
Caption = "水平投影"
End
End
End
Begin VB.Menu manalysis
Caption = "圖像效果"
Begin VB.Menu msmoothit
Caption = "柔化"
End
Begin VB.Menu mclipping
Caption = "削波"
Visible = 0 'False
End
Begin VB.Menu mgray_window
Caption = "灰度窗口"
Visible = 0 'False
End
Begin VB.Menu mbinary_image
Caption = "閥值化"
Visible = 0 'False
End
Begin VB.Menu mhistogram
Caption = "直方圖均衡"
Visible = 0 'False
End
End
End
Attribute VB_Name = "frmmain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim imagepixels(2, 1024, 1024) As Integer '用來存儲讀入的圖像數據
Dim x, y As Integer '用來記錄圖像的寬度和高度
Dim picturename, picture_savename As String
Private Sub open_Click()
Dim i As Integer, j As Integer
Dim red As Long, green As Long, blue As Long
Dim pixel As Long ' 設置“CancelError”為 True
CommonDialog1.CancelError = True
On Error GoTo ErrHandler ' 設置標志
CommonDialog1.Flags = cdlOFNHideReadOnly ' 設置過濾器
CommonDialog1.Filter = "All Files (*.*)|*.*|Text Files" & _
"(*.txt)|*.txt|pictures(*.gif)|*.gif|pictures(*.bmp)|*.bmp" ' 指定缺省的過濾器
CommonDialog1.FilterIndex = 4 ' 顯示“打開”對話框
CommonDialog1.ShowOpen ' 顯示選定文件的名字
picturename = CommonDialog1.FileName
If picturename = "" Then Exit Sub
Picture1.Picture = LoadPicture(picturename)
Picture2.Picture = Picture1.Picture
Picture1.Refresh
Picture2.Refresh
Picture1.ScaleMode = vbPixels
Picture1.AutoSize = True
x = Picture1.ScaleWidth
y = Picture1.ScaleHeight
If x > 1024 Or y > 1024 Then
MsgBox "圖片大,請選小圖片"
x = 0
y = 0
Exit Sub
End If '限制處理圖片的大小
frmmain.Visible = False
For i = 0 To y - 1
For j = 0 To x - 1
pixel& = frmmain.Picture1.Point(j, i)
red = pixel& Mod 256
green = ((pixel& And &HFF00) / 256&) Mod 256&
blue = (pixel& And &HFF0000) / 65536
imagepixels(0, j, i) = red
imagepixels(1, j, i) = green
imagepixels(2, j, i) = blue
Next
Next
frmmain.Visible = True
frmmain.Show
ErrHandler:
' 用戶按了“取消”按鈕
Exit Sub
End Sub
Private Sub msmoothit_Click() '對彩色圖像進行加柔
Dim i As Integer, j As Integer
Dim dx As Integer, dy As Integer
Dim red As Long, green As Long, blue As Long
Dim gray
Dim YofImg, UofImg, VofImg, redr, greeng, blueb '記錄需削波的象素點的yuv值。
If Picture1.Picture = 0 Then
MsgBox ("please choose an image,firstly")
Exit Sub
End If
ProgressBar1.Visible = True
For i = 1 To y - 1
For j = 1 To x - 1
red = (imagepixels(0, j - 1, i - 1) + imagepixels(0, j - 1, i) + imagepixels(0, j - 1, i + 1) + imagepixels(0, j, i - 1) + imagepixels(0, j, i) + imagepixels(0, j, i + 1) + imagepixels(0, j + 1, i - 1) + imagepixels(0, j + 1, i) + imagepixels(0, j + 1, i + 1)) / 9
green = (imagepixels(1, j - 1, i - 1) + imagepixels(1, j - 1, i) + imagepixels(1, j - 1, i + 1) + imagepixels(1, j, i - 1) + imagepixels(1, j, i) + imagepixels(1, j, i + 1) + imagepixels(1, j + 1, i - 1) + imagepixels(1, j + 1, i) + imagepixels(1, j + 1, i + 1)) / 9
blue = (imagepixels(2, j - 1, i - 1) + imagepixels(2, j - 1, i) + imagepixels(2, j - 1, i + 1) + imagepixels(2, j, i - 1) + imagepixels(2, j, i) + imagepixels(2, j, i + 1) + imagepixels(2, j + 1, i - 1) + imagepixels(2, j + 1, i) + imagepixels(2, j + 1, i + 1)) / 9
Picture1.PSet (j, i), RGB(red, green, blue)
Next
Picture1.Refresh
ProgressBar1.Value = i * 100& / (y - 1)
DoEvents
Next
MsgBox ("圖像已經被加柔!")
frmmain.ProgressBar1.Visible = False
End Sub
Private Sub save_Click()
' 初始化“CancelError”為 True
CommonDialog2.CancelError = True
On Error GoTo ErrHandler ' 設置標志
CommonDialog2.Flags = cdlOFNHideReadOnly ' 設置過濾器
CommonDialog2.Filter = "All Files (*.*)|*.*|Text Files" & _
"(*.txt)|*.txt|pictures(*.gif)|*.gif|pictures(*.bmp)|*.bmp" ' 指定缺省的過濾器
CommonDialog2.FilterIndex = 4 ' 顯示“打開”對話框
CommonDialog2.ShowSave ' 顯示選定文件的名字
picture_savename = CommonDialog2.FileName
SavePicture Picture1.Image, picture_savename
ErrHandler: ' 用戶按了“取消”按鈕
Exit Sub
End Sub
Private Sub exit_Click()
Unload Me
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -