vlambda博客
学习文章列表

EXCEL的图像识别在链路预算中的应用

通过下面示例和步骤,说明如使用EXCEL根据输入的地点名称自动获取降雨衰减和卫星EIRP、G/T值等。
1、从网上找到ITU雨区分布图和亚洲9的Ku频段中国波束EIRP覆盖图
EXCEL的图像识别在链路预算中的应用

2、利用PS处理只保留几种代表符号或数值的颜色(这里建议使用EXCEL单元格的56种底色系列)、删除无用线条和杂色,调整好图像尺寸,保存为BMP24位的格式,如下面的状态
EXCEL的图像识别在链路预算中的应用
上面这个雨区分布图是墨卡托投影,在后面的EXCEL查询中做了转换
EXCEL的图像识别在链路预算中的应用

3、利用EXCEL的VBA代码读取上面两张覆盖图
  
    
    
  
Sub Main() Const strBmpFile As String = "C:\Mercator06.bmp" Dim arrByte() As Byte Dim PixelCol As Long, PixelRow As Long Dim CellCol As Long, CellRow As Long Dim i As Long, j As Long Dim lngPos As Long, Zeroize As Long      Open strBmpFile For Binary As #1 ReDim arrByte(LOF(1) - 1) Get #1, , arrByte Close #1      For i = 0 To 3 PixelCol = PixelCol + arrByte(i + 18) * 256 ^ i Next For i = 0 To 3 PixelRow = PixelRow + arrByte(i + 22) * 256 ^ i Next     If PixelCol Mod 4 <> 0 Then Zeroize = PixelCol Mod 4      Cells.Clear For i = PixelRow To 1 Step -1 CellRow = CellRow + 1 CellCol = 0 For j = 1 To PixelCol * 3 Step 3 CellCol = CellCol + 1 lngPos = 53 + j + (i - 1) * (PixelCol * 3 + Zeroize) Cells(CellRow, CellCol).Interior.Color = RGB(arrByte(lngPos + 2), arrByte(lngPos + 1), arrByte(lngPos)) Next Next End Sub

4、利用EXCEL的VBA代码在两张覆盖表中填充对应符号或数字
Sub tst()Application.ScreenUpdating = FalseDim i, j, kWith Sheets("雨区颜色-1")For i = 1 To 3142For j = 1 To 3142k = .Cells(j, i).Interior.ColorIf k = 16777215 Then .Cells(j, i) = "A" ElseIf k = 65280 Then .Cells(j, i) = "B" ElseIf k = 16764160 Then .Cells(j, i) = "C" ElseIf k = 15066597 Then .Cells(j, i) = "D" ElseIf k = 13369343 Then .Cells(j, i) = "E" ElseIf k = 52735 Then .Cells(j, i) = "F" ElseIf k = 26367 Then .Cells(j, i) = "G" ElseIf k = 16738047 Then .Cells(j, i) = "H" ElseIf k = 10014157 Then .Cells(j, i) = "J" ElseIf k = 9764788 Then .Cells(j, i) = "K" ElseIf k = 39645 Then .Cells(j, i) = "L" ElseIf k = 65535 Then .Cells(j, i) = "M" ElseIf k = 16764415 Then .Cells(j, i) = "N" ElseIf k = 16777140 Then .Cells(j, i) = "P"Else .Cells(j, i) = "Q"    End IfNext jNext iEnd WithApplication.ScreenUpdating = TrueEnd Sub
数字化的覆盖图如下所示:
EXCEL的图像识别在链路预算中的应用
EXCEL的图像识别在链路预算中的应用

5、最后利用常用的链路预算EXCEL表格即可以实现根据输入地点自动获取相关数据了
EXCEL的图像识别在链路预算中的应用

EXCEL的图像识别在链路预算中的应用