NiirsCpp/NiirsLinux/niirs.h

200 lines
6.7 KiB
C
Raw Permalink Normal View History

2023-02-22 11:56:10 +08:00
#pragma once
#include <QtWidgets/QMainWindow>
#include <QDebug>
#include <QDomDocument>
#include <QFile>
#include <QFileDialog>
#include <QMessageBox>
#include <QStack>
#include <QTextStream>
#include <QTime>
#include "ui_niirs.h"
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/types_c.h>
#include <opencv2/core/core.hpp>
#include <math.h>
#include <omp.h>
//#include <stdlib.h>
//#include <iostream>
#include "gdal_priv.h"
using namespace std;
struct ImgInfo
{
GDALDataType dataType; //标示数据类型
int bandCount; //数据波段数目
int xSize; //数据在x方向上的尺寸
int ySize; //数据在y方向上的尺寸
int xOffset; //x方向上的偏移
int yOffset; //y方向上的偏移
char projWkt[1024]; //数据的投影方式
double geoTransform[6]; //数据的仿射坐标
double noData; //数据的背景值
};
class NIIRS : public QMainWindow
{
Q_OBJECT
public:
NIIRS(QWidget* parent = Q_NULLPTR);
void setXmlInterface(QString strXmlInterface);
/* 计算NIIRS
* @return NIIRS */
double calculateNiirsScore();
//计算10个客观参数
void calculateObjectivePara();
//void calculateEvaluationImage();
double calculateRER();
/*
* @brief
* @param srcImgPath
* @param imgInfo tiff文件信息
* @return */
int getImageInfo(const char* srcImgPath, struct ImgInfo* imgInfo);
/*
* @brief tiff
* @param srcImgPath
* @param imgInfo tiff文件信息
* @param imgArray tiff数组
* @param bandIndex bandIndex=0,
* @return */
int readTiffFile(const char* srcImgPath, ImgInfo imgInfo, void* imgArray, int bandIndex);
void initTableWidget(int rowNum, int colNum);
void setTableWidgetValue(double val, int row, int col);
/*
* @brief
* @param path
* @param fileType
* @return absoluteFilePath, */
QStringList getAllFiles(QString path, QString fileType);
public slots:
void onRadioBtn_Visi();
void onRadioBtn_Infra();
void on_pbtOpenImg_clicked();
//void on_pbtOpenEdgeX_clicked();
//void on_pbtOpenEdgeY_clicked();
private:
Ui::NIIRSClass ui;
/* 计算噪声增益
* @param kernel MTFC所使用的滤波器
* @return MTFC_G噪声增益 */
double calculateMTFC_G(cv::Mat kernel);
////计算信噪比mean/StdDev
//double calculateSNR(cv::Mat img);
/* 计算数字图像亮度
* @return */
double calculateMeanStdDev(cv::Mat img);
////计算图像标准差方差
//float calculateStdDev(cv::Mat img);
//计算图像对比度
double calculateContrastRatio(cv::Mat img);
////计算信息熵
//double calculateEntropy(cv::Mat img);
/*
* @brief
* @param imgArray tiff数组
* @param maxVal tiff波段中的最大值
* @return */
double calculateTiffEntropy(unsigned short* bandBuf, int bufSize, int maxVal);
//计算相对边缘相应
// double calculateERx(cv::Mat img);
// double calculateERy(cv::Mat img);
//return pair.first:ER, pair.second:H
QPair<double, double> calculateERx(cv::Mat img);
QPair<double, double> calculateERy(cv::Mat img);
QPair<double, double> calculate_rer_h(cv::Mat img, cv::Point pointA, cv::Point pointB);
cv::Point2d calculateFootPoint(array<cv::Point, 3>& ps);
//float SFRCalculation(cv::Mat& ROI, double gamma);
//void de_Gamma(cv::Mat& Src, double gamma);
//std::vector<double> CentroidFind(cv::Mat& Src, std::vector<double>& y_shifts, double* CCoffset);
//void SLR(std::vector<double>& Cen_Shifts, std::vector<double>& y_shifts, double* a, double* b);
//void ReduceRows(double slope, int* ImgHeight);
//std::vector<double> OverSampling(cv::Mat& Src, double slope, double CCoffset, int height, int width, int* SamplingLen);
//std::vector<double> HammingWindows(std::vector<double>& deSampling, int SamplingLen);
//void DFT(std::vector<double>& data, int size);
//陡度
//基于sobel算子计算平均梯度
double gradient_Sobel(cv::Mat img);
//基于Laplacian算子拉普拉斯导数评价清晰度
double definition_Laplacian(cv::Mat img);
//四个方向的角二阶矩
void get_GLCM_0deg(cv::Mat& input, cv::Mat& dst);
void get_GLCM_90deg(cv::Mat& input, cv::Mat& dst);
void get_GLCM_45deg(cv::Mat& input, cv::Mat& dst);
void get_GLCM_135deg(cv::Mat& input, cv::Mat& dst);
//计算二阶矩的特征值
double calculateASM(cv::Mat& src);
//PIQE
double calculatePIQEScore(cv::Mat& img);
bool noticeDistCriterion(cv::Mat Block, int nSegments, int blockSize_1,
int windowSize, float blockImpairedThreshold, int blockSize);
cv::Mat segmentEdge(cv::Mat blockEdge, int nSegments, int blockSize_1, int windowSize);
float noiseCriterion(cv::Mat Block, int blockSize_1, float blockVar, float blockStdDev);
float centerSurDev(cv::Mat Block, int blockSize_1);
// 计算垂足的坐标array点、直线两端点
cv::Point calculate_foot_point(array<cv::Point, 3>& ps);
// 计算两点距离
float pointDistance(cv::Point pt1, cv::Point pt2);
//// 计算两直线交点
//cv::Point line_intersection(array<cv::Point, 2>& line1, array<cv::Point, 2>& line2);
//// 根据一条线的点pt、斜率k、另一条水平或垂直的直线的端点求交点
//cv::Point point_k_edge_intersection(cv::Point pt, double k, array<cv::Point, 2>& line);
//// 计算点到直线距离
//int calculate_distance(array<cv::Point, 3>& ps);
bool jpegTest = false;
//int mBandCount = 0;
QString mXmlInterface = "";
//QString mXmlImgPath = "/home/testdata/19data/VALID-ALIGACE/JB19-2_MSS_000811113_MMB04_001_01_001_003_L1/JB19-2_MSS_000811113_MMB04_001_01_001_003_L1.tiff";
QString mXmlImgPath = "";//D:\\A_testdata\\niirs_test\\data\\GF2_mask1024.tif
QString mXmlTopLeftX = "0";//311,336
QString mXmlTopLeftY = "0";//324,293
QString mXmlBottomRightX = "0";//335,348
QString mXmlBottomRightY = "0";//337,311
QString mXmlProductDir = "";
QString mResultXmlDir = "";
cv::Point mRerEdgePointA;
cv::Point mRerEdgePointB;
double imgLight = 0.0; //亮度
double imgStdDev = 0.0; //标准差
double imgContrastRadio = 0.0; //对比度
double imgEntropy = 0.0; //熵
double imgSNR = 0.0; //信噪比
double imgGradient = 0.0; //陡度
double imgDefinition = 0.0; //清晰度
double imgASM = 0.0; //角二阶矩
double imgPIQE = 0.0; //PIQE
double imgRER = 0.986; //相对边缘响应
};