資源簡介
利用GDAL、OPENCV,GA對遙感圖像三波段組合進(jìn)行檢索,找到最有的組合。

代碼片段和文件信息
#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?????????{
????????????????genotype?geno;
????????????????for(int?j?=?0;?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
- 上一篇:prolog waterjugs.pl
- 下一篇:CP重構(gòu)代碼
評論
共有 條評論