扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
'中值滤波:
崇阳网站建设公司创新互联,崇阳网站设计制作,有大型网站制作公司丰富经验。已为崇阳千余家提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的崇阳做网站的公司定做!
Dim x As Integer, y As Integer, size As Integer = 3, point(8) As Integer
For x = CInt((size - 1) / 2) To CInt(jpgImage.Width - 1 - (size - 1) / 2)
For y = CInt((size - 1) / 2) To CInt(jpgImage.Height - 1 - (size - 1) / 2)
point(0) = jpgImage.GetPixel(x - 1, y - 1).R
point(1) = jpgImage.GetPixel(x - 1, y).R
point(2) = jpgImage.GetPixel(x - 1, y + 1).R
point(3) = jpgImage.GetPixel(x, y - 1).R
point(4) = jpgImage.GetPixel(x, y).R
point(5) = jpgImage.GetPixel(x, y + 1).R
point(6) = jpgImage.GetPixel(x + 1, y - 1).R
point(7) = jpgImage.GetPixel(x + 1, y).R
point(8) = jpgImage.GetPixel(x + 1, y + 1).R
Array.Sort(point)
jpgImage.SetPixel(x, y, Color.FromArgb(point(4), point(4), point(4)))
Next
Next
1.创建ADODB对象
2.连接数据库
3.输入查询内容,做 SELECT * FORM 数据表 WHERE 关键字段 Like "*" 输入字符 "*;" 查询
4.帮定DATAGRID到做查询的ADODB.RecordClass对象上,即完成你的要求.要详细代码的加分哦.
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Runtime.InteropServices
''' summary
''' Summary description for TextShadow
''' /summary
''' remarks/remarks
Public Class gaoshiBLUR
Public newbmp As Bitmap
StructLayout(LayoutKind.Explicit) Structure rgbA
FieldOffset(0) Public R As Byte
FieldOffset(1) Public G As Byte
FieldOffset(2) Public B As Byte
FieldOffset(3) Public A As Byte
FieldOffset(0) Public col As Integer
End Structure
Private m_radius As Integer = 5
''' summary
''' 高斯卷积矩阵
''' /summary
''' remarks/remarks
Private gaussMatrix As Integer()
''' summary
''' 卷积核
''' /summary
''' remarks/remarks
Private nuclear As Integer = 0
''' summary
''' 模糊半径
''' /summary
''' value/value
''' returns/returns
''' remarks/remarks
Public Property Radius() As Integer
Get
Return m_radius
End Get
Set(ByVal Value As Integer)
If (m_radius Value) Then
m_radius = Value
MakeGaussMatrix()
End If
End Set
End Property
''' summary
''' 高斯模糊
''' /summary
''' param name="bmp"要处理的图像/param
''' remarks/remarks
Public Sub MaskShadow(ByVal bmp As Bitmap)
If nuclear = 0 Then MakeGaussMatrix()
Dim rt As Rectangle = New Rectangle(0, 0, bmp.Width, bmp.Height)
' 克隆临时位图,作为卷积源
Dim tmp As Bitmap = bmp.Clone()
Dim dest As BitmapData = bmp.LockBits(rt, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb)
Dim source As BitmapData = tmp.LockBits(rt, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb)
Debug.Print(Radius)
Debug.Print(dest.Width.ToString)
Debug.Print(nuclear)
Dim Number As Integer = (bmp.Height * dest.Stride - 1) / 4 ' 图像数据元素的个数,注意.net中数组下标是从0开始的
Dim bmpdata(Number) As Integer
Dim tmpdata(Number) As Integer
Dim TMPrgb(Number) As rgbA '临时参考颜色
Dim BMPrgb(Number) As rgbA '计算结果后的颜色
'ReDim bmpdata(Number)
'ReDim TMPrgb(Number)
Marshal.Copy(source.Scan0, tmpdata, 0, Number)
Dim i As Long
Dim j As Long
j = Number
Dim w, h As Long
Dim yi, xi As Long
Dim iw, ih, iiw, iih, iii As Long
Dim k As Long
Dim nn As Integer = (Radius * 2 + 1) ^ 2
Dim n As Integer = Radius * 2 + 1
w = bmp.Width
h = bmp.Height
' System.Array.Copy(TMPrgb, tmpdata, j)
For i = 0 To j
TMPrgb(i).col = tmpdata(i)
Next i
i = 0
For i = 0 To j
ih = Int(i / w)
iw = i - ih * w
Dim r As Double = 0
Dim g As Double = 0
Dim b As Double = 0
Dim a As Double = 0
Dim weight As Double
For k = 0 To nn
'需要解决的是周边遍历颜色值然后相加(r=r1*weight1+r2*weight2+r3*weight3+r4*weight4+r5*weight5+...r*weight)
yi = Int(k / n)
xi = k - yi * n
yi -= Radius
xi -= Radius
iiw = iw + xi
iih = ih + yi
'yi = Int(k / n)
'xi = k - yi * n
'iih = ih + yi - Radius
'iiw = iw + xi - Radius
If (iiw 0 OrElse iih 0) Or (iiw w - 1 OrElse iih h - 1) Then
iiw = iw
iih = ih
iii = i
Else
iii = iih * w
iii += iiw
End If
weight = gaussMatrix(k) / 1000
r += TMPrgb(iii).R * weight
g += TMPrgb(iii).G * weight
b += TMPrgb(iii).B * weight
a += TMPrgb(iii).A * weight
Next
'TMPrgb(i).col = tmpdata(i)
'r = TMPrgb(i).R * weight
'g = TMPrgb(i).G * weight
'b = TMPrgb(i).B * weight
BMPrgb(i).R = IIf(r 255, 255, r)
BMPrgb(i).G = IIf(g 255, 255, g)
BMPrgb(i).B = IIf(b 255, 255, b)
BMPrgb(i).A = IIf(a 255, 255, a)
bmpdata(i) = BMPrgb(i).col
'Debug.Print(TMPrgb(i).R)
Next
Marshal.Copy(bmpdata, 0, dest.Scan0, Number)
tmp.UnlockBits(source)
bmp.UnlockBits(dest)
newbmp = bmp.Clone
tmp.Dispose()
' End Try
End Sub
''' summary
''' 高斯卷积矩阵
''' /summary
''' remarks/remarks
Protected Sub MakeGaussMatrix()
Dim Q As Double = Radius / 2
If (Q = 0.0) Then Q = 0.1
Dim n As Integer = Radius * 2 + 1
Dim index As Integer = 0
nuclear = 0
ReDim gaussMatrix(n * n)
Dim x As Integer
Dim y As Integer
For x = -Radius To Radius
For y = -Radius To Radius
gaussMatrix(index) = Math.Round(Math.Exp(-((x * x + y * y)) / (2.0 * Q * Q)) / (2.0 * Math.PI * Q * Q) * 1000.0)
nuclear += gaussMatrix(index)
index += 1
Next
Next
End Sub
End Class
使用方法.
Dim bmp As Bitmap = PictureBox1.Image.Clone
Dim x As New gaoshiBLUR
x.Radius = 30
x.MaskShadow(bmp)
PictureBox2.Image = x.newbmp.Clone
gdi+没有提供模糊的功能,也没有相应的api,要做模糊效果,照样需要读取像素数组,用模糊算法处理后返给图像。
gdi+倒是提供了反锯齿的功能,但只能使文字或图形边缘与背景过度更自然,不能用来模糊图像。
用vb的GetDIBits和SetDIBits,应该不会很慢呀,我用vb.net的LockBits获取像素数组,再取周围像素的平均值模糊一个200x200像素的图像,基本上都用不到0.02秒的,用vb和gdi应该不会比这个慢
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流