PIE SDK PCA融合
1.算法功能简介
PCA 融合分三步实现,首先将多光谱数据进行主成分变换,然后用高分辨单波段替换第一主成分波段,最后进行主成份逆变换得到融合图像。
PIE支持算法功能的执行,下面对PCA融合算法功能进行介绍。
2.算法功能实现说明
2.1. 实现步骤
第一步 |
算法参数设置 |
第二步 |
算法执行 |
第三步 |
结果显示 |
2.2. 算法参数
算法名称 |
PCA融合 |
|
C#算法DLL |
PIE.CommonAlgo.dll |
|
C#算法名称 |
PIE.CommonAlgo.PansharpFuseAlgo |
|
参数结构体 |
Pansharp_Exchange_Info |
|
参数说明 |
||
PanFilePath |
String |
输入高分辨率数据路径 |
MssFilePath |
String |
输入多光谱数据路径 |
MULChannels |
IList<int> |
输入的多光谱数据波段集合{0,1,2,3} |
HighChannel |
Int |
融合选择的高分辨率数据波段 |
OutputFilePath |
String |
输出文件 (*.tif;*.tiff; *.img) |
FileTypeCode |
String |
根据输出类型获得文件编码类型 .tif/.tiff——GTiff .img—————HFA 其他—————ENVI |
ResampleMode |
Int |
重采样类型 (最近邻点插值0/双线性插值1/三次卷积法插值2) |
AlgoType |
Int |
融合类型 0代表pca融合 、1代表pansharp 融合 |
FuncName |
String |
功能名称 |
BMultiThread |
Bool |
是否多线程(true) TRUE 是; FALSE 否 |
2.3. 示例代码
项目路径 |
百度云盘地址下/PIE示例程序/ 10.算法调用/图像预处理/PIE.ImagePreprocessing. PansharpFuseAlgo |
数据路径 |
百度云盘地址下/PIE示例数据/栅格数据/01.GF1/PAN.tif ;MS.tif |
视频路径 |
百度云盘地址下/PIE视频教程/10.算法调用/图像预处理/ PCA融合算法.avi |
示例代码 |
|
![]() 1 /// <summary> 2 ///PCA融合算法测试,本算法实现了将PAN.tif和MS.tif进行最近邻域法PCA融合 3 /// </summary> 4 public override void OnClick() 5 { 6 #region 1、参数设置 7 PIE.CommonAlgo.Pansharp_Exchange_Info info = new PIE.CommonAlgo.Pansharp_Exchange_Info(); 8 9 info.PanFilePath = @"D:\Data\PAN.tif"; 10 info.MssFilePath = @"D:\Data\MS.tif"; 11 info.MULChannels = new List<int> { 0, 1, 2 }; 12 info.HighChannel = 0; 13 info.OutputFilePath = @"D:\Data\result8.tif"; 14 info.FileTypeCode = "Gtiff"; 15 info.ResampleMode = 0; 16 info.AlgoType = 0; //PCA融合 17 //info.AlgoType = 1; //pansharp 融合 18 info.BMultiThread = true; 19 20 PIE.SystemAlgo.ISystemAlgo algo = PIE.SystemAlgo.AlgoFactory.Instance().CreateAlgo("PIE.CommonAlgo.dll", "PIE.CommonAlgo.PansharpFuseAlgo"); 21 if (algo == null) return; 22 #endregion 23 24 //2、算法执行 25 PIE.SystemAlgo.ISystemAlgoEvents algoEvents = algo as PIE.SystemAlgo.ISystemAlgoEvents; 26 algo.Name = "PCA融合"; 27 algo.Params = info; 28 algo.Params = info; 29 (algo as PIE.SystemAlgo.ISystemAlgoEvents).OnExecuteCompleted +=PansharpFuseAlgo_OnExecuteCompleted; 30 (algo as PIE.SystemAlgo.ISystemAlgoEvents).OnProgressChanged += PansharpFuseAlgo_OnProgressChanged; 31 32 PIE.AxControls.IStatusBar statusBar = m_Application.StatusBar; 33 statusBar.ShowProgress(0, 100, ""); 34 PIE.SystemAlgo.AlgoFactory.Instance().AsynExecuteAlgo(algo); 35 } 36 int PansharpFuseAlgo_OnProgressChanged(double complete, string msg, SystemAlgo.ISystemAlgo algo) 37 { 38 PIE.AxControls.IStatusBar statusBar = m_Application.StatusBar; 39 statusBar.UpdateProgress((int)complete, msg); 40 return 0; 41 } 42 43 void PansharpFuseAlgo_OnExecuteCompleted(SystemAlgo.ISystemAlgo algo) 44 { 45 PIE.AxControls.IStatusBar statusBar = m_Application.StatusBar; 46 statusBar.UpdateProgress(100, ""); 47 statusBar.HideProgress(); 48 //3、结果显示 49 ILayer layer = PIE.Carto.LayerFactory.CreateDefaultLayer(@"D:\Data\result8.tif"); 50 m_HookHelper.ActiveView.FocusMap.AddLayer(layer); m_HookHelper.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll); m_HookHelper.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll); 51 (algo as PIE.SystemAlgo.ISystemAlgoEvents).OnExecuteCompleted -= PansharpFuseAlgo_OnExecuteCompleted; 52 (algo as PIE.SystemAlgo.ISystemAlgoEvents).OnProgressChanged -= PansharpFuseAlgo_OnProgressChanged; 53 } |
2.4.示例截图