python + pyqt +opencv 有界面,对lable中的图片进行图像旋转,向右平移,向下平移,二值化,灰度,边缘检测

对lable中的图片进行图像旋转,向右平移,向下平移,二值化,灰度,边缘检测

要求:
一个界面,具体界面内容自行设计但必须符合以下要求
多个操作按钮:
1.图像180°旋转
2.图像向右平移
3.图像向下平移
4.图像二值化
5.图像灰度
6.图像边缘检测
7.打开图片
8.退出
两个标签用于图片显示对比:
1.原图片
2.操作后图片
要求:
1.图片读取路径不能指定

在这里插入图片描述

import cv2
import numpy as np
import sys
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

fname=''
one=0
two=0
three=180

class picture(QWidget):
    def __init__(self):
        super(picture, self).__init__()

        self.resize(900,500)
        self.center()   #使窗口居中
        self.setWindowTitle("label显示图片")
        self.setWindowIcon(QIcon('1.jpg'))

        self.label = QLabel(self)
        self.label.setText("   显示图片")
        self.label.setFixedSize(300, 400)
        self.label.move(200,30)

        self.label.setStyleSheet("QLabel{background:white;}"
                                 "QLabel{color:rgb(300,300,300,120);font-size:20px;font-weight:bold;font-family:宋体;}"
                                 )

        self.label2 = QLabel(self)
        self.label2.setText("   显示图片")
        self.label2.setFixedSize(300, 400)
        self.label2.move(550, 30)

        self.label2.setStyleSheet("QLabel{background:white;}"
                                 "QLabel{color:rgb(300,300,300,120);font-size:20px;font-weight:bold;font-family:宋体;}"
                                 )

        btn_1 = QPushButton(self)
        btn_1.setText("打开图片")
        btn_1.move(30, 30)
        btn_1.clicked.connect(self.openimage)

        btn_2 = QPushButton(self)
        btn_2.setText("图像旋转180")
        btn_2.move(30, 80)
        btn_2.clicked.connect(self.xaunzhuan180)

        btn_3 = QPushButton(self)
        btn_3.setText("图像向右平移")
        btn_3.move(30, 130)
        btn_3.clicked.connect(self.youyi)

        btn_4 = QPushButton(self)
        btn_4.setText("图像向下平移")
        btn_4.move(30, 180)
        btn_4.clicked.connect(self.xiayi)

        btn_5 = QPushButton(self)
        btn_5.setText("图像二值化")
        btn_5.move(30, 230)
        btn_5.clicked.connect(self.erzhihua)

        btn_6 = QPushButton(self)
        btn_6.setText("图像灰度")
        btn_6.move(30, 280)
        btn_6.clicked.connect(self.h
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大胖东

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值