EXCEL的图像识别在链路预算中的应用
Posted 卫星通信工程师
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EXCEL的图像识别在链路预算中的应用相关的知识,希望对你有一定的参考价值。
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
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的图像识别在链路预算中的应用的主要内容,如果未能解决你的问题,请参考以下文章