详细流程参考https://blog.csdn.net/deirjie/article/details/37872743
代码
//open_image.h
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_open_image.h"
#include "gdal_priv.h"
#include <QMessageBox>
#include <QFileDialog>
#include <QTextCodec>
#include<QWheelEvent>
#include<QStandardItemModel>
#include<QFileInfo>
#include<QImage>
#include<QPixmap>
#include<QGraphicsPixmapItem>
#include<QMatrix>
#include<QScrollBar>
#include <QListView>
class open_image : public QMainWindow
{Q_OBJECTpublic slots:void readimage();
public:QSize sizeHint() const;void CloseCurrentImg();open_image(QWidget *parent = Q_NULLPTR);bool m_showColor;float m_scaleFactor;QPoint lastEventCursorPos;
protected:void wheelEvent(QWheelEvent *event);void mousePressEvent(QMouseEvent *event);void mouseMoveEvent(QMouseEvent *event);void mouseReleaseEvent(QMouseEvent *event);void ZoomIn(){ScaleImg(1.2);};void ZoomOut(){ScaleImg(0.8);};
private:void ShowBand(GDALRasterBand* band);void ShowImg(QList<GDALRasterBand*>*imgBand);unsigned char* ImgSketch(float* buffer, GDALRasterBand* currentBand, int size, double noValue);Ui::open_imageClass ui;void ScaleImg(double factor){m_scaleFactor *= factor;QMatrix matrix;matrix.scale(m_scaleFactor, m_scaleFactor);ui.image_show->setMatrix(matrix);};QStandardItemModel *imgMetaModel;QStandardItemModel *fileListModel;GDALDataset *poDataset;void ShowImgInfor(const QString filename);void ShowFileList(const QString filename);
};
结果展示
只打开图片的话,没有投影信息
*//工程文件,有需要可以下载,主要是为了备份 用了GDAL+QT+OPENCV(包括有:图像打开,元数据查看,VDVI计算,灰度转换、直方图均衡化,拉普拉斯滤波、高斯滤波、线性拉伸、区域生长分割),还有很多bug没修改------
链接: https://pan.baidu.com/s/1banIbxF6xCcCCEeGrCPJjg?pwd=ten9
提取码: ten9 复制这段内容后打开百度网盘手机App,操作更方便哦
直方图均衡化截图有问题—不知道为啥