simorthoprogram/simorthoprogram-orth_gf3-strip/simptsn.h

243 lines
9.0 KiB
C
Raw Permalink Normal View History

2024-02-20 02:28:15 +00:00
#pragma once
///
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
///
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
// <20><><EFBFBD>ط<EFBFBD><D8B7><EFBFBD>
#include "baseTool.h"
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
#include <omp.h>
#include "SateOrbit.h"
#include "ImageMatch.h"
using namespace std;
using namespace Eigen;
////////////// <20><><EFBFBD>ú<EFBFBD><C3BA><EFBFBD> ////////////////////////
double getRangeColumn(long double R, long double NearRange, long double Fs, long double lamda);
Eigen::MatrixXd getRangeColumn(Eigen::MatrixXd R, long double NearRange, long double Fs, long double lamda);
double getRangebyColumn(double j, long double NearRange, long double Fs, long double lamda);
Eigen::MatrixXd getRangebyColumn(Eigen::MatrixXd j, long double NearRange, long double Fs, long double lamda);
///////////// ptsn <20>㷨 /////////////////////
class PSTNAlgorithm {
public:
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
PSTNAlgorithm();
PSTNAlgorithm(string parameterPath);
~PSTNAlgorithm();
int dem2lat_lon(std::string dem_path, std::string lon_path, std::string lat_path);
int dem2SAR_RC(std::string dem_path, std::string sim_rc_path);
// ģ<><C4A3><EFBFBD><EFBFBD><E3B7A8><EFBFBD><EFBFBD>
Eigen::MatrixX<double> calNumericalDopplerValue(Eigen::MatrixX<double> R);// <20><>ֵģ<D6B5><EFBFBD><E2B7A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>ֵ
double calNumericalDopplerValue(double R);// <20><>ֵģ<D6B5><EFBFBD><E2B7A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>ֵ
Eigen::MatrixX<double> calTheoryDopplerValue(Eigen::MatrixX<double> R, Eigen::MatrixX<double> R_s1, Eigen::MatrixX<double> V_s1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>ֵ
double calTheoryDopplerValue(double R, Eigen::MatrixX<double> R_s1, Eigen::MatrixX<double> V_s1);
Eigen::MatrixX<double> PSTN(Eigen::MatrixX<double> TargetPostion, double ave_dem, double dt, bool isCol ); // <20><><EFBFBD><EFBFBD>DEM
//Eigen::MatrixXd WGS842J2000(Eigen::MatrixXd blh);
//Landpoint WGS842J2000(Landpoint p);
public: // WGS84 <20><> J2000 ֮<><D6AE><EFBFBD>ı<C4B1><E4BBBB><EFBFBD><EFBFBD>
Eigen::MatrixXd UTC;
double Xp = 0.204071;
double Yp = 0.318663;
double Dut1 = 0.0366742;
double Dat = 37;
public:
int height; // Ӱ<><D3B0><EFBFBD>ĸ<EFBFBD>
int width;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double near_in_angle;// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double far_in_angle;// Զ<><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// SAR<41>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double fs;// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
double R0;//<2F><>б<EFBFBD><D0B1>
double LightSpeed; // <20><><EFBFBD><EFBFBD>
double lamda;// <20><><EFBFBD><EFBFBD>
double refrange;// <20>ο<EFBFBD>б<EFBFBD><D0B1>
double doppler_reference_time; //<2F><><EFBFBD><EFBFBD><EFBFBD>ղο<D5B2>ʱ<EFBFBD><CAB1>
double imgStartTime;// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼʱ<CABC><CAB1>
double PRF;// <20><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
int doppler_paramenter_number;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MatrixX<double> doppler_paras;// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
OrbitPoly orbit; // <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
};
/// <summary>
/// <20><>ȡ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><C7A3>Ƕ<EFBFBD>ֵ
/// </summary>
/// <param name="satepoint"></param>
/// <param name="landpoint"></param>
/// <param name="slopeVector"></param>
/// <returns></returns>
double getlocalIncAngle(Landpoint& satepoint, Landpoint& landpoint, Landpoint& slopeVector);
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>Ƕ<EFBFBD>ֵ
/// </summary>
/// <param name="satepoint"></param>
/// <param name="landpoint"></param>
/// <returns></returns>
double getIncAngle(Landpoint& satepoint, Landpoint& landpoint);
/// <summary>
/// ASF<53><46><EFBFBD><EFBFBD><E3B7BD>
/// </summary>
class ASFOrthClass {
public:
Eigen::MatrixXd Satellite2ECR(Eigen::Vector3d Rsc, Eigen::Vector3d Vsc); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4BBBB><EFBFBD><EFBFBD> M
Eigen::Vector3d UnitVectorOfSatelliteAndTarget(double alpha, double beta, Eigen::MatrixXd M);
double GetLookFromRangeYaw(double R, double alpha, double beta, Eigen::Vector3d SatellitePosition, Eigen::Vector3d SatelliteVelocity, double R_threshold, double H = 0);
Eigen::Vector3d GetXYZByBetaAlpha(double alpha,double beta, Eigen::Vector3d SatellitePosition,double R, Eigen::MatrixXd M);
double FD(double alpha, double beta, Eigen::Vector3d SatelliteVelocity, Eigen::Vector3d TargetVelocity,double R,double lamda, Eigen::MatrixXd M);
double FR(double alpha, double beta, Eigen::Vector3d SatellitePosition, Eigen::MatrixXd M, double R_threshold, double H = 0);
Eigen::Vector3d ASF(double R, Eigen::Vector3d SatellitePosition, Eigen::Vector3d SatelliteVelocity, Eigen::Vector3d TargetPosition, PSTNAlgorithm PSTN, double R_threshold, double H = 0, double alpha0 = 0, double beta0 = 0);
};
/// <summary>
/// <20><><EFBFBD><EFBFBD><E6B4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
class simProcess {
public:
simProcess();
~simProcess();
int parameters(int argc, char* argv[]);
int InitSimulationSAR(std::string paras_path,std::string workspace_path,std::string out_dir_path,std::string in_dem_path,std::string in_sar_path); // <20><><EFBFBD>Ӷ<EFBFBD>λ<EFBFBD><CEBB>
int CreateSARDEM();
int dem2SAR(); // <20>л<EFBFBD><D0BB>к<EFBFBD>
int SARIncidentAngle();
int SARSimulationWGS();
int SARSimulation();
int in_sar_power();
int ReflectTable_WGS2Range();
int InitRPCIncAngle(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path,std::string in_rpc_lon_lat_path,std::string out_inc_angle_path, std::string out_local_inc_angle_path, std::string out_inc_angle_geo_path, std::string out_local_inc_angle_geo_path);
int dem2SAR_row(); // <20>л<EFBFBD><D0BB>к<EFBFBD>
int SARIncidentAngle_RPC();
int createRPCDEM();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɢ<EFBFBD><C9A2>ֵ
int Scatter2Grid(std::string lon_lat_path, std::string data_tiff, std::string grid_path, double space);
// ASF ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int InitASFSAR(std::string paras_path, std::string workspace_path, std::string out_dir_path, std::string in_dem_path);
int ASF(std::string in_dem_path, std::string out_latlon_path, ASFOrthClass asfclass, PSTNAlgorithm PSTN);
//int dem2simSAR(std::string dem_path, std::string out_sim_path, PSTNAlgorithm PSTN); // <20><><EFBFBD><EFBFBD>DEM<45><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
int sim_SAR(std::string dem_path, std::string sim_rc_path, std::string sim_sar_path, PSTNAlgorithm PSTN);
int dem2aspect_slope(std::string dem_path, std::string aspect_path, std::string slope_path);
int sim_sum_SAR(std::string sim_dem_path,std::string sim_rc_path, std::string sim_orth_path, std::string sim_sum_path,PSTNAlgorithm pstn);
void interpolation_GTC_sar_sigma(std::string in_rc_wgs84_path, std::string in_ori_sar_path, std::string out_orth_sar_path, PSTNAlgorithm pstn);
//˫<><CBAB><EFBFBD>Բ<EFBFBD>ֵ
void interpolation_bil(std::string in_rc_wgs84_path, std::string in_ori_sar_path, std::string out_orth_sar_path, PSTNAlgorithm pstn);
//lee<65>˲<EFBFBD>
void lee_process(std::string in_ori_sar_path, std::string out_orth_sar_path, int w_size, double noise_var);
// ԭʼӰ<CABC><D3B0>ǿ<EFBFBD><C7BF>ͼ
int ori_sar_power(std::string ori_sar_path, std::string out_sar_power_path);
// ƥ<><C6A5>ƫ<EFBFBD><C6AB>ģ<EFBFBD>͹<EFBFBD><CDB9><EFBFBD>
int createImageMatchModel(std::string ori_sar_rsc_path, std::string ori_sar_rsc_jpg_path, std::string sim_sar_path, std::string sim_sar_jpg_path, std::string matchmodel_path);
// <20><><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0>
int correctOrth_rc(std::string sim_rc_path,ImageMatch matchmodel);
int correct_ati(std::string orth_rc_path, std::string dem_path, std::string out_inclocal_path, std::string out_dem_path, std::string out_count_path, PSTNAlgorithm PSTN);
void calcalIncident_localIncident_angle(std::string in_dem_path, std::string in_rc_wgs84_path, std::string out_incident_angle_path, std::string out_local_incident_angle_path, PSTNAlgorithm PSTN);
void calGEC_Incident_localIncident_angle(std::string in_dem_path, std::string in_gec_lon_lat_path,std::string out_incident_angle_path, std::string out_local_incident_angle_path,PSTNAlgorithm PSTN);
void interpolation_GTC_sar(std::string in_rc_wgs84_path, std::string in_ori_sar_path, std::string out_orth_sar_path, PSTNAlgorithm pstn);
// RPC
void CreateRPC_DEM(std::string in_rpc_rc_path, std::string in_dem_path, std::string out_rpc_dem_path);
void CreateRPC_refrenceTable(string in_rpc_tiff_path, string in_merge_dem, string out_rpc_lon_lat_tiff_path);
void CorrectionFromSLC2Geo(string in_lon_lat_path, string in_radar_path, string out_radar_path, int in_band_ids);
//TODO:<3A><><EFBFBD>㷽λ<E3B7BD><CEBB>
double getAzimuth();
// <20>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
public:
ImageMatch matchmodel;
bool isMatchModel;
std::string workSpace_path;// <20><><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>·<EFBFBD><C2B7>
std::string outSpace_path;// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>·<EFBFBD><C2B7>
PSTNAlgorithm pstn; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
///// RPC <20>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ///////////////////////////////////
std::string in_rpc_lon_lat_path;
std::string out_dir_path;
std::string workspace_path;
// <20><>ʱ<EFBFBD>ļ<EFBFBD>
std::string rpc_wgs_path;
std::string ori_sim_count_tiff;// ӳ<><D3B3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
std::string out_inc_angle_rpc_path;
std::string out_local_inc_angle_rpc_path;
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
std::string out_inc_angle_geo_path;
std::string out_local_inc_angle_geo_path;
///// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B7BD> /////////
// <20><>ʱ<EFBFBD><CAB1>Ʒ<EFBFBD>ļ<EFBFBD>
std::string in_dem_path; // <20><><EFBFBD><EFBFBD>DEM
std::string dem_path; // <20>ز<EFBFBD><D8B2><EFBFBD>֮<EFBFBD><D6AE>DEM
std::string dem_r_path;// <20>к<EFBFBD>Ӱ<EFBFBD><D3B0>
std::string dem_rc_path; // <20><><EFBFBD>к<EFBFBD>
std::string sar_sim_wgs_path;
std::string sar_sim_path;
std::string in_sar_path;
std::string sar_jpg_path;
std::string sar_power_path;
// <20><><EFBFBD>ղ<EFBFBD>Ʒ
std::string out_dem_rc_path; // <20><>γ<EFBFBD><CEB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>кű任<C5B1>ļ<EFBFBD>
std::string out_dem_slantRange_path; // б<><D0B1><EFBFBD>ļ<EFBFBD>
std::string out_plant_slantRange_path;// ƽ<><C6BD>б<EFBFBD><D0B1><EFBFBD>ļ<EFBFBD>
//// ASF <20><><EFBFBD><EFBFBD> /////////////
std::string out_lon_path;// <20><><EFBFBD><EFBFBD>
std::string out_lat_path;// γ<><CEB3>
std::string out_slantRange_path;// б<><D0B1><EFBFBD>ļ<EFBFBD>
/// <20><>ͬ<EFBFBD>ļ<EFBFBD> ///
std::string out_localIncidenct_path;// <20><><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
std::string out_incidence_path; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
std::string out_ori_sim_tiff;// ӳ<><D3B3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>'
std::string out_sim_ori_tiff;
};
bool PtInRect(Point_3d pCur, Point_3d pLeftTop, Point_3d pRightTop, Point_3d pRightBelow, Point_3d pLeftBelow);