vb.net 中二维数组的滑动窗口
我在 vb.net 中的 2D 数组上滑动可变大小的窗口时遇到问题。我的问题是,当我在 0,0 处取数组的第一个元素时,无论窗口的大小如何,它都需要更小,因为有问题的元素必须是滑动窗口的中心。例如: arrar size(40,43) 窗口大小 5x5 (窗口大小为 NxN N=3 获胜大小为 3x3),因此数组(0,0)获胜大小为 5,因此需要计算出 2 列和 2 行并创建一个新的窗口大小为 3x3。任何帮助都会很棒。`
Public Function getPIXELSinWINDOW(ByVal Wsize As Integer, ByVal x As Integer, ByVal y As Integer)
Dim tempARRAY As New ArrayList()
Dim Xwidth As Integer = Wsize
Dim Yheight As Integer = Wsize
Dim Xvalue As Integer = x - Wsize / 2
Dim Yvalue As Integer = y - Wsize / 2
Dim imgHEIGHT As Integer = Me.mysize.Height
Dim imgWIDTH As Integer = Me.mysize.Width
Dim i, j As Integer
While Xvalue < 0
Xvalue += 1
Xwidth -= 1
End While
While Xvalue > imgWIDTH
Xvalue -= 1
Xwidth -= 1
End While
While Xwidth >= imgWIDTH
Xwidth -= 1
End While
While Xvalue + Xwidth > imgWIDTH
Xwidth -= 1
End While
While Yvalue < 0
Yvalue += 1
Yheight -= 1
End While
While Yvalue > imgHEIGHT
Yvalue -= 1
Yheight -= 1
End While
While Yheight >= imgHEIGHT
Yheight -= 1
End While
While Yvalue + Yheight > imgHEIGHT
Yheight -= 1
End While
For i = Xvalue To Xvalue + Xwidth
For j = Yvalue To Yvalue + Yheight
tempARRAY.Add(pixels(j, i))
Next
Next
Return tempARRAY
End Function
var 像素是二维数组
I'm having problems with sliding a variable sized window over a 2D array in vb.net. my porblem is when I take the first element of the array at 0,0 what ever the size of the window is it needs to be smaller because the element in question has to be the center of the sliding window. ex: arrar size(40,43) window size 5x5 ( window size is NxN N=3 wins size is 3x3) so array(0,0) with win size 5 so 2 col and 2 rows need to be cout out and a new window size of 3x3. any help would be great.`
Public Function getPIXELSinWINDOW(ByVal Wsize As Integer, ByVal x As Integer, ByVal y As Integer)
Dim tempARRAY As New ArrayList()
Dim Xwidth As Integer = Wsize
Dim Yheight As Integer = Wsize
Dim Xvalue As Integer = x - Wsize / 2
Dim Yvalue As Integer = y - Wsize / 2
Dim imgHEIGHT As Integer = Me.mysize.Height
Dim imgWIDTH As Integer = Me.mysize.Width
Dim i, j As Integer
While Xvalue < 0
Xvalue += 1
Xwidth -= 1
End While
While Xvalue > imgWIDTH
Xvalue -= 1
Xwidth -= 1
End While
While Xwidth >= imgWIDTH
Xwidth -= 1
End While
While Xvalue + Xwidth > imgWIDTH
Xwidth -= 1
End While
While Yvalue < 0
Yvalue += 1
Yheight -= 1
End While
While Yvalue > imgHEIGHT
Yvalue -= 1
Yheight -= 1
End While
While Yheight >= imgHEIGHT
Yheight -= 1
End While
While Yvalue + Yheight > imgHEIGHT
Yheight -= 1
End While
For i = Xvalue To Xvalue + Xwidth
For j = Yvalue To Yvalue + Yheight
tempARRAY.Add(pixels(j, i))
Next
Next
Return tempARRAY
End Function
the var pixels is the 2d array
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的东西吗?
Something like this?