2025-05-13 17:48:58 +00:00
|
|
|
|
#include "GF3CalibrationAndOrthLib.h"
|
2025-05-13 18:56:15 +00:00
|
|
|
|
#include "BaseConstVariable.h"
|
|
|
|
|
#include "RasterToolBase.h"
|
|
|
|
|
#include "ImageOperatorBase.h"
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include "FileOperator.h"
|
|
|
|
|
#include "GPUBaseTool.h"
|
|
|
|
|
#include "GPUTool.cuh"
|
2025-05-20 07:18:00 +00:00
|
|
|
|
#include <omp.h>
|
|
|
|
|
// GPU<50><55><EFBFBD>صĴ<D8B5><C4B4><EFBFBD>
|
|
|
|
|
#include "GF3CalibrationGeoCodingFunCUDA.cuh"
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>HH<48><48><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>ΪVV<56><56><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="in_SigmaHHRasterPath"></param>
|
|
|
|
|
/// <param name="in_IncidencAngleRasterPath"></param>
|
|
|
|
|
/// <param name="out_SigmaVVRasterPath"></param>
|
|
|
|
|
/// <returns></returns>
|
2025-05-22 03:01:52 +00:00
|
|
|
|
int GF3_Sigma0_HH2VV(QString in_SigmaHHRasterPath, QString in_IncidencAngleRasterPath, QString out_SigmaVVRasterPath, SIGMATYPE sigmatype)
|
2025-05-13 18:56:15 +00:00
|
|
|
|
{
|
|
|
|
|
// step 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
// 1. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>
|
|
|
|
|
if (in_SigmaHHRasterPath.isEmpty() || in_IncidencAngleRasterPath.isEmpty() || out_SigmaVVRasterPath.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "Input or output file path is empty.";
|
|
|
|
|
throw std::invalid_argument("Input or output file path is empty.");
|
|
|
|
|
return 1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>Ϊ<EFBFBD><CEAA>
|
|
|
|
|
}
|
|
|
|
|
// 2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (!QFile::exists(in_SigmaHHRasterPath) || !QFile::exists(in_IncidencAngleRasterPath))
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "Input file does not exist.";
|
|
|
|
|
throw std::runtime_error("Input file does not exist.");
|
|
|
|
|
return 2; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
gdalImage inSigmaHHRaster(in_SigmaHHRasterPath);
|
|
|
|
|
gdalImage inIncidencAngleRaster(in_IncidencAngleRasterPath);
|
|
|
|
|
// 3. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD>С<EFBFBD>Ƿ<EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
if (inSigmaHHRaster.width != inIncidencAngleRaster.width || inSigmaHHRaster.height != inIncidencAngleRaster.height)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "Input images have different sizes.";
|
|
|
|
|
throw std::runtime_error("Input images have different sizes.");
|
|
|
|
|
return 3; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD>С<EFBFBD><D0A1>һ<EFBFBD><D2BB>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
copyFile(in_SigmaHHRasterPath, out_SigmaVVRasterPath);
|
|
|
|
|
// 4. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (!QFile::exists(out_SigmaVVRasterPath))
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "Output file does not exist.";
|
|
|
|
|
throw std::runtime_error("Output file does not exist.");
|
|
|
|
|
return 4; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// step 2 ִ<>в<EFBFBD><D0B2><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
gdalImage inSigmaHHRaster(in_SigmaHHRasterPath);
|
|
|
|
|
gdalImage inIncidencAngleRaster(in_IncidencAngleRasterPath);
|
|
|
|
|
gdalImage outSigmaVVRaster(out_SigmaVVRasterPath);
|
|
|
|
|
|
|
|
|
|
long width = inSigmaHHRaster.width;
|
|
|
|
|
long height = inSigmaHHRaster.height;
|
|
|
|
|
|
|
|
|
|
int64_t pixel_count64 = static_cast<int64_t>(height) * static_cast<int64_t>(width);
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
std::shared_ptr<double> sigmaHHRasterData = readDataArr<double>(inSigmaHHRaster, 0, 0, height, width, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
|
|
|
|
|
std::shared_ptr<double> incidenceAngleData = readDataArr<double>(inIncidencAngleRaster, 0, 0, height, width, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
|
|
|
|
|
std::shared_ptr<double> outSigmaVVRasterData = readDataArr<double>(outSigmaVVRaster, 0, 0, height, width, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
|
2025-05-20 07:18:00 +00:00
|
|
|
|
|
|
|
|
|
#pragma omp parallel for
|
|
|
|
|
for (int64_t i = 0; i < pixel_count64; i++)
|
2025-05-13 18:56:15 +00:00
|
|
|
|
{
|
2025-05-20 07:18:00 +00:00
|
|
|
|
double sigmaHH = sigmaHHRasterData.get()[i];
|
2025-05-22 03:01:52 +00:00
|
|
|
|
sigmaHH = converSigma2amp(sigmaHH,sigmatype);
|
|
|
|
|
double incidenceAngle = incidenceAngleData.get()[i];// <20>Ƕ<EFBFBD>
|
|
|
|
|
sigmaHH = 20 * log10(sigmaHH);
|
|
|
|
|
double sigmaVV = polartionConver_d(sigmaHH, incidenceAngle, 1.0, false); // <20><><EFBFBD><EFBFBD>dBֵ
|
2025-05-20 07:18:00 +00:00
|
|
|
|
outSigmaVVRasterData.get()[i] = sigmaVV;
|
2025-05-13 18:56:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-20 07:18:00 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
outSigmaVVRaster.saveImage(outSigmaVVRasterData,0,0,height,width,1);
|
|
|
|
|
// <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
|
2025-05-13 18:56:15 +00:00
|
|
|
|
sigmaHHRasterData.reset();
|
|
|
|
|
incidenceAngleData.reset();
|
|
|
|
|
outSigmaVVRasterData.reset();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return -1;// <20><><EFBFBD><EFBFBD>ִ<EFBFBD>гɹ<D0B3>
|
|
|
|
|
}
|