#include "pic.h"
#include "ui_pic.h"
#include<QFileDialog>
#include<QPainter>
#include<QPixmap>
#include<QLineEdit>
#include<QPushButton>
#include<QLabel>
#include<QTimer>
#include<QMovie>
#include<QErrorMessage>
#include<QIcon>
#include<opencv2/opencv.hpp>
#include<opencv2/core.hpp>
#include<QDebug>
#include<string>
#include<QGroupBox>
#include<opencv2/imgproc.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<vector>
#include<board.h>
using namespace cv;
using namespace std;
String changefn(String);
pic::pic(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::pic)
{
ui->setupUi(this);
this->setFixedSize(800,800);
this->setWindowIcon(QPixmap(":/res/icon.jpg"));
this->setWindowTitle("Picture");
QLineEdit* lineEdit=new QLineEdit(this);
QPushButton* btn=new QPushButton(this);
btn->resize(150,50);
btn->setText("choose");
btn->move(50,50);
lineEdit->resize(500,50);
lineEdit->move(250,50);
QLabel* label=new QLabel(this);
label->resize(800,700);
label->move(0,100);
QMovie* movie=new QMovie(":/res/nkfight");
QLabel* label2=new QLabel(this);
label2->resize(240,240);
label2->move(this->width()-240,this->height()-240);
label2->setMovie(movie);
movie->start();
connect(btn,&QPushButton::clicked,[=](){
QString fileName=QFileDialog::getOpenFileName();
lineEdit->setText(fileName);
});
connect(ui->actiontocam,&QAction::triggered,[=](){
QTimer::singleShot(500,this,[=](){
this->hide();
cam->show();
});
});
connect(cam,&camera::backto,[=](){
cam->hide();
emit backto();
});
connect(ui->actionreturn,&QAction::triggered,[=](){
emit backto();
});
//功能模块一 参看选中的原始图片
connect(ui->actionlook,&QAction::triggered,[=](){
QString fileName=lineEdit->text();
if(fileName != "")
{
board* b=new board(fileName);
b->show();
}
else
{
QErrorMessage* qe=new QErrorMessage();
qe->setWindowTitle("Error");
qe->showMessage("Picture does not exist!");
qe->setWindowIcon(QIcon(":/res/error.jpeg"));
qe->resize(400,200);
qe->show();
}
});
//功能模块二 实现灰度化
connect(ui->actiongray,&QAction::triggered,[=](){
QString fileName=lineEdit->text();
String fn=fileName.toStdString();
Mat img=imread(changefn(fn),0);
Mat imgg;
board* b=new board(img,"Gray");
b->show();
});
//功能模块三 实现阈值分割
QGroupBox* box1=new QGroupBox("Threshold",this);
box1->resize(200,260);
box1->move(50,150);
QPushButton* box1_btn1=new QPushButton("normal",box1);
box1_btn1->resize(150,60);
box1_btn1->move(25,20);
QPushButton* box1_btn2=new QPushButton("OTSU",box1);
box1_btn2->resize(150,60);
box1_btn2->move(25,100);
QPushButton* box1_btn3=new QPushButton("adaptive",box1);
box1_btn3->resize(150,60);
box1_btn3->move(25,180);
connect(box1_btn1,&QPushButton::clicked,[=](){
QString fileName=lineEdit->text();
if(fileName=="")
{
QErrorMessage* qe=new QErrorMessage();
qe->setWindowTitle("Error");
qe->showMessage("Picture does not exist!");
qe->setWindowIcon(QIcon(":/res/error.jpeg"));
qe->resize(400,200);
qe->show();
}
else
{
String fn=fileName.toStdString();
Mat img=imread(changefn(fn),0);
board* b=new board(img,"Normal_Threshold");
b->show();
}
});
connect(box1_btn2,&QPushButton::clicked,[=](){
QString fileName=lineEdit->text();
if(fileName=="")
{
QErrorMessage* qe=new QErrorMessage();
qe->setWindowTitle("Error");
qe->showMessage("Picture does not exist!");
qe->setWindowIcon(QIcon(":/res/error.jpeg"));
qe->resize(400,200);
qe->show();
}
else
{
String fn=fileName.toStdString();
Mat img=imread(changefn(fn),0);
Mat res;
int OTSU_thres=threshold(img,res,100,255,THRESH_OTSU);
board* b=new board(res,QString("OTSU_Threshold:%1").arg(OTSU_thres));
b->show();
}
});
connect(box1_btn3,&QPushButton::clicked,[=](){
QString fileName=lineEdit->text();
if(fileName=="")
{
QErrorMessage* qe=new QErrorMessage();
qe->setWindowTitle("Error");
qe->showMessage("Picture does not exist!");
qe->setWindowIcon(QIcon(":/res/error.jpeg"));
qe->resize(400,200);
qe->show();
}
else
{
String fn=fileName.toStdString();
Mat img=imread(changefn(fn),0);
Mat res;
adaptiveThreshold(img,res,255,0,1,3,10);
board* b=new board(res,"Adaptive_Threshold");
b->show();
}
});
//功能模块四 实现图像平滑滤波
QGroupBox* box2=new QGroupBox("Filter",this);
box2->resize(200,260);
box2->move(300,150);
QPushButton* box2_btn1=new QPushButton("MeanBlur",box2);
box2_btn1->resize(150,60);
box2_btn1->move(25,20);
QPushButton* box2_btn2=new QPushButton("MedianBlur",box2);
box2_btn2->resize(150,60);
box2_btn2->move(25,100);
QPushButton* box2_btn3=new QPushButton("GaussianBlur",box2);
box2_btn3->resize(150,60);
box2_btn3->move(25,180);
connect(box2_btn1,&QPushButton::clicked,[=](){
QString fileName=lineEdit->text();
if(fileName=="")
{
QErrorMessage* qe=new QErrorMessage();
qe->setWindowTitle("Error");
qe->showMessage("Picture does not exist!");
qe->setWindowIcon(QIcon(":/res/error.jpeg"));
qe->resize(400,200);
qe->show();
}
else
{
String fn=fileName.toStdString();
Mat img=imread(changefn(fn));
Mat res;
blur(img,res,Size(5,5));
board* b=new board(res,"Mean_Filter");
b->show();
}
});
connect(box2_btn2,&QPushButton::clicked,[=](){
QString fileName=lineEdit->text();
if(fileName=="")
{
QErrorMessage* qe=new QErrorMessage();
qe->setWindowTitle("Error");
qe->showMessage("Picture does not exist!");
qe->setWindowIcon(QIcon(":/res/error.jpeg"));
qe->resize(400,200);
qe->show();
}
else
{
String fn=fileName.toStdString();
Mat img=imread(changefn(fn));
Mat res;
medianBlur(img,res,5);
board* b=new board(res,"Median_Filter");
b->show();
}
});
connect(box2_btn3,&QPushButton::clicked,[=](){
QString fileName=lineEdit->text();
if(fileName=="")
{
QErrorMessage* qe=new QErrorMessage();
qe->setWindowTitle("Error");
qe->showMessage("Picture does not exist!");
qe->setWindowIcon(QIcon(":/res/error.jpeg"));
qe->resize(400,200);
qe->show();
}
else
{
String fn=fileName.toStdString();
Mat img=imread(changefn(fn));
Mat res;
GaussianBlur(img,res,Size(5,5),0);
board* b=new board(res,"Gaussian_Filter");
b->show();
}
});
//功能模块五 实现边缘检测功能
QGroupBox* box3=new QGroupBox("EdgeDetector",this);
box3->resize(200,260);
box3->move(550,150);
QPushButton* box3_btn1=new QPushButton("Sobel",box3);
box3_btn1->resize(150,60);
box3_btn1->move(25,20);
QPushButton* box3_btn2=new QPushButton("Lapl
没有合适的资源?快使用搜索试试~ 我知道了~
c语言大作业-图片处理器(基于Qt5.14.2与Opencv4.5.5)
共530个文件
cpp:112个
h:96个
ui:80个
0 下载量 103 浏览量
2024-01-07
09:58:10
上传
评论
收藏 9.49MB ZIP 举报
温馨提示
c语言大作业
资源推荐
资源详情
资源评论
收起资源包目录
c语言大作业-图片处理器(基于Qt5.14.2与Opencv4.5.5) (530个子文件)
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
PictureProcessor.pro.user.4.8-pre1 23KB
pic.cpp.autosave 18KB
mainwindow.cpp.autosave 2KB
mypushbutton.cpp.autosave 1KB
mypushbutton.h.autosave 428B
pic.cpp 19KB
pic.cpp 19KB
pic.cpp 19KB
pic.cpp 19KB
pic.cpp 19KB
pic.cpp 19KB
pic.cpp 19KB
pic.cpp 18KB
camera.cpp 17KB
camera.cpp 17KB
camera.cpp 17KB
pic.cpp 11KB
board.cpp 10KB
pic.cpp 10KB
board.cpp 10KB
camera.cpp 9KB
pic.cpp 8KB
board.cpp 5KB
board.cpp 5KB
board.cpp 5KB
pic.cpp 5KB
board.cpp 4KB
board.cpp 4KB
board.cpp 4KB
board.cpp 4KB
pic.cpp 3KB
board.cpp 3KB
board.cpp 3KB
board.cpp 3KB
choosewindow.cpp 3KB
choosewindow.cpp 3KB
choosewindow.cpp 3KB
choosewindow.cpp 3KB
choosewindow.cpp 3KB
choosewindow.cpp 3KB
choosewindow.cpp 2KB
choosewindow.cpp 2KB
choosewindow.cpp 2KB
choosewindow.cpp 2KB
choosewindow.cpp 2KB
choosewindow.cpp 2KB
choosewindow.cpp 2KB
choosewindow.cpp 2KB
choosewindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
mainwindow.cpp 2KB
camera.cpp 2KB
mainwindow.cpp 2KB
pic.cpp 2KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
mypushbutton.cpp 1KB
board.cpp 1KB
mypushbutton.cpp 1KB
camera.cpp 980B
camboard.cpp 767B
camboard.cpp 767B
camboard.cpp 767B
共 530 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
十小大
- 粉丝: 1w+
- 资源: 2556
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功