波段運算(Band Math)工具可以方便的執行圖像中的各個波段的加減乘除、三角函數、指數、對數等數學函數計算,也可使用IDL編寫的函數。算法
因爲每一個用戶都有獨特的需求,利用此工具用戶能夠本身定義處理算法,應用到某個波段或者整個圖像中。波段運算實質上是對每一個像素點對應的的像素值進行數學運算,運算表達式中的每個變量不只能夠對應於單一波段,也能夠是一個多波段的柵格文件。例如,在表達式 b1﹢b2 中,若是 b1 是一個多波段的圖像, b2 爲單一波段,則結果爲 b1 所對應圖像的全部波段分別與 b2 進行求和。函數
PIE SDK支持算法功能的執行,下面對波段運算算法功能進行介紹。工具
第一步測試 |
算法參數設置編碼 |
第二步spa |
算法執行code |
第三步視頻 |
結果顯示blog |
C#算法DLL教程 |
PIE.CommonAlgo.dll |
|
C#算法名稱 |
PIE.CommonAlgo.BandOperAlgo |
|
參數結構體 |
BandOper_Exchange_Info |
|
參數說明 |
||
StrExp |
String |
波段運算公式,如"(b4-b3)/(b4+b3)"; |
SelectFileBands |
IList<Int> |
選中的圖像對應的波段band編號(是波段編號而非波段索引),根據波段運算公式的波段大小前後順序b三、b4肯定順序。new List<int> {3, 4} |
SelectFileNames |
IList<String> |
選中的圖像對應的文件file名稱,根據波段運算公式的波段大小前後順序b三、b4肯定順序。new List<String> {b3對應文件路徑, b4對應文件路徑} |
OutputFilePath |
String |
輸出文件路徑 |
FileTypeCode |
String |
根據輸出類型得到文件編碼類型 .tif/.tiff——GTiff .img—————HFA 其餘—————ENVI |
FuncName |
String |
C#算法名稱 |
PixelDataType |
int(針對不一樣的類型設置對應的編號) |
輸出數據類型: Byte8——1(編號)(字節型) UInt16——2 (整型16位) Int16——3 (無符號整型16位) UInt32——4 (長整型32位) Int32——5 (無符號長整型32位) Float32——6 (浮點型32位) Float64——7 (雙精度浮點型64位) |
項目路徑 |
百度雲盤地址下/PIE示例程序/10.算法調用/多功能工具/FundamentalToolDemo.BandOperDemo |
數據路徑 |
百度雲盤地址下/ PIE示例數據/柵格數據/04.World/World.tif |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/10.算法調用/多功能工具/波段運算算法.avi |
示例代碼 |
|
1 /// <summary> 2 /// 波段運算算法測試,本算法實現了將World.tif的波段3和波段2波做波段差獲得world3.tif 3 /// </summary> 4 public void BandOper() 5 { 6 #region 一、參數設置 7 PIE.CommonAlgo.BandOper_Exchange_Info info = new PIE.CommonAlgo.BandOper_Exchange_Info(); 8 info.StrExp = "b2-b1"; 9 info.SelectFileBands = new List<int> { 3,2 };//band3和band2 根據運算公式的波段大小前後順序肯定 b1的選擇波段就是3; 10 info.SelectFileNames = new List<string> { @"D:\data\China1\world\World.tif", @"D:\data\China1\world\World.tif" };//分別爲band3和band2數據路徑 11 info.OutputFilePath = @"D:\data\world3.tif"; 12 info.FileTypeCode = "GTiff"; 13 14 PIE.SystemAlgo.ISystemAlgo algo = PIE.SystemAlgo.AlgoFactory.Instance().CreateAlgo("PIE.CommonAlgo.dll", "PIE.CommonAlgo.BandOperAlgo"); 15 if (algo == null) return; 16 #endregion 17 18 //二、算法執行 19 PIE.SystemAlgo.ISystemAlgoEvents algoEvents = algo as PIE.SystemAlgo.ISystemAlgoEvents; 20 algo.Name = "波段運算"; 21 algo.Params = info; 22 23 //三、結果顯示 24 bool result = PIE.SystemAlgo.AlgoFactory.Instance().ExecuteAlgo(algo); 25 if (result) 26 { 27 MessageBox.Show("波段算法執行成功"); 28 ILayer layer = LayerFactory.CreateDefaultLayer(info.OutputFilePath); 29 if (layer == null) return; 30 m_HookHelper.ActiveView.FocusMap.AddLayer(layer); 31 m_HookHelper.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll); 32 } 33 } |