• 大小: 6KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-04
  • 语言: 其他
  • 标签:

资源简介

利用GDAL、OPENCV,GA对遥感图像三波段组合进行检索,找到最有的组合。

资源截图

代码片段和文件信息

#include “ga_dlg.h“
#include “ui_ga_dlg.h“
#include “individual.h“

GA_Dlg::GA_Dlg(QWidget *parent) :
    QDialog(parent)
    ui(new Ui::GA_Dlg)
{
    ui->setupUi(this);
}

GA_Dlg::~GA_Dlg()
{
    delete ui;
}


population_type GA_Dlg::install_population()
{
        population_type r;

        for(int i = 0; i < population_size; i++)
        {
                genotype geno;
                for(int j = 0; j < gene_num; j++)
                {
                    int rdm=rand()/(double) RAND_MAX *bands_num;
                    int in_rdm=index[rdm];
                    geno.push_back(in_rdm);
                }
                individual ind(geno);
                int match=evaluate_individual(ind);
                ind.set_fitness(match);
                r.push_back(ind);
        }
        return r;
}

int GA_Dlg::evaluate_individual(individual ind)
{
    if(poDataset==NULL)
    {
    ui->errorlabel->setText(“NO IMAGE“);
    }

   genotype genes=ind.get_genes();

   CvMat *pTrain=cvCreateMat(4003CV_32FC1);
   CvMat *pClass=cvCreateMat(4001CV_32FC1);
   CvMat *pResult=cvCreateMat(4001CV_32FC1);

   int *buffer;
   buffer=(int *)CPLMalloc(sizeof(int));

   GDALRasterBand *poBand;

   int ele_index = 0;

   for(int y=0;y<10;y++)
       {
        for(int x=0;x<20;x++)
           {
               poBand=poDataset->GetRasterBand(genes[0]);
               poBand->RasterIO(GF_ReadROIX+xROIY+y11buffer11GDT_UInt3200);
               CV_MAT_ELEM(*pTrainfloatele_index0)=*buffer;

               poBand=poDataset->GetRasterBand(genes[1]);
               poBand->RasterIO(GF_ReadROIX+xROIY+y11buffer11GDT_UInt3200);
               CV_MAT_ELEM(*pTrainfloatele_index1)=*buffer;


               poBand=poDataset->GetRasterBand(genes[2]);
               poBand->RasterIO(GF_ReadROIX+xROIY+y11buffer11GDT_UInt3200);
               CV_MAT_ELEM(*pTrainfloatele_index2)=*buffer;

               ele_index++;
               }
       }


       for(int yy=0;yy<10;yy++)
       {
           for(int xx=0;xx<20;xx++)
           {
                   poBand=poDataset->GetRasterBand(genes[0]);
                   poBand->RasterIO(GF_ReadOTHX+xxOTHY+yy11buffer11GDT_UInt3200);
                   CV_MAT_ELEM(*pTrainfloatele_index0)=*buffer;

                   poBand=poDataset->GetRasterBand(genes[1]);
                   poBand->RasterIO(GF_ReadOTHX+xxOTHY+yy11buffer11GDT_UInt3200);
                   CV_MAT_ELEM(*pTrainfloatele_index1)=*buffer;

                   poBand=poDataset->GetRasterBand(genes[2]);
                   poBand->RasterIO(GF_ReadOTHX+xxOTHY+yy11buffer11GDT_UInt3200);
                   CV_MAT_ELEM(*pTrainfloatele_index2)=*buffer;
                   ele_index++;
               }

       }




    for(int i=0;i<200;i++)
   {
       CV_MAT_ELEM(*pClassfloati0)=0;
   }
   for(int i=200;i<400;i++)
   {
       CV_MAT_ELEM(*pClassfloati0)=1;
   }

   CvNormalBayesClassifier bayes;
   bayes

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2011-09-15 10:35  GA_test\
     文件        9270  2011-05-26 15:41  GA_test\ga_dlg.cpp
     文件        1359  2011-05-26 15:11  GA_test\ga_dlg.h
     文件        5118  2011-05-26 15:41  GA_test\ga_dlg.ui
     文件         457  2011-05-23 18:16  GA_test\GA_test.pro
     文件       13507  2011-05-26 15:41  GA_test\GA_test.pro.user
     文件         673  2011-05-26 14:06  GA_test\individual.cpp
     文件         603  2011-05-26 13:28  GA_test\individual.h
     文件         170  2011-05-23 18:13  GA_test\main.cpp

评论

共有 条评论

相关资源