同步修改---增加成像范围自动裁剪功能
parent
357cf2ec66
commit
9df7c8b1a0
|
@ -17,7 +17,6 @@ QLookTableResampleFromWGS84ToRange::QLookTableResampleFromWGS84ToRange(QWidget *
|
|||
connect(ui->pushButtonLookTableWGS84Select, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableWGS84SelectClicked(bool)));
|
||||
connect(ui->pushButtonLookTableRangeSelect, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableRangeSelectClicked(bool)));
|
||||
connect(ui->pushButtonLookTableCountSelect, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableCountSelectClicked(bool)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -286,7 +286,6 @@ void InterploateAtiByRefDEM(QString& ImageLLPath, QString& ImageDEMPath, QString
|
|||
qDebug() << u8"ͼÏñÐÐÁУº\t" << demimg.height << " , " << demimg.width;
|
||||
|
||||
|
||||
|
||||
for (long i = 0; i < imgheight; i++) {
|
||||
//printf("\rprocess:%f precent\t\t\t",i*100.0/imgheight);
|
||||
for (long j = 0; j < imgwidth; j++) {
|
||||
|
@ -416,6 +415,231 @@ void InterploateAtiByRefDEM(QString& ImageLLPath, QString& ImageDEMPath, QString
|
|||
}
|
||||
|
||||
|
||||
void InterploateClipAtiByRefDEM(QString ImageLLPath, QString& ImageDEMPath, QString& outImageLLAPath, QString& InEchoGPSDataPath) {
|
||||
|
||||
gdalImage demimg(ImageDEMPath);
|
||||
gdalImage imgll(ImageLLPath);
|
||||
|
||||
// 裁剪
|
||||
long imgheight = imgll.height;
|
||||
long imgwidth = imgll.width;
|
||||
|
||||
long minRow = -1;
|
||||
long maxRow = imgheight;
|
||||
long minCol = -1;
|
||||
long maxCol = imgwidth;
|
||||
|
||||
|
||||
Eigen::MatrixXd imglonArr = imgll.getData(0, 0, imgheight, imgwidth, 1);
|
||||
Eigen::MatrixXd imglatArr = imgll.getData(0, 0, imgheight, imgwidth, 2);
|
||||
|
||||
#pragma omp parallel for
|
||||
for (long i = 0; i < imgheight; i++) {
|
||||
for (long j = 0; j < imgwidth; j++) {
|
||||
double lon = imglonArr(i, j);
|
||||
double lat = imglatArr(i, j);
|
||||
Landpoint point = demimg.getRow_Col(lon, lat);
|
||||
imglonArr(i, j) = point.lon;
|
||||
imglatArr(i, j) = point.lat;
|
||||
}
|
||||
}
|
||||
|
||||
// 开始逐行扫描
|
||||
|
||||
bool minRowFlag=true, maxRowFlag= true, minColFlag = true, maxColFlag = true;
|
||||
|
||||
for (long i = 0; i < imgheight; i++) {
|
||||
for (long j = 0; j < imgwidth; j++) {
|
||||
if (imglonArr(i, j) > 0 && minRowFlag) {
|
||||
minRowFlag = false;
|
||||
minRow = i;
|
||||
break;
|
||||
}
|
||||
if (imglonArr(i, j) < imgheight) {
|
||||
maxRow = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (long j = 0; j < imgwidth; j++) {
|
||||
for (long i = 0; i < imgheight; i++) {
|
||||
if (imglatArr(i, j) > 0 && minColFlag) {
|
||||
minColFlag = false;
|
||||
minCol = j;
|
||||
break;
|
||||
}
|
||||
if (imglatArr(i, j) < imgheight) {
|
||||
maxCol = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
long RowCount = maxRow - minRow;
|
||||
long ColCount = maxCol - minCol;
|
||||
|
||||
gdalImage outimgll = CreategdalImageDouble(outImageLLAPath, RowCount, ColCount, 4, true, true); // 经度、纬度、高程、斜距
|
||||
|
||||
long imgheight = outimgll.height;
|
||||
long imgwidth = outimgll.width;
|
||||
|
||||
Eigen::MatrixXd imglonArr = imgll.getData(minRow, minCol, RowCount, ColCount, 1);
|
||||
Eigen::MatrixXd imglatArr = imgll.getData(minRow, minCol, RowCount, ColCount, 2);
|
||||
|
||||
Eigen::MatrixXd demArr = demimg.getData(0, 0, demimg.height, demimg.width, 1);
|
||||
|
||||
Eigen::MatrixXd imgatiArr = Eigen::MatrixXd::Zero(imgheight, imgwidth);
|
||||
Eigen::MatrixXd imgRArr = Eigen::MatrixXd::Zero(imgheight, imgwidth);
|
||||
|
||||
outimgll.saveImage(imglonArr, 0, 0, 1);
|
||||
outimgll.saveImage(imglatArr, 0, 0, 2);
|
||||
|
||||
|
||||
double minX = imglonArr.minCoeff();
|
||||
double maxX = imglonArr.maxCoeff();
|
||||
double minY = imglatArr.minCoeff();
|
||||
double maxY = imglatArr.maxCoeff();
|
||||
|
||||
//打印范围
|
||||
qDebug() << u8"dem 的范围:";
|
||||
qDebug() << u8"minX:" << minX << "\t" << demimg.width;
|
||||
qDebug() << u8"maxX:" << maxX << "\t" << demimg.width;
|
||||
qDebug() << u8"minY:" << minY << "\t" << demimg.height;
|
||||
qDebug() << u8"maxY:" << maxY << "\t" << demimg.height;
|
||||
qDebug() << u8"图像行列:\t" << demimg.height << " , " << demimg.width;
|
||||
|
||||
|
||||
for (long i = 0; i < imgheight; i++) {
|
||||
//printf("\rprocess:%f precent\t\t\t",i*100.0/imgheight);
|
||||
for (long j = 0; j < imgwidth; j++) {
|
||||
double lon = imglonArr(i, j);
|
||||
double lat = imglatArr(i, j);
|
||||
Landpoint point = demimg.getRow_Col(lon, lat);
|
||||
|
||||
if (point.lon<1 || point.lon>demimg.width - 2 || point.lat < 1 || point.lat - 2) {
|
||||
continue;
|
||||
}
|
||||
else {}
|
||||
|
||||
Landpoint p0, p11, p21, p12, p22;
|
||||
|
||||
p0.lon = point.lon;
|
||||
p0.lat = point.lat;
|
||||
|
||||
p11.lon = floor(p0.lon);
|
||||
p11.lat = floor(p0.lat);
|
||||
p11.ati = demArr(long(p11.lat), long(p11.lon));
|
||||
|
||||
p12.lon = ceil(p0.lon);
|
||||
p12.lat = floor(p0.lat);
|
||||
p12.ati = demArr(long(p12.lat), long(p12.lon));
|
||||
|
||||
p21.lon = floor(p0.lon);
|
||||
p21.lat = ceil(p0.lat);
|
||||
p21.ati = demArr(long(p21.lat), long(p21.lon));
|
||||
|
||||
p22.lon = ceil(p0.lon);
|
||||
p22.lat = ceil(p0.lat);
|
||||
p22.ati = demArr(long(p22.lat), long(p22.lon));
|
||||
|
||||
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;
|
||||
|
||||
p0.ati = Bilinear_interpolation(p0, p11, p21, p12, p22);
|
||||
imgatiArr(i, j) = p0.ati;
|
||||
}
|
||||
}
|
||||
|
||||
outimgll.saveImage(imgatiArr, 0, 0, 3);
|
||||
qDebug() << u8"计算每个点的斜距值";
|
||||
|
||||
|
||||
gdalImage antimg(InEchoGPSDataPath);
|
||||
qDebug() << u8"1. 回波GPS坐标点文件参数:\t";
|
||||
qDebug() << u8"文件路径:\t" << InEchoGPSDataPath;
|
||||
qDebug() << u8"GPS 点数:\t" << antimg.height;
|
||||
qDebug() << u8"文件列数:\t" << antimg.width;
|
||||
|
||||
long prfcount = antimg.height;
|
||||
|
||||
|
||||
std::shared_ptr<double> Pxs((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
|
||||
std::shared_ptr<double> Pys((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
|
||||
std::shared_ptr<double> Pzs((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
|
||||
std::shared_ptr<double> AntDirectX((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
|
||||
std::shared_ptr<double> AntDirectY((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
|
||||
std::shared_ptr<double> AntDirectZ((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
|
||||
|
||||
{
|
||||
long colnum = 19;
|
||||
std::shared_ptr<double> antpos = readDataArr<double>(antimg, 0, 0, prfcount, colnum, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
|
||||
double time = 0;
|
||||
double Px = 0;
|
||||
double Py = 0;
|
||||
double Pz = 0;
|
||||
for (long i = 0; i < prfcount; i++) {
|
||||
|
||||
Pxs.get()[i] = antpos.get()[i * 19 + 1]; // 卫星坐标
|
||||
Pys.get()[i] = antpos.get()[i * 19 + 2];
|
||||
Pzs.get()[i] = antpos.get()[i * 19 + 3];
|
||||
AntDirectX.get()[i] = antpos.get()[i * 19 + 13];// zero doppler
|
||||
AntDirectY.get()[i] = antpos.get()[i * 19 + 14];
|
||||
AntDirectZ.get()[i] = antpos.get()[i * 19 + 15];
|
||||
|
||||
double NormAnt = std::sqrt(AntDirectX.get()[i] * AntDirectX.get()[i] +
|
||||
AntDirectY.get()[i] * AntDirectY.get()[i] +
|
||||
AntDirectZ.get()[i] * AntDirectZ.get()[i]);
|
||||
AntDirectX.get()[i] = AntDirectX.get()[i] / NormAnt;
|
||||
AntDirectY.get()[i] = AntDirectY.get()[i] / NormAnt;
|
||||
AntDirectZ.get()[i] = AntDirectZ.get()[i] / NormAnt;// 归一化
|
||||
}
|
||||
antpos.reset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma omp parallel for
|
||||
for (long prfid = minRow; prfid < maxRow; prfid++) {
|
||||
double Px = Pxs.get()[prfid];
|
||||
double Py = Pys.get()[prfid];
|
||||
double Pz = Pzs.get()[prfid];
|
||||
double R = 0;
|
||||
Landpoint LLA = {};
|
||||
Point3 XYZ = {};
|
||||
for (long j = 0; j < imgwidth; j++) {
|
||||
LLA.lon = imglonArr(prfid-minRow, j);
|
||||
LLA.lat = imglatArr(prfid - minRow, j);
|
||||
LLA.ati = imgatiArr(prfid - minRow, j);
|
||||
|
||||
LLA2XYZ(LLA, XYZ);
|
||||
|
||||
R = sqrt(pow(Px - XYZ.x, 2) +
|
||||
pow(Py - XYZ.y, 2) +
|
||||
pow(Pz - XYZ.z, 2));
|
||||
imgRArr(prfid - minRow, j) = R;
|
||||
}
|
||||
}
|
||||
|
||||
outimgll.saveImage(imgRArr, 0, 0, 4);
|
||||
|
||||
qDebug() << u8"插值完成";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int ReflectTable_WGS2Range(QString dem_rc_path,QString outOriSimTiffPath,QString ori_sim_count_tiffPath,long OriHeight,long OriWidth)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ bool OverlapCheck(QString& ImageLLPath, QString& ImageDEMPath);
|
|||
|
||||
bool GPSPointsNumberEqualCheck(QString& ImageLLPath, QString& InEchoGPSDataPath);
|
||||
|
||||
|
||||
void InterploateClipAtiByRefDEM(QString ImageLLPath, QString& ImageDEMPath, QString& outImageLLAPath, QString& InEchoGPSDataPath);
|
||||
void InterploateAtiByRefDEM(QString& ImageLLPath, QString& ImageDEMPath, QString& outImageLLAPath, QString& InEchoGPSDataPath);
|
||||
int ReflectTable_WGS2Range(QString dem_rc_path, QString outOriSimTiffPath, QString ori_sim_count_tiffPath, long OriHeight, long OriWidth);
|
||||
#endif
|
||||
|
|
|
@ -64,12 +64,11 @@ void ImagePlaneAtiInterpDialog::onpushButtonEchoGPSPointSelect_clicked()
|
|||
void ImagePlaneAtiInterpDialog::onpushButtonRefRangeDEMSelect_clicked()
|
||||
{
|
||||
QString fileNames = QFileDialog::getOpenFileName(
|
||||
this, // ??????
|
||||
tr(u8"选择参考DEM"), // ????
|
||||
QString(), // ???·??
|
||||
tr(ENVI_FILE_FORMAT_FILTER) // ?????????
|
||||
this,
|
||||
tr(u8"选择参考DEM"),
|
||||
QString(),
|
||||
tr(ENVI_FILE_FORMAT_FILTER)
|
||||
);
|
||||
// ??????????????
|
||||
if (!fileNames.isEmpty()) {
|
||||
QString message = "Ñ¡ÖÐÎļþ\n";
|
||||
this->ui->lineEditRefRangeDEMPath->setText(fileNames);
|
||||
|
@ -82,12 +81,12 @@ void ImagePlaneAtiInterpDialog::onpushButtonRefRangeDEMSelect_clicked()
|
|||
void ImagePlaneAtiInterpDialog::onpushButtonImageLLASelect_clicked()
|
||||
{
|
||||
QString fileNames = QFileDialog::getSaveFileName(
|
||||
this, // ??????
|
||||
tr(u8"提示"), // ????
|
||||
QString(), // ???·??
|
||||
tr(ENVI_FILE_FORMAT_FILTER) // ?????????
|
||||
this,
|
||||
tr(u8"提示"),
|
||||
QString(),
|
||||
tr(ENVI_FILE_FORMAT_FILTER)
|
||||
);
|
||||
// ??????????????
|
||||
|
||||
if (!fileNames.isEmpty()) {
|
||||
QString message = "Ñ¡ÖÐÎļþ\n";
|
||||
this->ui->lineEditImageLLAPath->setText(fileNames);
|
||||
|
@ -119,17 +118,23 @@ void ImagePlaneAtiInterpDialog::onbuttonBoxAccepted()
|
|||
}
|
||||
|
||||
bool checkflag= this->ui->checkBoxOverLap->isChecked();
|
||||
|
||||
if (checkflag || OverlapCheck(imageNet0Path, refRangeDEMPath)) { // ????DEM???
|
||||
InterploateAtiByRefDEM(imageNet0Path, refRangeDEMPath, imageLLAPath,echoGPSDataPath);
|
||||
|
||||
QMessageBox::information(nullptr, u8"提示", u8"completed!!");
|
||||
if (checkflag) {
|
||||
InterploateClipAtiByRefDEM(imageNet0Path, refRangeDEMPath, imageLLAPath, echoGPSDataPath);
|
||||
QMessageBox::information(this, tr(u8"提示"), tr(u8"完成"));
|
||||
return;
|
||||
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(nullptr,u8"警告",u8"DEM影像小于成像粗平面采样要求");
|
||||
return;
|
||||
if (OverlapCheck(imageNet0Path, refRangeDEMPath)) { // ????DEM???
|
||||
InterploateAtiByRefDEM(imageNet0Path, refRangeDEMPath, imageLLAPath, echoGPSDataPath);
|
||||
|
||||
QMessageBox::information(nullptr, u8"提示", u8"completed!!");
|
||||
return;
|
||||
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(nullptr, u8"警告", u8"DEM影像小于成像粗平面采样要求");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue