当前位置: 首页>>代码示例>>C++>>正文


C++ Tools::Interpolation方法代码示例

本文整理汇总了C++中Tools::Interpolation方法的典型用法代码示例。如果您正苦于以下问题:C++ Tools::Interpolation方法的具体用法?C++ Tools::Interpolation怎么用?C++ Tools::Interpolation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tools的用法示例。


在下文中一共展示了Tools::Interpolation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SpectralAngleMatrix

int32_t SpectralAngleMatrix(char* filepath2,char* filepath3,char* logfilepath, vector<int> bandlist, string interkind, vector<double>& SpectralAngleMatrix) {
    GDALDataset *poDataset2,*poDataset3;
    GDALAllRegister();
    poDataset2=(GDALDataset *)GDALOpen(filepath2,GA_ReadOnly);
    poDataset3=(GDALDataset *)GDALOpen(filepath3,GA_ReadOnly);
    if( (poDataset2 == NULL) || (poDataset3 == NULL)  ) {
        WriteMsg(logfilepath,-1,"Image file open error!");
        GDALClose(poDataset2);
        poDataset2=NULL;
        GDALClose(poDataset3);
        poDataset3=NULL;
        return -1;
    } else {
        WriteMsg(logfilepath,0,"SpectralAngleMatrix algorithm is executing!");
    }

    int32_t n,i,j;
    int32_t width2,height2;
    int32_t bandnum3,width3,height3;

    width2=poDataset2->GetRasterXSize();
    height2=poDataset2->GetRasterYSize();

    bandnum3=poDataset3->GetRasterCount();
    width3=poDataset3->GetRasterXSize();
    height3=poDataset3->GetRasterYSize();

    if(bandlist.size() != bandnum3) {
        GDALClose(poDataset2);
        poDataset2=NULL;
        GDALClose(poDataset3);
        poDataset3=NULL;
        WriteMsg(logfilepath, -1, "bandlist.size() != bandnum3 || width2 != width3 || height2 != height3");
        return -1;
    }
    GDALRasterBand *pband;
    float *banddata2,*banddata3;
    float *tempdata1,*tempdata2,*tempdata3;
    banddata2=(float*)CPLMalloc(sizeof(float)*width2*height2);
    banddata3=(float*)CPLMalloc(sizeof(float)*width3*height3);
    tempdata1=(float *)CPLMalloc(sizeof(float)*width3*height3);
    tempdata2=(float *)CPLMalloc(sizeof(float)*width3*height3);
    tempdata3=(float *)CPLMalloc(sizeof(float)*width3*height3);

    float* new_data = (float*)malloc(sizeof(float)*width3*height3);
    if(new_data == NULL) {
        GDALClose(poDataset2);
        poDataset2=NULL;
        GDALClose(poDataset3);
        poDataset3=NULL;
        WriteMsg(logfilepath, -1, "new_data malloc error !");
        return -1;
    }
    Tools obj;
    map<string, int> m_interalg;
    m_interalg["Nearest_1_0"]=1;
    m_interalg["Linear_1_0"]=2;
    m_interalg["CubicConv_1_0"]=3;

    for(n=0;n<bandnum3;n++) {
        pband=poDataset2->GetRasterBand(bandlist[n]);
        pband->RasterIO(GF_Read,0,0,width2,height2,banddata2,width2,height2,GDT_Float32,0,0);
        GDALClose(pband);
        pband=NULL;

        obj.Interpolation(banddata2,height2, width2, 1, new_data, height3, width3, m_interalg[interkind]);

        pband=poDataset3->GetRasterBand(n+1);
        pband->RasterIO(GF_Read,0,0,width3,height3,banddata3,width3,height3,GDT_Float32,0,0);
        GDALClose(pband);
        pband=NULL;

        int32_t tempnum2=0;
        int32_t tempnum3=0;

        for(i=0;i<height3;i++) {
            for(j=0;j<width3;j++) {
                if(n==0) {
                    tempdata1[i*width3+j]=0.0;
                    tempdata2[i*width3+j]=0.0;
                    tempdata3[i*width3+j]=0.0;
                }

                tempnum2=new_data[i*width2+j];
                tempnum3=banddata3[i*width3+j];
                if(tempnum2>0 && tempnum3>0) {
                    tempdata1[i*width3+j]=tempdata1[i*width3+j]+(1.0*tempnum2*tempnum3/bandnum3);
                    tempdata2[i*width3+j]=tempdata2[i*width3+j]+(1.0*tempnum2*tempnum2/bandnum3);
                    tempdata3[i*width3+j]=tempdata3[i*width3+j]+(1.0*tempnum3*tempnum3/bandnum3);
                }
            }
        }

        int32_t temp = (int)(100.0*(n+1)/bandnum3);
        temp = (temp>99) ? 99:temp;
        WriteMsg(logfilepath,temp,"SpectralAngleMatrix algorithm is executing!");
    }

    free(new_data);
    CPLFree(banddata2);
//.........这里部分代码省略.........
开发者ID:DengZhuangSouthRd,项目名称:FusionServer,代码行数:101,代码来源:spectralanglematrix.cpp


注:本文中的Tools::Interpolation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。