图像的二值化处理就是讲图像上的点的灰度置为0或255,也就是讲整个图像呈现出明显的黑白效果。即将256个亮度等级的灰度图像通过适当的阀值选取而获得仍然可以反映图像整体和局部特征的二值化图像。

进行二值图像的处理与分析,首先要把灰度图像二值化,得到二值化图像,这样子有利于再对图像做进一步处理时,图像的集合性质只与像素值为0或255的点的位置有关,不再涉及像素的多级值,使处理变得简单,而且数据的处理和压缩量小。为了得到理想的二值图像,一般采用封闭、连通的边界定义不交叠的区域。所有灰度大于或等于阀值的像素被判定为属于特定物体,其灰度值为255表示,否则这些像素点被排除在物体区域以外,灰度值为0,表示背景或者例外的物体区域。如果某特定物体在内部有均匀一致的灰度值,并且其处在一个具有其他等级灰度值的均匀背景下,使用阀值法就可以得到比较的分割效果。如果物体同背景的差别表现不在灰度值上(比如纹理不同),可以将这个差别特征转换为灰度的差别,然后利用阀值选取技术来分割该图像。动态调节阀值实现图像的二值化可动态观察其分割图像的具体结果。

函数原型

cvtcolor()

RGB空间内的变换,例如添加/删除Alpha通道,反转通道顺序,转换为16位RGB颜色(R5:G6:B5或R5:G5:B5),以及使用以下方式转换为灰度/从灰度转换:

python cv2 灰度图 重心 opencv灰度图像二值化处理_灰度二值化

从RGB图像到灰色的转换是通过以下方式完成的:

cvtColor(src,bwsrc,cv :: COLOR_RGB2GRAY);

但是在实际的imread得到的图像为BGR,所以使用的函数是:

cvtColor(m_srcImage, m_grayImage, COLOR_BGR2GRAY);//图像格式转换

adaptiveThreshold()

void cv::adaptiveThreshold

(

InputArray 

src,

 

 

OutputArray 

dst,

 

 

double 

maxValue,

 

 

int 

adaptiveMethod,

 

 

int 

thresholdType,

 

 

int 

blockSize,

 

 

double 

C 

 

)

 

#include <opencv2/imgproc.hpp>

对数组应用自适应阈值。

该函数根据公式将灰度图像转换为二进制图像:

T.(x ,y) 是为每个像素单独计算的阈值(请参阅adaptiveMethod参数)。

该功能可以就地处理图像。

参数

SRC

源8位单通道图像。

DST

与src具有相同大小和相同类型的目标映像。

包括maxValue

分配给满足条件的像素的非零值

adaptiveMethod

要使用的自适应阈值算法,请参阅AdaptiveThresholdTypes。该BORDER_REPLICATE | BORDER_ISOLATED用于处理边界。

thresholdType

阈值类型必须是THRESH_BINARYTHRESH_BINARY_INV,请参阅ThresholdTypes

BLOCKSIZE

用于计算像素阈值的像素邻域的大小:3,5,7等。

C

从平均值或加权平均值中减去常数(请参阅下面的详细信息)。通常情况下,它是正数,但也可能为零或负数。

代码实现

界面设计:

python cv2 灰度图 重心 opencv灰度图像二值化处理_OPENCV_02

mainwindow.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>438</width>
    <height>416</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralWidget">
   <widget class="QLabel" name="label">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>10</y>
      <width>54</width>
      <height>12</height>
     </rect>
    </property>
    <property name="text">
     <string>原始图像:</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_2">
    <property name="geometry">
     <rect>
      <x>190</x>
      <y>10</y>
      <width>54</width>
      <height>12</height>
     </rect>
    </property>
    <property name="text">
     <string>灰度图像:</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_3">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>160</y>
      <width>111</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>二值图像(黑色底色)</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_4">
    <property name="geometry">
     <rect>
      <x>190</x>
      <y>160</y>
      <width>111</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>二值图像(白色底色)</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_Display">
    <property name="geometry">
     <rect>
      <x>30</x>
      <y>40</y>
      <width>151</width>
      <height>111</height>
     </rect>
    </property>
    <property name="text">
     <string>origin</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_Gray">
    <property name="geometry">
     <rect>
      <x>210</x>
      <y>30</y>
      <width>151</width>
      <height>121</height>
     </rect>
    </property>
    <property name="text">
     <string>gray</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_Bin">
    <property name="geometry">
     <rect>
      <x>23</x>
      <y>181</y>
      <width>161</width>
      <height>131</height>
     </rect>
    </property>
    <property name="text">
     <string>bin black</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_Final">
    <property name="geometry">
     <rect>
      <x>213</x>
      <y>181</y>
      <width>161</width>
      <height>121</height>
     </rect>
    </property>
    <property name="text">
     <string>bin white</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton">
    <property name="geometry">
     <rect>
      <x>340</x>
      <y>320</y>
      <width>75</width>
      <height>23</height>
     </rect>
    </property>
    <property name="text">
     <string>打开图片</string>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menuBar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>438</width>
     <height>23</height>
    </rect>
   </property>
  </widget>
  <widget class="QToolBar" name="mainToolBar">
   <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
   </attribute>
   <attribute name="toolBarBreak">
    <bool>false</bool>
   </attribute>
  </widget>
  <widget class="QStatusBar" name="statusBar"/>
 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <resources/>
 <connections/>
</ui>

mainwindow.cpp

参考原文: 

1. 代码中我生成灰度图的时候使用图片格式为 QImage::Format_Grayscale8 ,Qt助手中给出的解释The image is stored using an 8-bit grayscale format可以看出,这种图片中用8-bit存储灰度值,所以每个像素只有1字节;这里我也试过 QImage::Format_RGB888 格式(The image is stored using a 24-bit RGB format (8-8-8)),这时每个像素有3个字节,这里牵扯后面代码中有不同的地方。

实验中,除了展示原图像以外,QImage::Format_RGB888都会使程序崩溃.

后面对图像的二值化处理都是在灰度图的基础上完成的,所以都使用了 QImage::Format_Grayscale8格式.

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QMessageBox>


MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
        ui->menuBar->hide();    //隐藏菜单栏
        ui->mainToolBar->hide();//隐藏工具栏
        ui->statusBar->hide();  //隐藏状态栏
        setWindowTitle(tr("Qt_OpenCV二值化"));

        //初始化变量
        m_isOpenFile = false;
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
        QString fileName = QFileDialog::getOpenFileName(this,tr("Open Image"),".",tr("Image File(*.png *.jpg *.jpeg *.bmp)"));
        if (fileName.isEmpty())
        {
            return;
        }

        m_srcImage = imread(fileName.toLatin1().data());//读取图片数据
        if (!m_srcImage.data)
        {
            m_isOpenFile = false;
            QMessageBox box(QMessageBox::Critical, "打开图像", "读取图像文件失败!请重新打开.");
            box.setStandardButtons(QMessageBox::Ok);
            box.setButtonText(QMessageBox::Ok, QString("确定"));
            box.exec();
            return;
        }

        m_isOpenFile = true;//修改打开标志

        Mat disImageTemp;
        cvtColor(m_srcImage, disImageTemp, COLOR_BGR2RGB);//图像格式转换
        QImage disImage = QImage((const unsigned char*)(disImageTemp.data),disImageTemp.cols,disImageTemp.rows,QImage::Format_RGB888);
        ui->label_Display->setPixmap(QPixmap::fromImage(disImage.scaled(ui->label_Display->size(), Qt::KeepAspectRatio)));//显示图像

        on_Gray();
        on_Bin_Black();
        on_Bin_White();
  }

void MainWindow::on_Gray()
{
    //Mat m_grayImage;
    //int bytePerLine=(width*image->depth()+31)/8;
    cvtColor(m_srcImage, m_grayImage, COLOR_BGR2GRAY);//图像格式转换
    QImage disImage = QImage((const unsigned char*)(m_grayImage.data),m_grayImage.cols,m_grayImage.rows,QImage::Format_Grayscale8);//注意灰度有它的格式,这种图片每个像素只用了8bit存储灰度颜色值
    //img = QImage((const unsigned char*)(gray.data),gray.cols,gray.rows,gray.step,  QImage::Format_Indexed8)
    ui->label_Gray->setPixmap(QPixmap::fromImage(disImage.scaled(ui->label_Gray->size(),Qt::KeepAspectRatio)));
}

void MainWindow::on_Bin_Black()
{
    adaptiveThreshold(m_grayImage, m_binImage, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, -9);
    /** @brief 自适应二值化
    *@param _src     要二值化的灰度图
    *@param _dst     二值化后的图
    *@param maxValue    二值化后要设置的那个值
    *@param method 块计算的方法(ADAPTIVE_THRESH_MEAN_C 平均值,ADAPTIVE_THRESH_GAUSSIAN_C 高斯分布加权和)
    *@param type     二值化类型(CV_THRESH_BINARY 大于为最大值,CV_THRESH_BINARY_INV 小于为最大值)
    *@param blockSize    块大小(奇数,大于1)
    *@param delta 差值(负值底色为黑色)
    */
    QImage disImage = QImage((const unsigned char*)(m_binImage.data),m_binImage.cols,m_binImage.rows,QImage::Format_Grayscale8);
    ui->label_Bin->setPixmap(QPixmap::fromImage(disImage.scaled(ui->label_Bin->width(), ui->label_Bin->height(), Qt::KeepAspectRatio)));
}
void MainWindow::on_Bin_White(){
    adaptiveThreshold(m_grayImage, m_binImage, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, 9);
    /** @brief 自适应二值化
    *@param _src     要二值化的灰度图
    *@param _dst     二值化后的图
    *@param maxValue    二值化后要设置的那个值
    *@param method 块计算的方法(ADAPTIVE_THRESH_MEAN_C 平均值,ADAPTIVE_THRESH_GAUSSIAN_C 高斯分布加权和)
    *@param type     二值化类型(CV_THRESH_BINARY 大于为最大值,CV_THRESH_BINARY_INV 小于为最大值)
    *@param blockSize    块大小(奇数,大于1)
    *@param delta 差值(正值底色为白色)
    */
    QImage disImage = QImage((const unsigned char*)(m_binImage.data),m_binImage.cols,m_binImage.rows,QImage::Format_Grayscale8);
    ui->label_Final->setPixmap(QPixmap::fromImage(disImage.scaled(ui->label_Final->width(), ui->label_Final->height(), Qt::KeepAspectRatio)));
}

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include "opencv2/opencv.hpp"
#include "opencv2\imgproc\types_c.h"
using namespace cv;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void on_pushButton_clicked();

private:
    Ui::MainWindow *ui;
    bool m_isOpenFile;

    Mat m_srcImage;
    Mat m_grayImage;
    Mat m_binImage;
    Mat m_finalImage;

public:
    void on_Gray(void);
    void on_Bin_Black(void);
    void on_Bin_White(void);
};

#endif

pro文件:

#-------------------------------------------------
#
# Project created by QtCreator 2019-07-12T14:41:02
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = OpenCV_Filter
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

CONFIG += c++11

SOURCES += \
        main.cpp \
        mainwindow.cpp

HEADERS += \
        mainwindow.h

FORMS += \
        mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
INCLUDEPATH += $$PWD/../opencv_qt/include\
             $$PWD/../opencv_qt/include/opencv\
              $$PWD/../opencv_qt/include/opencv2

unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_calib3d410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_core410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_dnn410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_features2d410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_flann410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_highgui410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_imgcodecs410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_imgproc410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_ml410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_objdetect410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_photo410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_stitching410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_video410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -llibopencv_videoio410
unix|win32: LIBS += -L$$PWD/../opencv_qt/bin/ -lopencv_ffmpeg410

演示效果:

python cv2 灰度图 重心 opencv灰度图像二值化处理_灰度二值化_03

python cv2 灰度图 重心 opencv灰度图像二值化处理_dial控件_04

 

以下是个待解决的bug!

尝试加入了一个新控件dial

编译通过,运行就崩溃:

OpenCV: terminate handler is called! The last OpenCV error is:

OpenCV(4.1.0) Error: Assertion failed (src && dst && count > 0) in FilterEngine__proceed, file D:/opencv/opencv/sources/modules/imgproc/src/filter.simd.hpp, line 220

Invalid parameter passed to C runtime function.

至今没有解决感到很迷惑,然而这个控件不关联blocksize和delta的时候整个程序都可以运作成功,二值化函数不是可以就地的吗.....

如果有大佬明白还望指点迷津,感谢!!!

崩溃码:

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include "opencv2/opencv.hpp"
#include "opencv2\imgproc\types_c.h"
using namespace cv;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void on_pushButton_clicked();

    void on_dial_block_valueChanged(int value);

    void on_dial_delta_valueChanged(int value);

private:
    Ui::MainWindow *ui;
    bool m_isOpenFile;

    Mat m_srcImage;
    Mat m_grayImage;
    Mat m_binImage;
    Mat m_finalImage;

    int blocksize;
    int delta;

public:
    void on_Gray(void);
    void on_Bin_Black(void);
    void on_Bin_White(void);
};

#endif

mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QMessageBox>
//#include <QDial>

#define B_MIN_VALUE 1
#define B_MAX_VALUE 10
#define D_MAX_VALUE 5
#define D_MIN_VALUE 0

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
        ui->menuBar->hide();    //隐藏菜单栏
        ui->mainToolBar->hide();//隐藏工具栏
        ui->statusBar->hide();  //隐藏状态栏
        setWindowTitle(tr("Qt_OpenCV二值化"));

        //初始化变量
        m_isOpenFile = false;
        blocksize = 15;
        delta = 9;

        ui->dial_block->setMinimum(B_MIN_VALUE * 2 + 1);
        ui->dial_block->setMaximum(B_MAX_VALUE * 2 + 1);
        ui->dial_block->setValue(blocksize);
        ui->dial_block->setNotchTarget(1);
        ui->label_bvalue->setText(QString::number(blocksize));

        ui->dial_delta->setMinimum(D_MIN_VALUE);
        ui->dial_delta->setMaximum(D_MAX_VALUE);
        ui->dial_delta->setValue(delta);
        ui->dial_delta->setNotchTarget(1);
        ui->label_dvalue->setText(QString::number(delta));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
        QString fileName = QFileDialog::getOpenFileName(this,tr("Open Image"),".",tr("Image File(*.png *.jpg *.jpeg *.bmp)"));
        if (fileName.isEmpty())
        {
            return;
        }

        m_srcImage = imread(fileName.toLatin1().data());//读取图片数据
        if (!m_srcImage.data)
        {
            m_isOpenFile = false;
            QMessageBox box(QMessageBox::Critical, "打开图像", "读取图像文件失败!请重新打开.");
            box.setStandardButtons(QMessageBox::Ok);
            box.setButtonText(QMessageBox::Ok, QString("确定"));
            box.exec();
            return;
        }

        m_isOpenFile = true;//修改打开标志

        Mat disImageTemp;
        cvtColor(m_srcImage, disImageTemp, COLOR_BGR2RGB);//图像格式转换
        QImage disImage = QImage((const unsigned char*)(disImageTemp.data),disImageTemp.cols,disImageTemp.rows,QImage::Format_RGB888);
        ui->label_Display->setPixmap(QPixmap::fromImage(disImage.scaled(ui->label_Display->size(), Qt::KeepAspectRatio)));//显示图像

        on_Gray();
  }

void MainWindow::on_Gray()
{
    //Mat m_grayImage;
    //int bytePerLine=(width*image->depth()+31)/8;
    cvtColor(m_srcImage, m_grayImage, COLOR_BGR2GRAY);//图像格式转换
    QImage disImage = QImage((const unsigned char*)(m_grayImage.data),m_grayImage.cols,m_grayImage.rows,QImage::Format_Grayscale8);//注意灰度有它的格式,这种图片每个像素只用了8bit存储灰度颜色值
    //img = QImage((const unsigned char*)(gray.data),gray.cols,gray.rows,gray.step,  QImage::Format_Indexed8)
    ui->label_Gray->setPixmap(QPixmap::fromImage(disImage.scaled(ui->label_Gray->size(),Qt::KeepAspectRatio)));
}

void MainWindow::on_Bin_Black()
{
    adaptiveThreshold(m_grayImage, m_binImage, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, blocksize, delta);
    /** @brief 自适应二值化
    *@param _src     要二值化的灰度图
    *@param _dst     二值化后的图
    *@param maxValue    二值化后要设置的那个值
    *@param method 块计算的方法(ADAPTIVE_THRESH_MEAN_C 平均值,ADAPTIVE_THRESH_GAUSSIAN_C 高斯分布加权和)
    *@param type     二值化类型(CV_THRESH_BINARY 大于为最大值,CV_THRESH_BINARY_INV 小于为最大值)
    *@param blockSize    块大小(奇数,大于1)
    *@param delta 差值(负值底色为黑色)
    */
    delta = 0-delta;
    QImage disImage = QImage((const unsigned char*)(m_binImage.data),m_binImage.cols,m_binImage.rows,QImage::Format_Grayscale8);
    ui->label_Bin->setPixmap(QPixmap::fromImage(disImage.scaled(ui->label_Bin->width(), ui->label_Bin->height(), Qt::KeepAspectRatio)));
}

void MainWindow::on_Bin_White(){
    adaptiveThreshold(m_grayImage, m_binImage, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, blocksize, delta);
    /** @brief 自适应二值化
    *@param _src     要二值化的灰度图
    *@param _dst     二值化后的图
    *@param maxValue    二值化后要设置的那个值
    *@param method 块计算的方法(ADAPTIVE_THRESH_MEAN_C 平均值,ADAPTIVE_THRESH_GAUSSIAN_C 高斯分布加权和)
    *@param type     二值化类型(CV_THRESH_BINARY 大于为最大值,CV_THRESH_BINARY_INV 小于为最大值)
    *@param blockSize    块大小(奇数,大于1)
    *@param delta 差值(正值底色为白色)
    */
    QImage disImage = QImage((const unsigned char*)(m_binImage.data),m_binImage.cols,m_binImage.rows,QImage::Format_Grayscale8);
    ui->label_Final->setPixmap(QPixmap::fromImage(disImage.scaled(ui->label_Final->width(), ui->label_Final->height(), Qt::KeepAspectRatio)));
}
void MainWindow::on_dial_block_valueChanged(int value)
{
    blocksize = value;
    ui->label_bvalue->setText(QString::number(blocksize));
    on_Bin_Black();
    on_Bin_White();
}

void MainWindow::on_dial_delta_valueChanged(int value)
{
    delta = value;
    ui->label_dvalue->setText(QString::number(delta));
   on_Bin_Black();
   on_Bin_White();
}

python cv2 灰度图 重心 opencv灰度图像二值化处理_OPENCV_05

mainwindow.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>438</width>
    <height>416</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralWidget">
   <widget class="QLabel" name="label">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>10</y>
      <width>54</width>
      <height>12</height>
     </rect>
    </property>
    <property name="text">
     <string>原始图像:</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_2">
    <property name="geometry">
     <rect>
      <x>190</x>
      <y>10</y>
      <width>54</width>
      <height>12</height>
     </rect>
    </property>
    <property name="text">
     <string>灰度图像:</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_3">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>160</y>
      <width>111</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>二值图像(黑色底色)</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_4">
    <property name="geometry">
     <rect>
      <x>190</x>
      <y>160</y>
      <width>111</width>
      <height>16</height>
     </rect>
    </property>
    <property name="text">
     <string>二值图像(白色底色)</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_Display">
    <property name="geometry">
     <rect>
      <x>30</x>
      <y>40</y>
      <width>151</width>
      <height>111</height>
     </rect>
    </property>
    <property name="text">
     <string>origin</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_Gray">
    <property name="geometry">
     <rect>
      <x>210</x>
      <y>30</y>
      <width>151</width>
      <height>121</height>
     </rect>
    </property>
    <property name="text">
     <string>gray</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_Bin">
    <property name="geometry">
     <rect>
      <x>23</x>
      <y>181</y>
      <width>161</width>
      <height>131</height>
     </rect>
    </property>
    <property name="text">
     <string>bin black</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_Final">
    <property name="geometry">
     <rect>
      <x>213</x>
      <y>181</y>
      <width>161</width>
      <height>121</height>
     </rect>
    </property>
    <property name="text">
     <string>bin white</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton">
    <property name="geometry">
     <rect>
      <x>340</x>
      <y>320</y>
      <width>75</width>
      <height>23</height>
     </rect>
    </property>
    <property name="text">
     <string>打开图片</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_5">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>300</y>
      <width>61</width>
      <height>20</height>
     </rect>
    </property>
    <property name="text">
     <string>blocksize</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_6">
    <property name="geometry">
     <rect>
      <x>150</x>
      <y>300</y>
      <width>61</width>
      <height>20</height>
     </rect>
    </property>
    <property name="text">
     <string>delta</string>
    </property>
   </widget>
   <widget class="QDial" name="dial_block">
    <property name="geometry">
     <rect>
      <x>80</x>
      <y>300</y>
      <width>50</width>
      <height>64</height>
     </rect>
    </property>
   </widget>
   <widget class="QDial" name="dial_delta">
    <property name="geometry">
     <rect>
      <x>200</x>
      <y>300</y>
      <width>50</width>
      <height>64</height>
     </rect>
    </property>
   </widget>
   <widget class="QLabel" name="label_bvalue">
    <property name="geometry">
     <rect>
      <x>20</x>
      <y>330</y>
      <width>54</width>
      <height>12</height>
     </rect>
    </property>
    <property name="text">
     <string>TextLabel</string>
    </property>
   </widget>
   <widget class="QLabel" name="label_dvalue">
    <property name="geometry">
     <rect>
      <x>150</x>
      <y>330</y>
      <width>54</width>
      <height>12</height>
     </rect>
    </property>
    <property name="text">
     <string>TextLabel</string>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menuBar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>438</width>
     <height>23</height>
    </rect>
   </property>
  </widget>
  <widget class="QToolBar" name="mainToolBar">
   <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
   </attribute>
   <attribute name="toolBarBreak">
    <bool>false</bool>
   </attribute>
  </widget>
  <widget class="QStatusBar" name="statusBar"/>
 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <resources/>
 <connections/>
</ui>

编译通过,运行崩溃,很难受,唉.