如何对这个曲线进行平滑处理可以使用移动平均法vb.net曲线平滑处理,对前n个数求和取平均赋给下一个数,依次移动直到数据末尾,最后形成一新的数组z,最后plot(x,z)就行vb.net曲线平滑处理了,不过要注意n的取值要合适,推荐先取5-10之间的数吧 。
vb中样条曲线问题不引用的话,VB做不到 。这事情要看VB的版本 。如果是6.0的话,要去网上下载GDIPLUS的库文件或者自己声明GDI 的API 。如果是VB.NET的话,VB自带GDI,但是也可以下载GDIPLUS库来用 。如果不知道去哪里下载,我下载有,你可以问我要 。我使用VB6.0 。下载gdiplus以后,在VB里面引用这个库,注意要选择“所有文件”才能看到这个库 。gdi 里面的path功能可以实现样条:Private TOKEN As Long'GDI 对象
Private Graphics As Long'画板
Private Sub InitGDIPlus()
'初始化GDI
Dim uInput As GdiplusStartupInput
uInput.GdiplusVersion = 1
If GdiplusStartup(TOKEN, uInput)Ok Then
'初始化错误
MsgBox "GDI初始化错误 。程序即将关闭 。", vbCritical, "InitError"
End
End If
GdipCreateFromHDC Me.hDC, Graphics'创建画板
GdipSetSmoothingMode Graphics, SmoothingModeAntiAlias'设置为反锯齿
End SubPrivate Sub TerminateGDIPlus()
GdipDeleteGraphics Graphics '释放graphics占用的内存
GdiplusShutdown TOKEN '关闭GDI
End SubPrivate Sub Form_Load()
InitGDIPlus '初始化End SubPrivate Sub Command1_Click()Dim path As Long
Dim m(3) As POINTF '以下是坐标,你可以自由改变
m(0).x = 0
m(0).y = 0
m(1).x = 10
m(1).y = 100
m(2).x = 20
m(2).y = 3
m(3).x = 500
m(3).y = 100
Dim pen As Long
GdipCreatePen1 HFF000000, 2, UnitPixel, pen '创建画笔,用来画出样条
GdipCreatePath FillModeAlternate, path '创建path
GdipAddPathBeziers path, m(0), 4 '创建样条'Count是说坐标的个数,points只能传递数组的第一个元素,不能传递数组 。
GdipDrawPath Graphics, pen, path '画出样条
GdipDeletePen pen '删除画笔
GdipDeletePath path '删除样条End SubPrivate Sub Form_Unload(Cancel As Integer)
TerminateGDIPlus '删除GDI
End Sub
VB如何实现平滑曲线VERSION 5.00Begin VB.Form FrmMainAutoRedraw = -1 'TrueCaption = "光滑直线"ClientHeight = 6780ClientLeft = 60ClientTop = 450ClientWidth = 9795LinkTopic = "Form1"ScaleHeight = 452ScaleMode = 3 'PixelScaleWidth = 653StartUpPosition = 3 '窗口缺省Begin VB.CommandButton CmdDrawCaption = "绘制"Height = 375Left = 120TabIndex = 0Top = 120Width = 1215EndBegin VB.Line Line1Visible = 0 'FalseX1 = 48X2 = 272Y1 = 128Y2 = 88EndEndAttribute VB_Name = "FrmMain"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As LongFunction Min(s1 As Long, s2 As Long) As LongIf s1s2 Then Min = s1 Else Min = s2End FunctionFunction Max(s1 As Long, s2 As Long) As LongIf s1s2 Then Max = s1 Else Max = s2End FunctionPrivate Sub CmdDraw_Click()Dim Scal As Single, Gray As Long, MinX As Long, MaxX As Long, MinY As Long, MaxY As LongDim X1 As Long, X2 As Long, Y1 As Long, Y2 As Long, X3 As Single, Y3 As SingleLine1.Visible = FalseMinX = Min(Line1.X1, Line1.X2): MaxX = Max(Line1.X1, Line1.X2)MinY = Min(Line1.Y1, Line1.Y2): MaxY = Max(Line1.Y1, Line1.Y2)If (Line1.Y1Line1.Y2 And Line1.X1Line1.X2) Or (Line1.Y1Line1.Y2 And Line1.X1Line1.X2) ThenIf Abs(Line1.X1 - Line1.X2)Abs(Line1.Y1 - Line1.Y2) ThenScal = Abs(Line1.Y2 - Line1.Y1) / Abs(Line1.X2 - Line1.X1)For i = 0 To MaxX - MinXY3 = i * ScalMinY: Y1 = Int(Y3): Y2 = Y11Gray = (Y2 - Y3) * 255SetPixel Me.hdc, iMinX, Y2, RGB(Gray, Gray, Gray)Gray = (Y3 - Y1) * 255SetPixel Me.hdc, iMinX, Y1, RGB(Gray, Gray, Gray)Next iElseScal = Abs(Line1.X2 - Line1.X1) / Abs(Line1.Y2 - Line1.Y1)For i = 0 To MaxY - MinYX3 = i * ScalMinX: X1 = Int(X3): X2 = X11Gray = (X2 - X3) * 255SetPixel Me.hdc, X2, iMinY, RGB(Gray, Gray, Gray)Gray = (X3 - X1) * 255SetPixel Me.hdc, X1, iMinY, RGB(Gray, Gray, Gray)Next iEnd IfElseIf Abs(Line1.X1 - Line1.X2)Abs(Line1.Y1 - Line1.Y2) ThenScal = -Abs(Line1.Y2 - Line1.Y1) / Abs(Line1.X2 - Line1.X1)For i = 0 To MaxX - MinXY3 = i * ScalMaxY: Y1 = Int(Y3): Y2 = Y11Gray = (Y2 - Y3) * 255SetPixel Me.hdc, iMinX, Y2, RGB(Gray, Gray, Gray)Gray = (Y3 - Y1) * 255SetPixel Me.hdc, iMinX, Y1, RGB(Gray, Gray, Gray)Next iElseScal = -Abs(Line1.X2 - Line1.X1) / Abs(Line1.Y2 - Line1.Y1)For i = 0 To MaxY - MinYX3 = i * ScalMaxX: X1 = Int(X3): X2 = X11Gray = (X2 - X3) * 255SetPixel Me.hdc, X2, iMinY, RGB(Gray, Gray, Gray)Gray = (X3 - X1) * 255SetPixel Me.hdc, X1, iMinY, RGB(Gray, Gray, Gray)Next iEnd IfEnd IfMe.RefreshEnd SubPrivate Sub Form_Load()Me.ScaleMode = vbPixelsMe.AutoRedraw = TrueEnd SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)Line1.Visible = TrueLine1.X1 = x: Line1.Y1 = yEnd SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)If Button = vbLeftButton Then Line1.X2 = x: Line1.Y2 = yEnd SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)Line1.X2 = x: Line1.Y2 = yEnd Sub
vb.net绘制曲线图 。net其实还是很好绘制图形vb.net曲线平滑处理的
vb.net曲线平滑处理你可以看下 Graphics类
Dim d As New Bitmap(Me.Width, Me.Height)‘一个图片吧
Dim g As Graphics = Graphics.FromImage(d)’绘制准备在这个图片是进行
然后就是vb.net曲线平滑处理你绘制的东西vb.net曲线平滑处理了
线 就是g.DrawLine()
圆 弧度就用g.DrawArc(Pens.Black, New Rectangle(0, 0, 400, 200), 0, 360)
复杂的就是g.DrawBezier()
等如果你用的是 VS的编译上面都有详细的参数说明
Dim d As New Bitmap(Me.Width, Me.Height)
Dim g As Graphics = Graphics.FromImage(d)
g.DrawArc(Pens.Black, New Rectangle(0, 0, 200, 200), 0, 360)
g.DrawLine(Pens.Red, New Point(0, 0), New Point(200, 200))
g.DrawLines(Pens.Green, New Point() {New Point(0, 0), New Point(50, 40), New Point(50, 80), New Point(90, 70), New Point(100, 400)})
g.DrawBezier(Pens.Yellow, New Point(0, 100), New Point(0, 0), New Point(200, 0)vb.net曲线平滑处理,New Point(200, 200))
g.Dispose()
Me.BackgroundImage = d
【vb.net曲线平滑处理 vb 曲线】vb.net曲线平滑处理的介绍就聊到这里吧,感谢你花时间阅读本站内容 , 更多关于vb 曲线、vb.net曲线平滑处理的信息别忘了在本站进行查找喔 。
推荐阅读
- 读文章公众号推荐情感文章,推荐微信公众号情感类
- 语音直播能卖什么产品,语音直播可以播什么内容
- 直播聚合运营群,直播聚合运营群怎么找
- 函数指针python 函数指针怎么用
- 视频号带货怎么找素材,视频号带货怎么做
- js过去超链接的文本,js超链接跳转
- 手机休闲益智的游戏,手机休闲益智游戏排行前十
- go语言做图像处理 go语言绘图库
- jquery根据名称获取,jquery根据 id name获取对象