#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
import os
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui, QtWidgets
from mainWindowLayout import MainLayout
import cv2
import numpy as np
from scipy import ndimage
from matplotlib import pyplot as plt
class MainWindow(QMainWindow, MainLayout):
imagePaths = []
originImages=[]
imageList = [] #二维的图像列表
hideLayoutTag=-1
def __init__(self,parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.signalSlots()
#button与具体方法关联
def signalSlots(self):
#文件按钮相关方法
#打开
self.openAct.triggered.connect(lambda : importImage(self))
#保存
self.saveAct.triggered.connect(lambda : importImage(self))
#退出
self.exitAct.triggered.connect(self.close)
#编辑按钮相关方法
#放大
self.largeAct.triggered.connect(lambda : largeImage(self))
#缩小
self.smallAct.triggered.connect(lambda : smallImage(self))
#灰度
self.grayAct.triggered.connect(lambda : grayImage(self))
#亮度
self.brightAct.triggered.connect(lambda : brightImage(self))
#旋转
self.rotateAct.triggered.connect(lambda : rotateImage(self))
#截图
self.screenshotAct.triggered.connect(lambda : screenshotImage(self))
#变换按钮相关方法
#傅里叶变换
self.change1Act.triggered.connect(lambda : change1Image(self))
#离散余弦变换
self.change2Act.triggered.connect(lambda : change2Image(self))
#Radon变换
self.change3Act.triggered.connect(lambda : change3Image(self))
#噪声按钮相关方法
#高斯噪声
self.noise1Act.triggered.connect(lambda : noise1Image(self))
#椒盐噪声
self.noise2Act.triggered.connect(lambda : noise2Image(self))
#斑点噪声
self.noise3Act.triggered.connect(lambda : importImage(self))
#泊松噪声
self.noise4Act.triggered.connect(lambda : importImage(self))
#滤波按钮相关方法
#高通滤波
self.smoothing1Act.triggered.connect(lambda : smoothing1Image(self))
#低通滤波
self.smoothing2Act.triggered.connect(lambda : smoothing2Image(self))
#平滑滤波
self.smoothing3Act.triggered.connect(lambda : smoothing3Image(self))
#锐化滤波
self.smoothing4Act.triggered.connect(lambda : smoothing4Image(self))
#直方图统计按钮相关方法
#R直方图
self.hist1Act.triggered.connect(lambda : hist1Image(self))
#G直方图
self.hist2Act.triggered.connect(lambda : importImage(self))
#B直方图
self.hist3Act.triggered.connect(lambda : importImage(self))
#图像增强按钮相关方法
#伪彩色增强
self.enhance1Act.triggered.connect(lambda : enhance1Image(self))
#真彩色增强
self.enhance2Act.triggered.connect(lambda : enhance2Image(self))
#直方图均衡
self.enhance3Act.triggered.connect(lambda : histNormalized(self))
#NTSC颜色模型
self.enhance4Act.triggered.connect(lambda : enhance4Image(self))
#YCbCr颜色模型
self.enhance5Act.triggered.connect(lambda : enhance5Image(self))
#HSV颜色模型
self.enhance6Act.triggered.connect(lambda : enhance6Image(self))
#阈值分割方法
self.threButton.clicked.connect(lambda : threImage(self))
#形态学处理方法
self.morphologyProcessButton.clicked.connect(lambda : morphologyProcessImage(self))
#特征提取方法
self.featureButton.clicked.connect(lambda : featureImage(self))
#图像分类与识别方法
self.imgButton.clicked.connect(lambda : layoutChange(self))
#底部
#上一张
self.preButton.clicked.connect(lambda : preImage(self))
#下一张
self.nextButton.clicked.connect(lambda : nextImage(self))
#退出
self.exitButton.clicked.connect(self.close)
#编辑按钮相关方法
#放大
def largeImage(window):
imageList=[]
for img in window.originImages:
imgs=[]
img_info=img[0].shape
image_height=img_info[0]
image_weight=img_info[1]
dstHeight=int(2*image_height)
dstWeight=int(2*image_weight)
result=cv2.resize(img[0],(dstHeight,dstWeight))
imgs.extend([img[0],result])
imageList.append(imgs)
resizeFromList(window, imageList)
showImage(window,['原图','放大后'])
#缩小
def smallImage(window):
imageList=[]
for img in window.originImages:
imgs=[]
img_info=img[0].shape
image_height=img_info[0]
image_weight=img_info[1]
dstHeight=int(0.5*image_height)
dstWeight=int(0.5*image_weight)
result=cv2.resize(img[0],(dstHeight,dstWeight))
imgs.extend([img[0],result])
imageList.append(imgs)
resizeFromList(window, imageList)
showImage(window,['原图','缩小后'])
#灰度
def grayImage(window):
imageList=[]
for img in window.originImages:
imgs=[]
result = cv2.cvtColor(img[0], cv2.COLOR_BGR2RGB)
imgs.extend([img[0],result])
imageList.append(imgs)
resizeFromList(window, imageList)
showImage(window,['原图','灰度处理后'])
#亮度
def brightImage(window):
imageList=[]
for img in window.originImages:
imgs=[]
rows, cols, chunnel = img[0].shape
blank = np.zeros([rows, cols, chunnel], img[0].dtype)
result = cv2.addWeighted(img[0], 1.3, blank, 1-1.3, 3)
imgs.extend([img[0],result])
imageList.append(imgs)
resizeFromList(window, imageList)
showImage(window,['原图','调整亮度后'])
#旋转
def rotateImage(window):
imageList=[]
for img in window.originImages:
imgs=[]
img_info=img[0].shape
image_height=img_info[0]
image_weight=img_info[1]
mat_rotate=cv2.getRotationMatrix2D((image_height*0.5,image_weight*0.5),90,1) #center angle 3scale
result=cv2.warpAffine(img[0],mat_rotate,(image_height,image_weight))
imgs.extend([img[0],result])
imageList.append(imgs)
resizeFromList(window, imageList)
showImage(window,['原图','旋转后'])
#截图
def screenshotImage(window):
imageList=[]
for img in window.originImages:
imgs=[]
result = img[0][70:170, 440:540]
imgs.extend([img[0],result])
imageList.append(imgs)
resizeFromList(window, imageList)
showImage(window,['原图','截图后'])
#变换按钮相关方法
#傅里叶变换
def change1Image(window):
imageList=[]
for img in window.originImages:
imgs=[]
b,g,r=cv2.split(img[0])
b_freImg,b_recImg=oneChannelDft(b)
g_freImg, g_recImg = oneChannelDft(g)
r_freImg, r_recImg = oneChannelDft(r)
freImg=cv2.merge([b_freImg,g_freImg,r_freImg])
imgs.extend([img[0],freImg])
imageList.append(imgs)
resizeFromList(window, imageList)
showImage(window,['原图','傅里叶变换后'])
def oneChannelDft(img):
width, height = img.shape
nwidth = cv2.getOptimalDFTSize(width)
nheigth = cv2.getOptimalDFTSize(height)
nimg = np.zeros((nwidth, nheigth))
nimg[:width, :height] = img
dft = cv2.dft(np.float32(nimg), flags=cv2.DFT_COMPLEX_OUTPUT)
ndft = dft[:width, :height]
ndshift = np.fft.fftshift(ndft)
magnitude = np.log(cv2.magnitude(ndshift[:, :, 0], ndshift[:
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于pyqt5+opencv实现的多功能图像处理python源码(变换、滤波、增强、分割、形态学处理、特征提取、识别等).zip基于pyqt5+opencv实现的多功能图像处理python源码(变换、滤波、增强、分割、形态学处理、特征提取、识别等).zip基于pyqt5+opencv实现的多功能图像处理python源码(变换、滤波、增强、分割、形态学处理、特征提取、识别等).zip基于pyqt5+opencv实现的多功能图像处理python源码(变换、滤波、增强、分割、形态学处理、特征提取、识别等).zip 【优质项目推荐】 1.项目代码功能经验证ok,确保稳定可靠运行。欢迎下载使用!在使用过程中,如有问题或建议,请及时私信沟通,帮助解答。 2.项目主要针对各个计算机相关专业,包括计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网等领域的在校学生、专业教师或企业员工使用。 3.项目具有丰富的拓展空间,不仅可作为入门进阶,也可直接作为毕设、课程设计、大作业、项目初期立项演示等用途。 4.如果基础还行,或热爱钻研,可基于此项目进行二次开发,DIY其他不同功能。 基于pyqt5+opencv实现的多功能图像处理python源码(变换、滤波、增强、分割、形态学处理、特征提取、识别等).zip基于pyqt5+opencv实现的多功能图像处理python源码(变换、滤波、增强、分割、形态学处理、特征提取、识别等).zip基于pyqt5+opencv实现的多功能图像处理python源码(变换、滤波、增强、分割、形态学处理、特征提取、识别等).zip基于pyqt5+opencv实现的多功能图像处理python源码(变换、滤波、增强、分割、形态学处理、特征提取、识别等).zip
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/ZIP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 6 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
北航程序员小陈
- 粉丝: 3174
- 资源: 2445
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)