aiena Level: Trainee
 Registered: 18-09-2006 Posts: 1
|
from gray scale to threshold, inverse, convolution
Option Explicit
Private Sub Command1_Click()
Dim x As Long
Dim y As Long
Dim c As Long
Dim r, g, b As Byte
Picture1.Picture = LoadPicture("d:\disegni\fridgedoor_1683_28908208.gif")
'convert picture lo grayscale
With Picture1
For x = 1 To .ScaleX(.Picture.Width, vbHimetric, vbPixels)
For y = 1 To .ScaleY(.Picture.Height, vbHimetric, vbPixels)
c = .Point(.ScaleX(x, vbPixels, .ScaleMode), .ScaleY(y, vbPixels, .ScaleMode))
If c > 0 Then
b = c Mod 256
c = c \ 256
g = c Mod 256
r = c \ 256
c = (r + g + b) / 3
Picture1.PSet (.ScaleX(x, vbPixels, .ScaleMode), .ScaleY(y, vbPixels, .ScaleMode)), RGB(c, c, c)
End If
Next
Next
End With
End Sub
From this, how to convert gray scale to threshold, smoothing filter, Convolution – Laplacian sharpening filter (3x3 mask),Edge detection – Sobel kernel (3x3 mask), inverse.
|