2019-01-09 12:55:49 baidu_15952103 阅读数 2661
  • Python可视化界面编程课程 PyQt5实战网课 GUI在线视频...

    课程概述 本课程主要针对PyQT5中的界面部分(GUI)进行学习,分为三部分,包括初级GUI编程、进阶GUI编程和GUI编程实战。 初级GUI编程:从介绍编程环境搭建开始,然后分析最基础的单个窗口框架,接着介绍QT Designer,最后结合实例详细分析基本控件的使用。 进阶GUI编程:主要包括高级界面控件分析、布局管理介绍、信息与槽分析、图形与特效和扩展应用。 GUI编程实战:经典程序开发和微信好友数据分析。 本课程共55节课时,除前两节介绍和安装的课时外,其它每节课都有编程实例,购买本视频教程后,赠送的资料包括课程配套PPT和源码等,入群有老师提供在线解答学习中遇到的问题。 客服QQ群:671935288 请联系客服微信号:18958869699,加入微信群

    56351 人正在学习 去看看 林男

1.首先在Matalb命令行中输入guide指令:

2.点击open,打开我设计好的界面如下:

主界面主要包含两个axes来显示图像处理前后的效果。

3.下面来介绍本文设计的程序:

function varargout = gui(varargin)

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @gui_OpeningFcn, ...
                   'gui_OutputFcn',  @gui_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end

function gui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);

function varargout = gui_OutputFcn(hObject, eventdata, handles) 

varargout{1} = handles.output;

% --------------------------------------------------------------------
%文件
function open_Callback(hObject, eventdata, handles)%打开图片
global im   %定义一个全局变量im
global im2
[filename,pathname]=...
    uigetfile({'*.*';'*.bmp';'*.tif';'*.png'},'select picture');  %选择图片路径
str=[pathname filename];  %合成路径+文件名
im=imread(str);   %读取图片
im2=im;
axes(handles.axes1);  %使用第一个axes
imshow(im);  %显示图片

function save_Callback(hObject, eventdata, handles)%保存图片
global BW 
set(handles.axes2,'HandleVisibility','ON');
axes(handles.axes2);
[filename,pathname]=uiputfile({'*.jpg';'*.bmp';'*.tif';'*.*'},'save image as');
file=strcat(pathname,filename);
BW=getimage(gca);
imwrite(BW,file);
set(handles.axes2,'HandleVisibility','Off');
function quit_Callback(hObject, ~, handles)%退出操作
close(gcf)  %关闭当前Figure窗口句柄

% --------------------------------------------------------------------
%菜单栏的调回函数,实际不使用
function t1_Callback(hObject, eventdata, handles)

function t2_Callback(hObject, eventdata, handles)

function t3_Callback(hObject, eventdata, handles)

function t4_Callback(hObject, eventdata, handles)

function t5_Callback(hObject, eventdata, handles)

function t6_Callback(hObject, eventdata, handles)

function t7_Callback(hObject, eventdata, handles)

function t8_Callback(hObject, eventdata, handles)

function t9_Callback(hObject, eventdata, handles)


% --------------------------------------------------------------------
% 图像类型变换
function rgb2gray_Callback(hObject, eventdata, handles)%原图-灰度
global im
global BW  %定义全局变量  
axes(handles.axes2); 
BW=rgb2gray(im);
im=BW;
imshow(BW);

function im2bw_Callback(hObject, eventdata, handles)%原图-二值
global im
global BW  %定义全局变量  
axes(handles.axes2); 
BW=im2bw(im);
im=BW;
imshow(BW);

function dither_Callback(hObject, eventdata, handles)%灰度-二值
global im
global BW  %定义全局变量  
axes(handles.axes2); 
BW=dither(im);
im=BW;
imshow(BW);

% --------------------------------------------------------------------
% 边缘检测
function roberts_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量
axes(handles.axes2);   %使用第二个axes
BW=edge(im,'roberts',0.04);
imshow(BW);

function sobel_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量
axes(handles.axes2);   %使用第二个axes
BW=edge(im,'sobel',0.04);
imshow(BW);

function prewitt_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量
axes(handles.axes2);   %使用第二个axes
BW=edge(im,'prewitt',0.04);
imshow(BW);

function log_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量
axes(handles.axes2);   %使用第二个axes
BW=edge(im,'log',0.003);
imshow(BW);

function canny_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量
axes(handles.axes2);   %使用第二个axes
BW=edge(im,'canny',0.2);
imshow(BW);


% --------------------------------------------------------------------
%图像变换
function DFT_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量
axes(handles.axes2); 
I1=double(im);
I2=fft2(I1);
I3=fftshift(I2);
I3=log(abs(I3));
BW=I3;
imshow(BW,[]);

function DCT_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量
axes(handles.axes2); 
I1=double(im);
I2=dct2(I1);
I3=log(abs(I2));
BW=I3;
imshow(BW);

% --------------------------------------------------------------------
% 图像旋转
function rotate_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量 
% A=getimage(handles.axes1);
A=im;
axes(handles.axes2); 
prompt={'度数:'};
def={'90'};
answer=inputdlg(prompt,'请输入:',1,def);
if ~isempty(answer)
a = str2num(answer{1});
J=imrotate(A,360-a);
BW=J;
imshow(BW);
end

function Initial_Callback(hObject, eventdata, handles)%初始化
global im
global im2
global BW  %定义全局变量 
BW=im2;
im=im2;
axes(handles.axes2); 
imshow(BW);

% --------------------------------------------------------------------
% 图像噪声添加
function gaussian_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量 
I=im2double(im);
J=imnoise(I,'gaussian');
BW=J;
axes(handles.axes2); 
imshow(BW);

function salt_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量 
I=im2double(im);
J=imnoise(I,'salt & pepper');
BW=J;
axes(handles.axes2); 
imshow(BW);

function speckle_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量 
I=im2double(im);
J=imnoise(I,'speckle');
BW=J;
axes(handles.axes2); 
imshow(BW);

function poisson_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量 
I=im2double(im);
J=imnoise(I,'poisson');
BW=J;
axes(handles.axes2); 
imshow(BW);

% --------------------------------------------------------------------
% 图像滤波
function medilt_Callback(hObject, eventdata, handles)%中值滤波
global BW  %定义全局变量 
J=medfilt2(BW, [3,3]);
BW=J;
axes(handles.axes2); 
imshow(BW);

function wiener_Callback(hObject, eventdata, handles)%自适应滤波
global BW  %定义全局变量 
J=wiener2(BW,[3,3]);
BW=J;
axes(handles.axes2); 
imshow(BW);

function filter2_Callback(hObject, eventdata, handles)%均值滤波
global BW  %定义全局变量 
M1=ones(3);
M1=M1/9;
J=filter2(M1,BW);
BW=J;
axes(handles.axes2); 
imshow(BW);

% --------------------------------------------------------------------
% 形态学图像处理
function bwmorph_Callback(hObject, eventdata, handles)%骨骼化
global im
global BW  %定义全局变量 
I=im2double(im);
I=im2bw(I);
J=bwmorph(I,'remove');
G=bwmorph(J,'skel',inf);
BW=G;
axes(handles.axes2); 
imshow(BW);

function imfill_Callback(hObject, eventdata, handles)%区域填充
global im
global BW  %定义全局变量 
axes(handles.axes2); 
I1=im2bw(im);

I2=1-I1;
se=ones(5);
I3=imerode(I2,se);
I4=1-I3;
I5=imerode(I4,se);
I6=imerode(I5,se);
I7=imdilate(I6,se);
BW=I7;

imshow(BW);

function diagonal_Callback(hObject, eventdata, handles)%对角线特征提取
global im
global BW  %定义全局变量 
axes(handles.axes2);
I1=im2bw(im);
v=[1,1,1,1,1,1,1,1,1,1];
se=diag(v);
I2=imerode(I1,se);
I3=imdilate(I2,se);
BW=I3;
imshow(BW);

% --------------------------------------------------------------------
%图像灰度变化
function plotchange_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量
axes(handles.axes2);   %使用第二个axes
A=im2double(im);
    a=0.3;%0.3 0.7 0.5 0.9
    b=0.7;
    c=0.1;
    d=0.9;
    %0.3 0.7 0.1 0.9
    B=A;
    [m,n]=size(B);
    Mg=max(max(B));
    Mf=max(max(A));
    for (i=1:m)
      for (j=1:n)
        if(A(i,j)>=0&&A(i,j)<=a)
             B(i,j)=(c/a)*A(i,j);
        end
        if(A(i,j)>=a&&A(i,j)<=b)
            B(i,j)=(((d-c)/(b-a))*(A(i,j)-a))+c;
        end
        if(A(i,j)>=b&&A(i,j)<=1)
             B(i,j)=(((Mg-d)/(Mf-b))*(A(i,j)-b))+d;
        end
      end
    end
   BW=B;
   imshow(BW);

function imhist_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量
axes(handles.axes2);   %使用第二个axes
 BW=im;
 imhist(BW);
 
function histeq_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量
axes(handles.axes2);   %使用第二个axes
BW=histeq(im);
imhist(BW);


% --------------------------------------------------------------------
function histeqafter_Callback(hObject, eventdata, handles)
global im
global BW  %定义全局变量
axes(handles.axes2);   %使用第二个axes
imshow(BW);

4.最终的生成界面如下。

将原图进行灰度化处理效果如下

5.GUI界面所实现的功能如下。

2017-02-12 14:48:47 attilax 阅读数 566
  • Python可视化界面编程课程 PyQt5实战网课 GUI在线视频...

    课程概述 本课程主要针对PyQT5中的界面部分(GUI)进行学习,分为三部分,包括初级GUI编程、进阶GUI编程和GUI编程实战。 初级GUI编程:从介绍编程环境搭建开始,然后分析最基础的单个窗口框架,接着介绍QT Designer,最后结合实例详细分析基本控件的使用。 进阶GUI编程:主要包括高级界面控件分析、布局管理介绍、信息与槽分析、图形与特效和扩展应用。 GUI编程实战:经典程序开发和微信好友数据分析。 本课程共55节课时,除前两节介绍和安装的课时外,其它每节课都有编程实例,购买本视频教程后,赠送的资料包括课程配套PPT和源码等,入群有老师提供在线解答学习中遇到的问题。 客服QQ群:671935288 请联系客服微信号:18958869699,加入微信群

    56351 人正在学习 去看看 林男

Atitit 软件项目的一整套解决方案(gui界面,中间,存储数据库,图像处理,全文搜索)attilax总结

 

1.1. 项目的常见构成模块(界面ui gui ,数据存储数据库,图像处理等) 2

1.2. 常见的界面ui模式gui cli 3

1.3. Gui的发展 native方案(swing qt winform>>xml方案(wpf javafx qml qss),私有h5》》dsl方案h5 4

1.4. 编程语言 5

1.5. 软件的运行模式:编译运行与直接源码运行(解释执行) 5

1.6. 数据库存储 6

1.7. 图像编程处理的四大金刚halcon matlab opencv photoshop 7

1.8. 全文检索 8

 


1.1. 项目的常见构成模块(界面ui gui ,数据存储数据库,图像处理等)

做出一款软件项目的常见要素有。。

依赖类库::通用的半成品软件。。代码包等。。站在巨人的肩膀上,君子善假于物也

语言::特点的环境使用特定的语言。。现在的混合编程模型是趋势,也需要混合多种编程语言来完成软件(一般一个通用语言GPL和多款DSL领域特定语言)

运行环境::一般是桌面   web 手机等,,还分为原生   h5  hybrid混合模式等。。

软件架构: cs bs web hybrid 跨架构是趋势,即是一个软件可以运行在web模式下,也可以运行在桌面gui模式,或者混合模式,一般是web优先,然后套一个本地shell

跨平台操作系统: 一般可以跨越linux win 等操作系统。。甚至安卓 ios等。。

 

 

 


1.2. 常见的界面ui模式gui cli

 

Gui模式一般俩中实现,一个基于dom模型,一个基于像素级别,性能高,但是事件模型需要自己实现,繁琐。。

普通软件大部分是属于dom模型。。一部分游戏也用像素模型,特别是比较需求性能的


1.3. Gui的发展 native方案(swing qt winform>>xml方案(wpf javafx qml qss),私有h5》》dsl方案h5

 

效果图

 

native方案大概如图

 JButton btn2=new JButton();  btn.setText("按钮文字")

 

native方案的缺点,受限于通用语言的语法限制,语法噪音太多,啰嗦,可读性较差。。面对嵌套层次结构界面设计可读性很差

 

 

xml方案,比如javafx fxml方案。。

<Buttonfx text="按钮文字" />   

可以看到简洁很多了,解决了可读性问题,语法噪音问题,层次结构问题。但是,私有的,不是标准化的。。

第三阶段,H5阶段(html5

<button  >按钮文字</button>标准化的问题。。

主要解决了标准化的问题。。至此阶段,gui 界面方面的dsl已经发展比较好了。。

 


1.4. 编程语言 

编程语言分类:命令式java c# js,函数式sql , 逻辑式语言等。。

 

按照是否编译,可以分为编译型语言和脚本语言。。脚本语言一般更加简化。。

按照通用与专用,可分为GPL 通用语言 Generalized Programming Language 通用编程语言dsl领域特定语言

按照代际划分,有一代汇编类,二代native本地编译语言(c c++),三代vm类型语言(java c# ) ,脚本语言也有时称为三代半语言,常用的js py php4gl一般就是dsl,常用的dslh5(html) sql等。。

 

 

编程语言的发展 从机器语言,汇编语言到本地native语言(c c++) vm语言(java  c#) 再到脚本语言(js php python) 再到dsl

语言层次越高,可读性一般越好,可移植性越好,不过性能也越差了。。当然如果使用同样的类库的话,只是写点胶水代码的话,差别到是相对来说不大了。

 

机器语言, 可以说彻底淘汰,唯一的优点就是性能,其他基本全是缺点。。

汇编语言,貌似也基本淘汰,比起机器语言,提升了很大的可读性。。

native语言(c c++) 相对汇编语言可读性又大幅提升,性能方面不如汇编,但比vm语言要高。。。缺点是开发效率,以及可移植性仍然需要提升。。很多图像库貌似都是使用此开发。。依赖于性能的应用大有所为。

vm语言(java  c#)  改进了native语言的问题,增加一个vm层隔离开了os。目前的业界高层应用开发主力

脚本语言 带来更高的生产力。但目前ide的问题,大型复杂企业级开发还难当重任,目前貌似在轻复杂度代码领域比较大发展。

Dsl语言 ,领域特定语言。。比如H5做界面。。Sql做数据库查询。Matlab halcon使用的语言,用来做图像处理。。

更高的开发效率,特别对于特定领域,图像处理,界面,数据库查询等大有优势。。正则表达式,用来文本搜索等。

Dsl语言本身性能很差,但是它是调用类库的,类库使用底层语言书写的,所以对性能不影响。

 

 

1.5. 软件的运行模式:编译运行与直接源码运行(解释执行)


1.6. 数据库存储

数据库相当于一个高级的excel。。。

 

表头定义

 

 

数据显示与维护

 

 


1.7. 图像编程处理的四大金刚halcon matlab opencv photoshop

 

图像方面的编程处理也是非常的与广泛了,比如人脸识别,指纹识别,二维码扫描等,条码,拍照识别等。。

 

opencv

 编辑

OpenCV全称是:Open Source Computer Vision LibraryOpenCV是一个基于BSD许可(开源)发行的跨平台计算机视觉库

halcon 

 

HALCON是德国MVtec公司开发的一套完善的标准的机器视觉算法包,拥有应用广泛的机器视觉集成开发环境

MATLAB是美国MathWorks公司出品的商业数学与图像处理软件,

 

Photoshop::知名的图像处理软件了。。公开只提供gui接口。。用来测试,调试,验证一些图像处理的很有用。。直接通过gui接口调用ps也是某些情况下的很好选择。。

 

当然一些非常频繁的图像处理都已经有成熟的类库,算法库等,可以直接几行代码调用,较为方便的集成到自己的软件当中。。

 


1.8. 全文检索

全文检索一般处理文章搜索的大量文字搜索,数据库默认的like搜索对这种大文字搜索性能很差。。。。

 

搜索主要分俩中一种是遍历搜索,扫描一遍。。小数据量下还可,大数据量当然就不行了

一种是索引搜索,就是做个目录,类似与分类,书籍目录,可以快速定位到需要的数据。。。

 

索引的实质,即是分类处理,就像我们数据的目录编排一样。。。

 

 

 

2019-01-07 11:32:28 qq_38233696 阅读数 1125
  • Python可视化界面编程课程 PyQt5实战网课 GUI在线视频...

    课程概述 本课程主要针对PyQT5中的界面部分(GUI)进行学习,分为三部分,包括初级GUI编程、进阶GUI编程和GUI编程实战。 初级GUI编程:从介绍编程环境搭建开始,然后分析最基础的单个窗口框架,接着介绍QT Designer,最后结合实例详细分析基本控件的使用。 进阶GUI编程:主要包括高级界面控件分析、布局管理介绍、信息与槽分析、图形与特效和扩展应用。 GUI编程实战:经典程序开发和微信好友数据分析。 本课程共55节课时,除前两节介绍和安装的课时外,其它每节课都有编程实例,购买本视频教程后,赠送的资料包括课程配套PPT和源码等,入群有老师提供在线解答学习中遇到的问题。 客服QQ群:671935288 请联系客服微信号:18958869699,加入微信群

    56351 人正在学习 去看看 林男

此次登录界面完全是为了后面的图像处理GUI界面所添加的点睛之笔,不喜勿喷。
界面建立所要调用的模块:

import tkinter as tk
import tkinter.messagebox
import pickle
from tux import Image_sys   #调用文件tux

登陆主界面搭建,三个文本数据输入框,三个按钮。

  # 窗口
        window = tk.Tk()
        window.title('欢迎进入图像处理系统')
        window.geometry('690x500')
        # 画布放置图片
        canvas=tk.Canvas(window,height=400,width=800)
        imagefile=tk.PhotoImage(file='hdu3.png')
        image=canvas.create_image(0,0,anchor='nw',image=imagefile)
        canvas.pack(side='top')`在这里插入代码片`
        # 标签 用户名密码
        tk.Label(window, text='用户名:').place(x=200, y=320)
        tk.Label(window, text='密码:').place(x=200, y=360)
        # 用户名输入框
        var_usr_name = tk.StringVar()
        entry_usr_name = tk.Entry(window, textvariable=var_usr_name)
        entry_usr_name.place(x=260, y=320)
        # 密码输入框
        var_usr_pwd = tk.StringVar()
        entry_usr_pwd = tk.Entry(window, textvariable=var_usr_pwd, show='*')
        entry_usr_pwd.place(x=260, y=360)
        # 登录 注册按钮
        bt_login = tk.Button(window, text='登录', command=usr_log_in)
        bt_login.place(x=260, y=400)
   	    bt_logup = tk.Button(window, text='注册', command=usr_sign_up)
        bt_logup.place(x=330, y=400)
        bt_logquit = tk.Button(window, text='退出', command=usr_sign_quit)
        bt_logquit.place(x=400, y=400)

在这里插入图片描述
登陆函数,这里我们所需要的用户名和登陆密码都是经过注册函数所保存的本地字典文件usr_info.pickle中,用户名作为键,密码存为值,一一对应关系。登陆函数根据输入值,读取字典里的用户名与密码判断字典内是否存在相应数据实现登陆匹配,若输入用户名键而不匹配相应的值,则弹出提示框 ‘密码错误’,若输入用户名不存在或者为空,则弹出提示框’欢迎’, ‘您还没有注册,是否现在注册’

# 登录函数
def usr_log_in():
    # 输入框获取用户名密码
    usr_name = var_usr_name.get()
    usr_pwd = var_usr_pwd.get()
    # 从本地字典获取用户信息,如果没有则新建本地数据库
    try:
        with open('usr_info.pickle', 'rb') as usr_file:
            usrs_info = pickle.load(usr_file)
    except FileNotFoundError:
        with open('usr_info.pickle', 'wb') as usr_file:
            usrs_info = {'admin': 'admin'}
            pickle.dump(usrs_info, usr_file)
    # 判断用户名和密码是否匹配
    if usr_name in usrs_info:
        if usr_pwd == usrs_info[usr_name]:
            tk.messagebox.showinfo(title='welcome',
                                   message='欢迎您:' + usr_name)
            window.destroy()
            Image_sys()       #打开主界面

        else:
            tk.messagebox.showerror(message='密码错误')
    # 用户名密码不能为空
    elif usr_name == '' or usr_pwd == '':
        tk.messagebox.showerror(message='用户名或密码为空')
    # 不在数据库中弹出是否注册的框
    else:
        is_signup = tk.messagebox.askyesno('欢迎', '您还没有注册,是否现在注册')
        if is_signup:
            usr_sign_up() #打开注册界面

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

注册函数,我们建立注册子界面,通过新建三个文本输入框, 用户名变量,密码变量,重复密码变量来进行数据输入,首先要获取这三个输入框中的数据,判断本地字典内是否存在已注册数据,若存在则弹出提示框’错误’, ‘用户名已存在’ ,重复密码判断前后密码输入是否一致,若不同则弹出提示框 ‘错误’, ‘密码前后不一致’ ,若获取的数据均不存在于本地字典中且前后密码变量一致,则将获取数据存入字典当中,并弹出提示框(‘欢迎’, ‘注册成功’)。

# 注册函数
def usr_sign_up():
    # 确认注册时的相应函数
    def signtowcg():
        # 获取输入框内的内容
        nn = new_name.get()
        np = new_pwd.get()
        npf = new_pwd_confirm.get()

        # 本地加载已有用户信息,如果没有则已有用户信息为空
        try:
            with open('usr_info.pickle', 'rb') as usr_file:
                exist_usr_info = pickle.load(usr_file)
        except FileNotFoundError:
            exist_usr_info = {}

            # 检查用户名存在、密码为空、密码前后不一致
        if nn in exist_usr_info:
            tk.messagebox.showerror('错误', '用户名已存在')
        elif np == '' or nn == '':
            tk.messagebox.showerror('错误', '用户名或密码为空')
        elif np != npf:
            tk.messagebox.showerror('错误', '密码前后不一致')
        # 注册信息没有问题则将用户名密码写入数据库
        else:
            exist_usr_info[nn] = np
            with open('usr_info.pickle', 'wb') as usr_file:
                pickle.dump(exist_usr_info, usr_file)
            tk.messagebox.showinfo('欢迎', '注册成功')
            # 注册成功关闭注册框
            window_sign_up.destroy()

注册界面建立,设置三个文本输入框,与一个按键。

# 新建注册界面
    window_sign_up = tk.Toplevel(window)
    window_sign_up.geometry('350x200')
    window_sign_up.title('注册')
    # 用户名变量及标签、输入框
    new_name = tk.StringVar()
    tk.Label(window_sign_up, text='用户名:').place(x=10, y=10)
    tk.Entry(window_sign_up, textvariable=new_name).place(x=150, y=10)
    # 密码变量及标签、输入框
    new_pwd = tk.StringVar()
    tk.Label(window_sign_up, text='请输入密码:').place(x=10, y=50)
    tk.Entry(window_sign_up, textvariable=new_pwd, show='*').place(x=150, y=50)
    # 重复密码变量及标签、输入框
    new_pwd_confirm = tk.StringVar()
    tk.Label(window_sign_up, text='请再次输入密码:').place(x=10, y=90)
    tk.Entry(window_sign_up, textvariable=new_pwd_confirm, show='*').place(x=150, y=90)
    # 确认注册按钮及位置
    bt_confirm_sign_up = tk.Button(window_sign_up, text='确认注册',
                                   command=signtowcg)
    bt_confirm_sign_up.place(x=150, y=130)

在这里插入图片描述

这是一个简单的登录界面操作,大多系统的登录都是遵从这样的流程,以后有了新的想法会做好相应优化。

2017-02-28 21:45:11 woshiluoye9 阅读数 229
  • Python可视化界面编程课程 PyQt5实战网课 GUI在线视频...

    课程概述 本课程主要针对PyQT5中的界面部分(GUI)进行学习,分为三部分,包括初级GUI编程、进阶GUI编程和GUI编程实战。 初级GUI编程:从介绍编程环境搭建开始,然后分析最基础的单个窗口框架,接着介绍QT Designer,最后结合实例详细分析基本控件的使用。 进阶GUI编程:主要包括高级界面控件分析、布局管理介绍、信息与槽分析、图形与特效和扩展应用。 GUI编程实战:经典程序开发和微信好友数据分析。 本课程共55节课时,除前两节介绍和安装的课时外,其它每节课都有编程实例,购买本视频教程后,赠送的资料包括课程配套PPT和源码等,入群有老师提供在线解答学习中遇到的问题。 客服QQ群:671935288 请联系客服微信号:18958869699,加入微信群

    56351 人正在学习 去看看 林男

Java的图像界面一般分为两种:
AWT(Abstract Window Toolkit) ,抽象窗口工具集,第一代的Java GUI 组件,是重量级的,依赖于底层和操作系统,同样的代码,在不同的系统上运行,就界面而言,感官上看起来是不一样的。基本的AWT库处理用户界面元素的方法是把这些元素的创建和行为委托给每个目标平台(Windows,Unix,等)的本地GUI工具进行处理的。
Swing,不依赖于底层细节,轻量级的组件。

AWT:
1. Frames 构造方法 frame(String title),创建一个带标题的框,设置setVisible(true)可见, setSize设置大小

  1. Dialog 对话框

  2. 布局管理器: 容器中组件的大小和位置由布局管理器实现,AWT提供了五种布局管理器:
    BorderLayout,默认布局,分为东西南北中五个方位,缩放时,按钮相应的位置不变化,但是其大小改变
    FlowLayout, 不限制它所管理的组件大小,而是允许他们有自己的最佳大小,默认居中放置
    GridLayout, 创建行与列来分割整个布局空间,将元素填充到分割开的一个个格子中去 new GridLayout(3, 2),创建了6个位置,3行2列,所有的格子的大小是相同的
    CardLayout,
    GirdBagLayout

  3. Pannel 面板,继承自Frame类 ,继承自Container,可以在Frame上添加面板, Pannel的默认布局是FlowLayout的

  4. Button 按钮

AWT事件模型:

事件-描述发生了什么的对象 ,存在着各种不同类型的事件类用来描述各种类型的用户交互
事件源-事件的产生器
事件处理器-接收事件、解释事件并处理用户交互的方法

以Button为例说明:
当单击一个按钮时就会产生一个事件(ActionEvent),然后检查是否有与该按钮关联的事件处理器(实际上就是一个方法),如果没有,那么什么都不执行;如果有,就会将该事件传递给与该按钮关联的事件处理器方法,作为该方法的参数,之后该事件处理器方法就会自动得到调用,并且该方法可以使用传递过来的 ActionEvent 对象,进而获得事件发生时与该事件及事件源相关联的那些信息。

Java中的组件若想添加事件处理器,都会使用形如 addXxxListener 的方法来添加。

几类具有典型代表意义的事件:
MouseEvent: 鼠标事件,鼠标按下、释放、点击、双击
WindowEvent: 窗口事件,点击关闭按钮,窗口最大化,最小化,窗口得到或者失去焦点
ActionEvent: 动作事件,比如按钮按下

2017-04-18 23:37:18 cg_Amaz1ng 阅读数 5155
  • Python可视化界面编程课程 PyQt5实战网课 GUI在线视频...

    课程概述 本课程主要针对PyQT5中的界面部分(GUI)进行学习,分为三部分,包括初级GUI编程、进阶GUI编程和GUI编程实战。 初级GUI编程:从介绍编程环境搭建开始,然后分析最基础的单个窗口框架,接着介绍QT Designer,最后结合实例详细分析基本控件的使用。 进阶GUI编程:主要包括高级界面控件分析、布局管理介绍、信息与槽分析、图形与特效和扩展应用。 GUI编程实战:经典程序开发和微信好友数据分析。 本课程共55节课时,除前两节介绍和安装的课时外,其它每节课都有编程实例,购买本视频教程后,赠送的资料包括课程配套PPT和源码等,入群有老师提供在线解答学习中遇到的问题。 客服QQ群:671935288 请联系客服微信号:18958869699,加入微信群

    56351 人正在学习 去看看 林男

数字图像处理——Matlab GUI与灰度变换函数

简介

Matlab具有强大的函数运算功能,利用这一点可以进行像素级的计算,也就是图像处理。这款软件基于Matlab平台,用户可以在软件界面中打开需要修改的图片,选择想要变换的效果,通过拖动滑动条可以动态显示修改后的图片效果。

涉及到的图像处理包括以下三种灰度变换:

  • 二值化

  • 伽马变换

  • 对数变换

使用方法

不允许修改空图片,必须打开一张图片后才能获得修改图片的权限。

打开文件后,面板上显示两张图片,左边的是原图,右边的是原图副本,可以动态显示修改效果。如图:
这里写图片描述

其中PhotoProcess包含三个菜单项,分别是

  • BinaryImage:图像二值化处理
  • Gamma Trans:伽马变换
  • Log Trans:对数变换

下面分别对这三种功能进行演示:

图像二值化

这里写图片描述

其中在子窗口中出现的拖动条可以动态调整二值化阀值(Threshold),这里取值0到1,从而显示出不一样的效果。

*伽马变换*

这里写图片描述
类似二值化功能,这里也有一个拖动条,可以动态调整γ值,我们知道伽马变换的表达式:

s=crγ

其中c取1,不再接受变化。

**对数变换

这里写图片描述

对数变换公式:

s=clogv+1(1+vr)

保存

退出的时候如果还未保存将提示是否需要保存。 可选格式为bmp和jpg格式。如图为修改后的图片
这里写图片描述

参考资料

[数字图像处理]灰度变换——反转,对数变换,伽马变换,灰度拉伸,灰度切割,位图切割

《一个实例搞定matlab界面编程》 https://wenku.baidu.com/view/fdf6ad6925c52cc58bd6be8e.html

附录:Matlab代码

DIP.m

function varargout = DIP(varargin)
% DIP MATLAB code for DIP.fig
%      DIP, by itself, creates a new DIP or raises the existing
%      singleton*.
%
%      H = DIP returns the handle to a new DIP or the handle to
%      the existing singleton*.
%
%      DIP('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DIP.M with the given input arguments.
%
%      DIP('Property','Value',...) creates a new DIP or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before DIP_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to DIP_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help DIP

% Last Modified by GUIDE v2.5 10-Apr-2017 16:55:51

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @DIP_OpeningFcn, ...
                   'gui_OutputFcn',  @DIP_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before DIP is made visible.
function DIP_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to DIP (see VARARGIN)

% Choose default command line output for DIP
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes DIP wait for user response (see UIRESUME)
% uiwait(handles.figure_DIP);
setappdata(handles.figure_DIP,'img_src',0);
set(handles.photoprocess,'Enable','off');
setappdata(handles.figure_DIP,'bSave',false);
setappdata(handles.figure_DIP,'bChanged',false);
setappdata(handles.figure_DIP,'fstSave',true);
setappdata(handles.figure_DIP,'fstPath',0);
set(handles.toolSave,'Enable','off');
set(handles.save,'Enable','off');
set(handles.axes1,'visible','off');
set(handles.axes2,'visible','off');
% --- Outputs from this function are returned to the command line.
function varargout = DIP_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --------------------------------------------------------------------
function file_Callback(hObject, eventdata, handles)
% hObject    handle to file (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function photoprocess_Callback(hObject, eventdata, handles)
% hObject    handle to photoprocess (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Untitled_8_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function help_Callback(hObject, eventdata, handles)
% hObject    handle to help (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function toBinary_Callback(hObject, eventdata, handles)
% hObject    handle to toBinary (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%axes(handles.axes2);
%img_src = getappdata(handles.figure_DIP,'img_src');
%imshow(img_src);
h = toBW;
setappdata(handles.figure_DIP,'bChanged',true);
set(handles.toolSave,'Enable','on');
set(handles.save,'Enable','on');
set(handles.axes2,'visible','on');
% --------------------------------------------------------------------
function gammatrans_Callback(hObject, eventdata, handles)
% hObject    handle to gammatrans (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
h = toGamma;
setappdata(handles.figure_DIP,'bChanged',true);
set(handles.toolSave,'Enable','on');
set(handles.save,'Enable','on');
set(handles.axes2,'visible','on');

% --------------------------------------------------------------------
function contrast_Callback(~, eventdata, handles)
% hObject    handle to contrast (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function brightness_Callback(hObject, eventdata, handles)
% hObject    handle to brightness (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function open_Callback(hObject, eventdata, handles)
% hObject    handle to open (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile({'*.bmp;*.jpg;*.png;*.jpeg', 'Image Files (*.bmp, *.jpg, *.png,*.jpeg)'; '*.*', 'All Files (*.*)'}, 'Pick an image');
if isequal(filename,0) || isequal(pathname,0),
    return;
end
axes(handles.axes1);%用axes命令设定当前操作的坐标轴是axes1
fpath=[pathname filename];%将文件名和目录名组合成一个完整的路径
img_src = imread(fpath);
imshow(img_src);
axes(handles.axes2);
imshow(img_src);
setappdata(handles.figure_DIP,'img_src',img_src);
set(handles.photoprocess,'Enable','on');
set(handles.axes1,'visible','on');
% --------------------------------------------------------------------
function save_Callback(hObject, eventdata, handles)
% hObject    handle to save (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
fstSave=getappdata(handles.figure_DIP,'fstSave');
if(fstSave==true)
    [filename, pathname] = uiputfile({'*.bmp','BMP files';'*.jpg;','JPG files'}, 'Pick an Image');
    if isequal(filename,0) || isequal(pathname,0)
        return;%如果点了“取消”
    else
        fpath=fullfile(pathname, filename);%获得全路径的另一种方法
    end    
    img_dst=getimage(handles.axes2);
    imwrite(img_dst,fpath);%保存图片
    setappdata(handles.figure_DIP,'fstPath',fpath);
    setappdata(handles.figure_DIP,'bSave',true);
    setappdata(handles.figure_DIP,'fstSave',false);
else
    img_dst=getimage(handles.axes2);
    fpath=getappdata(handles.figure_DIP,'fstPath');
    imwrite(img_dst,fpath);
end
% --------------------------------------------------------------------
function exit_Callback(hObject, eventdata, handles)
% hObject    handle to exit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
bChanged=getappdata(handles.figure_DIP,'bChanged');%获得是否更改
bSave=getappdata(handles.figure_DIP,'bSave');%获得是否保存
if bChanged==true && bSave==false,%更改了,而没保存时
    btnName=questdlg('Not Saved Yet','Warning','save','leave','save');%用提问对话框
    switch btnName,
      case 'save', %执行axes_dst_menu_save_Callback的功能
        feval(@save_Callback,handles.save,eventdata,handles);
      case 'leave',%什么也不做
    end
end
h=findobj('Tag','figure_toBW');%查找是否打开设置图像二值化参数窗口
hh=findobj('Tag','figure_toLogTrans');
hhh=findobj('Tag','figure_toGamma');
if ~isempty(h),%找到的话,则关闭
  close(h);
  close(hh);
  close(hhh);
end
close(findobj('Tag','figure_DIP'));%关闭主窗口


% --------------------------------------------------------------------
function toolOpen_ClickedCallback(hObject, eventdata, handles)
% hObject    handle to toolOpen (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
feval(@open_Callback,handles.open,eventdata,handles);


% --------------------------------------------------------------------
function toolSave_ClickedCallback(hObject, eventdata, handles)
% hObject    handle to toolSave (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
feval(@save_Callback,handles.save,eventdata,handles);


% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to axes1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
set(hObject,'xTick',[]);
set(hObject,'ytick',[]);
set(hObject,'box','on');
% Hint: place code in OpeningFcn to populate axes1


% --- Executes during object creation, after setting all properties.
function axes2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to axes2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
set(hObject,'xTick',[]);
set(hObject,'ytick',[]);
set(hObject,'box','on');
% Hint: place code in OpeningFcn to populate axes2


% --------------------------------------------------------------------
function logtrans_Callback(hObject, eventdata, handles)
% hObject    handle to logtrans (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%axes(handles.axes2);
%img_src = getappdata(handles.figure_DIP,'img_src');
%imshow(img_src);
h = toLogTrans;
setappdata(handles.figure_DIP,'bChanged',true);
set(handles.toolSave,'Enable','on');
set(handles.save,'Enable','on');
set(handles.axes2,'visible','on');

toBW.m

function varargout = toBW(varargin)
% TOBW MATLAB code for toBW.fig
%      TOBW, by itself, creates a new TOBW or raises the existing
%      singleton*.
%
%      H = TOBW returns the handle to a new TOBW or the handle to
%      the existing singleton*.
%
%      TOBW('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in TOBW.M with the given input arguments.
%
%      TOBW('Property','Value',...) creates a new TOBW or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before toBW_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to toBW_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help toBW

% Last Modified by GUIDE v2.5 10-Apr-2017 00:49:18

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @toBW_OpeningFcn, ...
                   'gui_OutputFcn',  @toBW_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before toBW is made visible.
function toBW_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to toBW (see VARARGIN)

% Choose default command line output for toBW
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);
%找到原始界面的句柄
HH = findobj('Tag','figure_DIP');
DIP = guihandles(HH);
setappdata(handles.figure_toBW,'DIP',DIP)
% UIWAIT makes toBW wait for user response (see UIRESUME)
% uiwait(handles.figure_toBW);


% --- Outputs from this function are returned to the command line.
function varargout = toBW_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
val = get(hObject,'Value');
set(handles.text_bw,'String',num2str(val));
DIP = getappdata(handles.figure_toBW,'DIP');
axes(DIP.axes2);
img_src = getappdata(DIP.figure_DIP,'img_src');
bw = im2bw(img_src,val);
imshow(bw);


% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

LogTrans.m

function   [g] = LogTrans(f,c,v)
%此处显示详细说明
    h = mat2gray(f,[0,255]);
    g = c*log2(1+v*h)/log2(v+1);
end

toLogTrans.m

function varargout = toLogTrans(varargin)
% TOLOGTRANS MATLAB code for toLogTrans.fig
%      TOLOGTRANS, by itself, creates a new TOLOGTRANS or raises the existing
%      singleton*.
%
%      H = TOLOGTRANS returns the handle to a new TOLOGTRANS or the handle to
%      the existing singleton*.
%
%      TOLOGTRANS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in TOLOGTRANS.M with the given input arguments.
%
%      TOLOGTRANS('Property','Value',...) creates a new TOLOGTRANS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before toLogTrans_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to toLogTrans_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help toLogTrans

% Last Modified by GUIDE v2.5 10-Apr-2017 16:41:28

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @toLogTrans_OpeningFcn, ...
                   'gui_OutputFcn',  @toLogTrans_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before toLogTrans is made visible.
function toLogTrans_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to toLogTrans (see VARARGIN)

% Choose default command line output for toLogTrans
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);
%找到原始界面的句柄
HH = findobj('Tag','figure_DIP');
DIP = guihandles(HH);
setappdata(handles.figure_toLogTrans,'DIP',DIP)
setappdata(handles.figure_toLogTrans,'val_C',0);
setappdata(handles.figure_toLogTrans,'val_V',0);
% UIWAIT makes toLogTrans wait for user response (see UIRESUME)
% uiwait(handles.figure_toLogTrans);


% --- Outputs from this function are returned to the command line.
function varargout = toLogTrans_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
val_C = get(hObject,'Value');
set(handles.text2,'String',num2str(val_C));
setappdata(handles.figure_toLogTrans,'val_C',val_C);
val_V = getappdata(handles.figure_toLogTrans,'val_V');
DIP = getappdata(handles.figure_toLogTrans,'DIP');
axes(DIP.axes2);
img_src = getappdata(DIP.figure_DIP,'img_src');
bw = LogTrans(img_src,val_C,val_V);
imshow(bw);

% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
val_V = get(hObject,'Value');
set(handles.text4,'String',num2str(val_V));
setappdata(handles.figure_toLogTrans,'val_V',val_V);
val_C = getappdata(handles.figure_toLogTrans,'val_C');
DIP = getappdata(handles.figure_toLogTrans,'DIP');
axes(DIP.axes2);
%img_src = getimage(DIP.axes2);
img_src = getappdata(DIP.figure_DIP,'img_src');
%bw = val_C*log2(1+val_V*img_src)/log2(val_V+1);
bw = LogTrans(img_src,val_C,val_V);
imshow(bw);
% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

toGamma.m

function varargout = toGamma(varargin)
% TOGAMMA MATLAB code for toGamma.fig
%      TOGAMMA, by itself, creates a new TOGAMMA or raises the existing
%      singleton*.
%
%      H = TOGAMMA returns the handle to a new TOGAMMA or the handle to
%      the existing singleton*.
%
%      TOGAMMA('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in TOGAMMA.M with the given input arguments.
%
%      TOGAMMA('Property','Value',...) creates a new TOGAMMA or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before toGamma_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to toGamma_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help toGamma

% Last Modified by GUIDE v2.5 10-Apr-2017 21:32:21

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @toGamma_OpeningFcn, ...
                   'gui_OutputFcn',  @toGamma_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before toGamma is made visible.
function toGamma_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to toGamma (see VARARGIN)

% Choose default command line output for toGamma
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);
%找到原始界面的句柄
HH = findobj('Tag','figure_DIP');
DIP = guihandles(HH);
setappdata(handles.figure_toGamma,'DIP',DIP)
% UIWAIT makes toGamma wait for user response (see UIRESUME)
% uiwait(handles.figure_toGamma);


% --- Outputs from this function are returned to the command line.
function varargout = toGamma_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
val = get(hObject,'Value');
set(handles.text2,'String',num2str(val));
DIP = getappdata(handles.figure_toGamma,'DIP');
axes(DIP.axes2);
img_src = getappdata(DIP.figure_DIP,'img_src');
c = 1;
bw = GammaTrans(img_src,c,val);
imshow(bw);

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

GammaTrans.m

function  [g]=GammaTrans(f,c,gamma)
%   此处显示详细说明
    h = mat2gray(f,[0,255]);
    g = c*(h.^gamma);
end

没有更多推荐了,返回首页