增加采样工具

pull/10/head
陈增辉 2025-04-06 14:29:35 +08:00
parent 033db9e569
commit 5f7b8ae9ea
14 changed files with 475 additions and 16 deletions

View File

@ -15,6 +15,9 @@
/** 定义常见文件格式*********/
#define ENVI_FILE_FORMAT_FILTER u8"ALL File(*.*);;ENVI Bin(*.bin);;ENVI Data(*.dat);;ENVI Data(*.data);;tiff影像(*.tif);;tiff影像(*.tiff)"
#define XML_FILE_FORMAT_FILTER u8"ALL File(*.*);;XML File(*.xml);;tiff影像(*.tiff)"
//

View File

@ -16,7 +16,7 @@
#include <QDir>
#include <QFile>
#include <QDebug>
bool BASECONSTVARIABLEAPI isDirectory(const QString& path);
bool BASECONSTVARIABLEAPI isExists(const QString& path);
@ -29,7 +29,7 @@ unsigned long BASECONSTVARIABLEAPI convertToULong(const QString& input);
/// <param name="folderpath"></param>
/// <param name="FilenameExtension"></param>
/// <returns></returns>
std::vector<QString> BASECONSTVARIABLEAPI getFilelist(const QString& folderpath, const QString& FilenameExtension = ".*",int (*logfun)(QString logtext,int value)=nullptr);
std::vector<QString> BASECONSTVARIABLEAPI getFilelist(const QString& folderpath, const QString& FilenameExtension = ".*", int (*logfun)(QString logtext, int value) = nullptr);
QString BASECONSTVARIABLEAPI getParantFolderNameFromPath(const QString& path);
@ -41,11 +41,11 @@ QString BASECONSTVARIABLEAPI getFileExtension(QString path);
int BASECONSTVARIABLEAPI write_binfile(char* filepath, char* data, size_t data_len);
char* read_textfile(char* text_path, int* length);
char* read_textfile(char* text_path, int* length);
bool BASECONSTVARIABLEAPI exists_test(const QString& name);
bool BASECONSTVARIABLEAPI exists_test(const QString& name);
size_t BASECONSTVARIABLEAPI fsize(FILE* fp);
size_t BASECONSTVARIABLEAPI fsize(FILE* fp);
QString BASECONSTVARIABLEAPI getParantFromPath(const QString& path);
void BASECONSTVARIABLEAPI copyFile(const QString& sourcePath, const QString& destinationPath);

View File

@ -135,10 +135,10 @@ GDALDataType BASECONSTVARIABLEAPI getGDALDataType(QString fileptah);
struct RasterExtend {
double min_x; //纬度
double min_y;//经度
double max_x;//纬度
double max_y;//经度
double min_x;
double min_y;
double max_x;
double max_y;
};

View File

@ -1228,8 +1228,8 @@ RasterExtend gdalImage::getExtend()
double x1 = this->gt(0, 0);
double y1 = this->gt(1, 0);
double x2 = this->gt(0, 0) + (this->width - 1) * gt(0, 1) + (0) * gt(0, 2);
double y2 = this->gt(1, 0) + (this->width - 1) * gt(1, 1) + (0) * gt(1, 2);
double x2 = this->gt(0, 0) + (this->width - 1) * gt(0, 1) + (0) * gt(0, 2); // ¾­
double y2 = this->gt(1, 0) + (this->width - 1) * gt(1, 1) + (0) * gt(1, 2); // γ
double x3 = this->gt(0, 0) + (0) * gt(0, 1) + (this->height - 1) * gt(0, 2);
double y3 = this->gt(1, 0) + (0) * gt(1, 1) + (this->height - 1) * gt(1, 2);

View File

@ -5,6 +5,7 @@
#include "ImageOperatorBase.h"
#include "GPUBaseTool.h"
#include "GPUBPImageNet.cuh"
#include "BaseTool.h"
void InitCreateImageXYZProcess(QString& outImageLLPath, QString& outImageXYZPath, QString& InEchoGPSDataPath,
@ -171,3 +172,120 @@ void InitCreateImageXYZProcess(QString& outImageLLPath, QString& outImageXYZPath
qDebug() << u8"6.保存成像网格结果";
qDebug() << "---------------------------------------------------------------------------------";
}
bool OverlapCheck(QString& ImageLLPath, QString& ImageDEMPath)
{
// 检查DEM是否是WGS84坐标系
long demEPSG = GetEPSGFromRasterFile(ImageDEMPath);
if (demEPSG != 4326) {
qDebug() << u8"DEM坐标系不是WGS84坐标系";
return false;
}
gdalImage demimg(ImageDEMPath);
gdalImage imgll(ImageLLPath);
long imgheight = imgll.height;
long imgwidth = imgll.width;
Eigen::MatrixXd imglonArr = imgll.getData(0, 0, imgheight, imgwidth, 1);
Eigen::MatrixXd imglatArr = imgll.getData(0, 0, imgheight, imgwidth, 2);
for (long i = 0; i < imgheight; i++)
{
for (long j = 0; j < imgwidth; j++)
{
double lon = imglonArr(i, j); // X
double lat = imglatArr(i, j); // Y
Landpoint point = imgll.getRow_Col(lon, lat);
imglonArr(i, j) = point.lon;
imglatArr(i, j) = point.lat;
}
}
double minX = imglonArr.minCoeff();
double maxX = imglonArr.maxCoeff();
double minY = imglatArr.minCoeff();
double maxY = imglatArr.maxCoeff();
if (minX<1 || maxX>demimg.width - 1 || minY<1 || maxY>demimg.height - 1) {
return false;
}
else {
return true;
}
}
void InterploateAtiByRefDEM(QString& ImageLLPath, QString& ImageDEMPath, QString& outImageLLAPath)
{
gdalImage demimg(ImageDEMPath);
gdalImage imgll(ImageLLPath);
gdalImage outimgll = CreategdalImageDouble(outImageLLAPath, imgll.height, imgll.width, 3, true, true);
long imgheight = imgll.height;
long imgwidth = imgll.width;
Eigen::MatrixXd imglonArr = imgll.getData(0, 0, imgheight, imgwidth, 1);
Eigen::MatrixXd imglatArr = imgll.getData(0, 0, imgheight, imgwidth, 2);
Eigen::MatrixXd imgatiArr = Eigen::MatrixXd::Zero(imgheight, imgwidth);
outimgll.saveImage(imglonArr, 0, 0, 1);
outimgll.saveImage(imglatArr, 0, 0, 2);
for (long i = 0; i < imgheight; i++) {
for (long j = 0; j < imgwidth; j++) {
double lon = imglonArr(i, j); // X
double lat = imglatArr(i, j); // Y
Landpoint point = imgll.getRow_Col(lon, lat);
imglonArr(i, j) = point.lon;
imglatArr(i, j) = point.lat;
}
}
for (long i = 0; i < imgheight; i++) {
for (long j = 0; j < imgwidth; j++) {
double imX = imglonArr(i, j);
double imY = imglatArr(i, j);
Landpoint p0, p11, p21, p12, p22;
p0.lon = imX;
p0.lat = imY;
p11.lon = floor(p0.lon);
p11.lat = floor(p0.lat);
p12.lon = ceil(p0.lon);
p12.lat = floor(p0.lat);
p21.lon = floor(p0.lon);
p21.lat = ceil(p0.lat);
p22.lon = ceil(p0.lon);
p22.lat = ceil(p0.lat);
p0.lon = p0.lon - p11.lon;
p0.lat = p0.lat - p11.lat;
p12.lon = p12.lon - p11.lon;
p12.lat = p12.lat - p11.lat;
p21.lon = p21.lon - p11.lon;
p21.lat = p21.lat - p11.lat;
p22.lon = p22.lon - p11.lon;
p22.lat = p22.lat - p11.lat;
p11.lon = p11.lon - p11.lon;
p11.lat = p11.lat - p11.lat;
Bilinear_interpolation(p0, p11, p21, p12, p22);
imgatiArr(i, j) = p0.ati;
}
}
outimgll.saveImage(imgatiArr, 0, 0, 3);
qDebug() << u8"插值完成";
}

View File

@ -7,9 +7,9 @@
void InitCreateImageXYZProcess(QString& outImageLLPath, QString& outImageXYZPath, QString& InEchoGPSDataPath, double& NearRange, double& RangeResolution, int64_t& RangeNum);
bool OverlapCheck(QString& ImageLLPath, QString& ImageDEMPath);
void InterploateAtiByRefDEM(QString& ImageLLPath, QString& ImageDEMPath, QString& outImageLLAPath);

View File

@ -0,0 +1,112 @@
#include "ImagePlaneAtiInterpDialog.h"
#include "ui_ImagePlaneAtiInterpDialog.h"
#include <QFileDialog>
#include <QMessageBox>
#include "BaseConstVariable.h"
#include "ImageNetOperator.h"
ImagePlaneAtiInterpDialog::ImagePlaneAtiInterpDialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::ImagePlaneAtiInterpDialogClass)
{
ui->setupUi(this);
connect(ui->pushButtonImageLLASelect, SIGNAL(clicked()), this, SLOT(onpushButtonImageLLASelect_clicked()));
connect(ui->pushButtonImageNet0Select, SIGNAL(clicked()), this, SLOT(onpushButtonImageNet0Select_clicked()));
connect(ui->pushButtonRefRangeDEMSelect, SIGNAL(clicked()), this, SLOT(onpushButtonRefRangeDEMSelect_clicked()));
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(onbuttonBoxAccepted()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(onbuttonBoxRejected()));
}
ImagePlaneAtiInterpDialog::~ImagePlaneAtiInterpDialog()
{}
void ImagePlaneAtiInterpDialog::onpushButtonImageNet0Select_clicked()
{
QString fileNames = QFileDialog::getOpenFileName(
this,
tr(u8"选择成像粗平面文件"),
QString(),
tr(ENVI_FILE_FORMAT_FILTER)
);
if (!fileNames.isEmpty()) {
QString message = "选中文件\n";
this->ui->lineEditImageNet0Path->setText(fileNames);
}
else {
QMessageBox::information(this, tr(u8"提示"), tr(u8"没有选中文件"));
}
}
void ImagePlaneAtiInterpDialog::onpushButtonRefRangeDEMSelect_clicked()
{
QString fileNames = QFileDialog::getOpenFileName(
this, // ??????
tr(u8"选择参考DEM"), // ????
QString(), // ???·??
tr(ENVI_FILE_FORMAT_FILTER) // ?????????
);
// ??????????????
if (!fileNames.isEmpty()) {
QString message = "选中文件\n";
this->ui->lineEditRefRangeDEMPath->setText(fileNames);
}
else {
QMessageBox::information(this, tr(u8"提示"), tr(u8"没有选中文件"));
}
}
void ImagePlaneAtiInterpDialog::onpushButtonImageLLASelect_clicked()
{
QString fileNames = QFileDialog::getOpenFileName(
this, // ??????
tr(u8"提示"), // ????
QString(), // ???·??
tr(ENVI_FILE_FORMAT_FILTER) // ?????????
);
// ??????????????
if (!fileNames.isEmpty()) {
QString message = "????????У?\n";
this->ui->lineEditImageLLAPath->setText(fileNames);
}
else {
QMessageBox::information(this, tr(u8"提示"), tr(u8"没有选中文件"));
}
}
void ImagePlaneAtiInterpDialog::onbuttonBoxAccepted()
{
QString imageNet0Path = this->ui->lineEditImageNet0Path->text().trimmed();
QString refRangeDEMPath = this->ui->lineEditRefRangeDEMPath->text().trimmed();
QString imageLLAPath = this->ui->lineEditImageLLAPath->text().trimmed();
if (imageNet0Path.isEmpty() || refRangeDEMPath.isEmpty() || imageLLAPath.isEmpty()) {
QMessageBox::warning(this, tr(u8"提示"), tr(u8"没有选中文件"));
return;
}
else {
}
if (OverlapCheck(imageNet0Path, refRangeDEMPath)) { // ????DEM???
InterploateAtiByRefDEM(imageNet0Path, refRangeDEMPath, imageLLAPath);
QMessageBox::information(nullptr, u8"提示", u8"completed!!");
return;
}
else {
QMessageBox::warning(nullptr,u8"警告",u8"DEM影像小于成像粗平面采样要求");
return;
}
}
void ImagePlaneAtiInterpDialog::onbuttonBoxRejected()
{
this->close();
}

View File

@ -0,0 +1,35 @@
#pragma once
#ifndef __ImagePlaneAtiInterpDialog__HH__
#define __ImagePlaneAtiInterpDialog__HH__
#include <QDialog>
namespace Ui {
class ImagePlaneAtiInterpDialogClass;
}
class ImagePlaneAtiInterpDialog : public QDialog
{
Q_OBJECT
public:
ImagePlaneAtiInterpDialog(QWidget *parent = nullptr);
~ImagePlaneAtiInterpDialog();
public /*slots*/:
void onpushButtonImageNet0Select_clicked();
void onpushButtonRefRangeDEMSelect_clicked();
void onpushButtonImageLLASelect_clicked();
void onbuttonBoxAccepted();
void onbuttonBoxRejected();
private:
Ui::ImagePlaneAtiInterpDialogClass* ui;
};
#endif

View File

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImagePlaneAtiInterpDialogClass</class>
<widget class="QDialog" name="ImagePlaneAtiInterpDialogClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>661</width>
<height>266</height>
</rect>
</property>
<property name="windowTitle">
<string>根据经纬度插值高程数据</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>成像网格(经纬度):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditImageNet0Path">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButtonImageNet0Select">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>参考DEM</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditRefRangeDEMPath">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButtonRefRangeDEMSelect">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>成像粗网格(高程):</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditImageLLAPath">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButtonImageLLASelect">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
<height>403</height>
</rect>
</property>
<property name="windowTitle">
@ -155,7 +155,7 @@
<x>0</x>
<y>0</y>
<width>580</width>
<height>236</height>
<height>239</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">

View File

@ -8,6 +8,8 @@
#include "QtSimulationGeoSARSigma0Dialog.h"
#include "QtLinearToIntenisityDialog.h"
#include "InitCreateImageXYZDialog.h"
#include "ImagePlaneAtiInterpDialog.h"
SARSimlulationRFPCToolButton::SARSimlulationRFPCToolButton(QWidget* parent)
{
@ -77,6 +79,7 @@ void RegisterPreToolBox(LAMPMainWidget::RasterMainWidget* mainwindows, ToolBoxWi
emit toolbox->addBoxToolItemSIGNAL(new QtSimulationGeoSARSigma0ToolButton(toolbox));
emit toolbox->addBoxToolItemSIGNAL(new QtLinearToIntenisityToolButton(toolbox));
emit toolbox->addBoxToolItemSIGNAL(new InitCreateImageXYZToolButton(toolbox));
emit toolbox->addBoxToolItemSIGNAL(new ImagePlaneAtiInterpToolButton(toolbox));
}
@ -163,4 +166,18 @@ void InitCreateImageXYZToolButton::run()
dialog->show();
}
ImagePlaneAtiInterpToolButton::ImagePlaneAtiInterpToolButton(QWidget* parent)
{
this->toolPath = QVector<QString>(0);
this->toolPath.push_back(u8"³ÉÏñ¹¤¾ß¿â");
this->toolname = QString(u8"2.´ÖÆ½ÃæÓ³ÉäDEM");
}
ImagePlaneAtiInterpToolButton::~ImagePlaneAtiInterpToolButton()
{
}
void ImagePlaneAtiInterpToolButton::run()
{
ImagePlaneAtiInterpDialog* dialog = new ImagePlaneAtiInterpDialog;
dialog->show();
}

View File

@ -109,6 +109,16 @@ public :
};
class SIMULATIONSARTOOL_EXPORT ImagePlaneAtiInterpToolButton : public QToolAbstract {
Q_OBJECT
public:
ImagePlaneAtiInterpToolButton(QWidget* parent = nullptr);
~ImagePlaneAtiInterpToolButton();
public:
virtual void run() override;
};
extern "C" SIMULATIONSARTOOL_EXPORT void RegisterPreToolBox(LAMPMainWidget::RasterMainWidget* mainwindows, ToolBoxWidget* toolbox);

View File

@ -215,6 +215,7 @@
<ClCompile Include="PowerSimulationIncoherent\QtLinearToIntenisityDialog.cpp" />
<ClCompile Include="PowerSimulationIncoherent\QtSimulationGeoSARSigma0Dialog.cpp" />
<ClCompile Include="SARImage\ImageNetOperator.cpp" />
<ClCompile Include="SARImage\ImagePlaneAtiInterpDialog.cpp" />
<ClCompile Include="SARImage\InitCreateImageXYZDialog.cpp" />
<ClCompile Include="SimulationSAR\QImageSARRFPC.cpp" />
<ClCompile Include="SimulationSAR\QSARLookTableSimualtionGUI.cpp" />
@ -243,6 +244,7 @@
<QtMoc Include="SARImage\InitCreateImageXYZDialog.h" />
<ClInclude Include="SARImage\GPUBPImageNet.cuh" />
<ClInclude Include="SARImage\ImageNetOperator.h" />
<ClInclude Include="SARImage\ImagePlaneAtiInterpDialog.h" />
<ClInclude Include="SimulationSARToolAPI.h" />
<ClInclude Include="simulationsartool_global.h" />
<QtMoc Include="SimulationSAR\QImageSARRFPC.h" />
@ -277,6 +279,7 @@
<QtUic Include="PowerSimulationIncoherent\QSimulationSARPolynomialOrbitModel.ui" />
<QtUic Include="PowerSimulationIncoherent\QtLinearToIntenisityDialog.ui" />
<QtUic Include="PowerSimulationIncoherent\QtSimulationGeoSARSigma0Dialog.ui" />
<QtUic Include="SARImage\ImagePlaneAtiInterpDialog.ui" />
<QtUic Include="SARImage\InitCreateImageXYZDialog.ui" />
<QtUic Include="SimulationSAR\QImageSARRFPC.ui" />
<QtUic Include="SimulationSAR\QSARLookTableSimualtionGUI.ui" />

View File

@ -80,6 +80,9 @@
<ClInclude Include="SARImage\GPUBPImageNet.cuh">
<Filter>SARImage</Filter>
</ClInclude>
<ClInclude Include="SARImage\ImagePlaneAtiInterpDialog.h">
<Filter>SARImage</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SimulationSAR\QImageSARRFPC.cpp">
@ -139,6 +142,9 @@
<ClCompile Include="SARImage\ImageNetOperator.cpp">
<Filter>SARImage</Filter>
</ClCompile>
<ClCompile Include="SARImage\ImagePlaneAtiInterpDialog.cpp">
<Filter>SARImage</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtUic Include="SimulationSAR\QImageSARRFPC.ui">
@ -171,6 +177,9 @@
<QtUic Include="SARImage\InitCreateImageXYZDialog.ui">
<Filter>SARImage</Filter>
</QtUic>
<QtUic Include="SARImage\ImagePlaneAtiInterpDialog.ui">
<Filter>SARImage</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<QtMoc Include="SimulationSAR\QImageSARRFPC.h">