VB.NET2005计算图片某一区域的面积
日期:2008-6-27 13:53:27 来源: 作者: 浏览:次 |
|
| VB.NET2005计算图片某一区域的面积 |
Public Structure PicArea Dim x1 As Integer Dim y1 As Integer Dim x2 As Integer Dim y2 As Integer End Structure
Public Function ComputationArea(ByVal img As Image) As PicArea Dim fArea As New PicArea Dim x1, x2, x3, x4, y1, y2, y3, y4 As Integer Dim red, green, blue As Integer Dim ColorCenter As Integer Dim bmp As New Bitmap(img) Dim c As System.Drawing.Color c = bmp.GetPixel(4, 4) Dim i As Integer = (CInt(c.R) + CInt(c.G) + CInt(c.B)) / 3 If i > 129 Then ColorCenter = 150 Else ColorCenter = 150 End If With bmp For y As Integer = 8 To .Height - 8 For x As Integer = 8 To .Width - 8 Dim pixel As System.Drawing.Color pixel = .GetPixel(x, y) red = Math.Abs(CInt(pixel.R)) green = Math.Abs(CInt(pixel.G)) | |