Click or drag to resize
XDL

XDMBandLocalWarp Class

참조 영상을 이용해서 정합점(입력영상 이미지 좌표-참조영상 이미지 좌표)을 생성하여 영상 정합을 수행한다.
Inheritance Hierarchy

Namespace:  Pixoneer.NXDL.NRSEX
Assembly:  NXDLrsEx (in NXDLrsEx.dll) Version: 2.0.3.30
Syntax
C#
public class XDMBandLocalWarp : XDMBand

The XDMBandLocalWarp type exposes the following members.

Constructors
  NameDescription
Public methodXDMBandLocalWarp
클래스의 기본 생성자로서, 멤버변수에 대하여 초기화를 수행한다.
Top
Methods
  NameDescription
Public methodGetInputParam
영상 정합을 위한 입력 파라미터를 얻는다.
Public methodPreprocess
정합점들로 Triangle을 생성하고 각 Triangle 에 대한 warping coeff (xr, yr) --> (xi, yi) 를 계산한다.
Public methodSetInputParam
영상 정합을 위한 입력 파라미터를 설정.
Top
Examples
This is example C# : 수동으로 생성한 GCP 를 이용하여 영상 정합 수행하는 예제
// IO initialize to load image file
XRasterIO RasterIO = new XRasterIO();
string strError = "";
if (RasterIO.Initialize(out strError) == false)
{
    return;
}

// Image load
string strFilePathLoad1 = @"G:\Sample\LocalWarp\photo.xdm";
string strFilePathLoad2 = @"G:\Sample\LocalWarp\Negaunee.xdm";
XRSLoadFile xrsFileSrc = RasterIO.LoadFile(strFilePathLoad1, out strError, false, eIOCreateXLDMode.All_NoMsg);
XRSLoadFile xrsFileRef = RasterIO.LoadFile(strFilePathLoad2, out strError, false, eIOCreateXLDMode.All_NoMsg);

XDMBand bandSrc = xrsFileSrc.GetBandAt(0);
XDMBand bandRef = xrsFileRef.GetBandAt(0);

XGCP gcp1 = new XGCP();
gcp1.imgCoord.x = 1998.2961;
gcp1.imgCoord.y = 158.6989;
gcp1.refCoord.x = 2534.2150;
gcp1.refCoord.y = 652.0193;

XGCP gcp2 = new XGCP();
gcp2.imgCoord.x = 1965.0028;
gcp2.imgCoord.y = 1744.6427;
gcp2.refCoord.x = 2470.1761;
gcp2.refCoord.y = 2276.2578;

XGCP gcp3 = new XGCP();
gcp3.imgCoord.x = 1893.5687;
gcp3.imgCoord.y = 565.8181;
gcp3.refCoord.x = 2419.3451;
gcp3.refCoord.y = 1068.6179;

XGCP gcp4 = new XGCP();
gcp4.imgCoord.x = 2660.0829;
gcp4.imgCoord.y = 774.2678;
gcp4.refCoord.x = 3180.2355;
gcp4.refCoord.y = 1278.0713;

XGCP gcp5 = new XGCP();
gcp5.imgCoord.x = 2509.6825;
gcp5.imgCoord.y = 886.4084;
gcp5.refCoord.x = 3026.7015;
gcp5.refCoord.y = 1389.7092;

XGCP gcp6 = new XGCP();
gcp6.imgCoord.x = 1956.8952;
gcp6.imgCoord.y = 896.9628;
gcp6.refCoord.x = 2479.6710;
gcp6.refCoord.y = 1408.6453;

XGCP gcp7 = new XGCP();
gcp7.imgCoord.x = 898.8155;
gcp7.imgCoord.y = 1232.0654;
gcp7.refCoord.x = 1418.3478;
gcp7.refCoord.y = 1759.7482;

XGCPSets gcpSets = new XGCPSets();
gcpSets.AddGCP(ref gcp1);
gcpSets.AddGCP(ref gcp2);
gcpSets.AddGCP(ref gcp3);
gcpSets.AddGCP(ref gcp4);
gcpSets.AddGCP(ref gcp6);
gcpSets.AddGCP(ref gcp7);

double minx = double.MaxValue;
double miny = double.MaxValue;
double maxx = double.MinValue;
double maxy = double.MinValue;
for (int i = 0; i < gcpSets.GetNumGCP(); i++)
{
    XGCP gcp = gcpSets.GetGCP(i);
    minx = gcp.refCoord.x < minx ? gcp.refCoord.x : minx;
    miny = gcp.refCoord.y < miny ? gcp.refCoord.y : miny;
    maxx = gcp.refCoord.x > maxx ? gcp.refCoord.x : maxx;
    maxy = gcp.refCoord.y > maxy ? gcp.refCoord.y : maxy;
}

double wminx = minx;
double wmaxx = maxx;
double wminy = maxy;
double wmaxy = miny;
bandRef.PixelToWorld(ref wminx, ref wminy);
bandRef.PixelToWorld(ref wmaxx, ref wmaxy);

double psx = 1.0;
double psy = 1.0;
XBandParamLocalWarp param = new XBandParamLocalWarp();
param.SrcBand = bandSrc;
param.RefBand = bandRef;
param.SR = bandRef.SR;
param.ResampleMethod = eResampleMethod.BiLinear;
param.GcpSets = gcpSets;
param.BlankValue = 0;
param.ULX = wminx;
param.ULY = wmaxy;
param.SizeX = (int)((wmaxx - wminx) / psx);
param.SizeY = (int)((wmaxy - wminy) / psy);
param.PixelSizeX = 1.0;
param.PixelSizeY = 1.0;

XDMBandLocalWarp bandLocalWarp = new XDMBandLocalWarp();
if (!bandLocalWarp.SetInputParam(ref param))
{
    return;
}

if (bandLocalWarp.Preprocess(null))
{
    // create XRSSaveFile to save realtime band(XDMBandXXXX)
    XRSSaveFile fileSave = new XRSSaveFile();
    XDMBand bandCast = (XDMBand)bandLocalWarp;

    fileSave.AddBand(ref bandCast);

    // Save output file
    String strFilePathSave = @"D:\Sample\localwarp.xdm";
    if (RasterIO.Export(ref fileSave, strFilePathSave, "XDM", out strError, null))
    {
        MessageBox.Show("성공");
        return;
    }
}
This is example C# : 자동으로 생성한 GCP 를 이용하여 영상 정합 수행하는 예제
// IO initialize to load image file
XRasterIO RasterIO = new XRasterIO();
string strError = "";
if (RasterIO.Initialize(out strError) == false)
{
    return;
}

// Image load
string strFilePathLoad1 = @"G:\Sample\LocalWarp\photo.xdm";
string strFilePathLoad2 = @"G:\Sample\LocalWarp\Negaunee.xdm";
XRSLoadFile xrsFileSrc = RasterIO.LoadFile(strFilePathLoad1, out strError, false, eIOCreateXLDMode.All_NoMsg);
XRSLoadFile xrsFileRef = RasterIO.LoadFile(strFilePathLoad2, out strError, false, eIOCreateXLDMode.All_NoMsg);

XDMBand bandSrc = xrsFileSrc.GetBandAt(0);
XDMBand bandRef = xrsFileRef.GetBandAt(0);

XGCP gcp1 = new XGCP();
gcp1.imgCoord.x = 1998.2961;
gcp1.imgCoord.y = 158.6989;
gcp1.refCoord.x = 2534.2150;
gcp1.refCoord.y = 652.0193;

XGCP gcp2 = new XGCP();
gcp2.imgCoord.x = 2442.2078;
gcp2.imgCoord.y = 1949.9519;
gcp2.refCoord.x = 2954.6654;
gcp2.refCoord.y = 2488.2819;

XGCP gcp3 = new XGCP();
gcp3.imgCoord.x = 1965.0028;
gcp3.imgCoord.y = 1744.6427;
gcp3.refCoord.x = 2470.1761;
gcp3.refCoord.y = 2276.2578;

XGCPSets gcpBaseSets = new XGCPSets();
gcpBaseSets.AddGCP(ref gcp1);
gcpBaseSets.AddGCP(ref gcp2);
gcpBaseSets.AddGCP(ref gcp3);

XGenPMAG genPMAG = new XGenPMAG();
genPMAG.KernelX = 25;
genPMAG.KernelY = 25;
genPMAG.KernelXCorrect = 50;
genPMAG.KernelYCorrect = 50;
genPMAG.NumXGrid = 20;
genPMAG.NumYGrid = 20;
genPMAG.CorrThreshold = 0.8;
genPMAG.IsForceEdgeMatching = true;
genPMAG.MaxIteration = 3;
genPMAG.SetImageBand(bandSrc);
genPMAG.SetReferenceBand(bandRef);
genPMAG.SetSearchRange(0, bandSrc.XSize - 1, 0, bandSrc.YSize - 1);
for (int i = 0; i < gcpBaseSets.GetNumGCP(); i++)
{
    XGCP gcp = gcpBaseSets.GetGCP(i);
    genPMAG.AddBaseGCP(gcp.imgCoord.x, gcp.imgCoord.y, gcp.refCoord.x, gcp.refCoord.y);
}

XGCPSets gcpSets = null;
if (!genPMAG.GenerateGCP(null))
{
    MessageBox.Show("Fail to generate auto gcp.");
    return;
}
else
{
    double xi, yi, xr, yr, corr;
    xi = yi = xr = yr = corr = 0.0;
    gcpSets = new XGCPSets();
    for (int i = 0; i < genPMAG.GetSize(); i++)
    {
        genPMAG.GetAt(i, ref xi, ref yi, ref xr, ref yr, ref corr);
        XGCP newGcp = new XGCP();
        newGcp.imgCoord.x = xi;
        newGcp.imgCoord.y = yi;

        newGcp.refCoord.x = xr;
        newGcp.refCoord.y = yr;
        gcpSets.AddGCP(ref newGcp);
    }
}

double minx = double.MaxValue;
double miny = double.MaxValue;
double maxx = double.MinValue;
double maxy = double.MinValue;
for (int i = 0; i < gcpSets.GetNumGCP(); i++)
{
    XGCP gcp = gcpSets.GetGCP(i);
    minx = gcp.refCoord.x < minx ? gcp.refCoord.x : minx;
    miny = gcp.refCoord.y < miny ? gcp.refCoord.y : miny;
    maxx = gcp.refCoord.x > maxx ? gcp.refCoord.x : maxx;
    maxy = gcp.refCoord.y > maxy ? gcp.refCoord.y : maxy;
}

double wminx = minx;
double wmaxx = maxx;
double wminy = maxy;
double wmaxy = miny;
bandRef.PixelToWorld(ref wminx, ref wminy);
bandRef.PixelToWorld(ref wmaxx, ref wmaxy);

double psx = 1.0;
double psy = 1.0;
XBandParamLocalWarp param = new XBandParamLocalWarp();
param.SrcBand = bandSrc;
param.RefBand = bandRef;
param.SR = bandRef.SR;
param.ResampleMethod = eResampleMethod.BiLinear;
param.GcpSets = gcpSets;
param.BlankValue = 0;
param.ULX = wminx;
param.ULY = wmaxy;
param.SizeX = (int)((wmaxx - wminx) / psx);
param.SizeY = (int)((wmaxy - wminy) / psy);
param.PixelSizeX = 1.0;
param.PixelSizeY = 1.0;

XDMBandLocalWarp bandLocalWarp = new XDMBandLocalWarp();
bandLocalWarp.SetInputParam(ref param);

if (bandLocalWarp.Preprocess(null))
{
    // create XRSSaveFile to save realtime band(XDMBandXXXX)
    XRSSaveFile fileSave = new XRSSaveFile();
    XDMBand bandCast = (XDMBand)bandLocalWarp;

    fileSave.AddBand(ref bandCast);

    // Save output file
    String strFilePathSave = @"D:\Sample\localwarp.xdm";
    if (RasterIO.Export(ref fileSave, strFilePathSave, "XDM", out strError, null))
    {
        MessageBox.Show("성공");
        return;
    }
}
See Also