matlab图像去雾技术GUI界面-全局平衡直方图

Posted studyer_domi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了matlab图像去雾技术GUI界面-全局平衡直方图相关的知识,希望对你有一定的参考价值。

1、内容简介


431-可以交流、咨询、答疑

2、内容说明


3、仿真分析

function varargout = main(varargin)
% MAIN MATLAB code for main.fig
%      MAIN, by itself, creates a new MAIN or raises the existing
%      singleton*.
%
%      H = MAIN returns the handle to a new MAIN or the handle to
%      the existing singleton*.
%
%      MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAIN.M with the given input arguments.
%
%      MAIN('Property','Value',...) creates a new MAIN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before main_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to main_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 main

% Last Modified by GUIDE v2.5 14-Apr-2019 17:22:46

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

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


% --- Executes just before main is made visible.
function main_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 main (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes main wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = main_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
varargout1 = handles.output;


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
%        contentsget(hObject,'Value') returns selected item from popupmenu1
global Img2
%具体算法实现
val=get(handles.popupmenu1,'value');
switch val
    case 1
        if isequal(handles.Img1, 0)
            msgbox('请载入图像!', '提示信息');
            return;
        end
        Img2 = RemoveFogByGlobalHisteq(handles.Img1, 0);
        axes(handles.axes2); imshow(Img2, []);
    case 2
       if isequal(handles.Img1, 0)
             msgbox('请载入图像!', '提示信息');
             return;
       end
        Img2 = RemoveFogByLocalHisteq(handles.Img1, 0);
        axes(handles.axes2); imshow(Img2, []);
    case 3
        if isequal(handles.Img1, 0)
            msgbox('请载入图像!', '提示信息');
            return;
        end
        Img2 = RemoveFogByRetinex(handles.Img1, 0);
        axes(handles.axes2); imshow(Img2, []);
end

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

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% 打开
warning off all;
% 载入图像
[FileName,PathName] = uigetfile('*.jpg;*.tif;*.png;*.gif', ...
    '所有图像文件';...
    '*.*','所有文件' ,'载入图像',...
    '.\\images\\\\sweden_input.jpg');
if isequal(FileName, 0) || isequal(PathName, 0)
    return;
end
Img1 = imread(fullfile(PathName, FileName));
axes(handles.axes1);
imshow(Img1, []);
handles.Img1 = Img1;
handles.Img2 = 0;
guidata(hObject, handles);


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global Img1 Img2
%直方图
figure('Name', '直方图对比', 'NumberTitle', 'Off', ...
    'Units', 'Normalized', 'Position', [0.1 0.1 0.5 0.5]);
one = rgb2gray(handles.Img1);
two = rgb2gray(Img2);
subplot(2, 2, 1); imshow(handles.Img1); title('原图','FontWeight', 'Bold');
subplot(2, 2, 2); imshow(Img2, []); title('处理后的图','FontWeight', 'Bold');
subplot(2, 2, 3); imhist(one,64); title('原灰度直方图', 'FontWeight', 'Bold');
subplot(2, 2, 4); imhist(two,64); title('处理后的灰度直方图', 'FontWeight', 'Bold');


one = rgb2gray(handles.Img1);
axes(handles.axes3);
imhist(one,64);
axes(handles.axes4); 
imhist(two,64);

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% 截图保存
SnapImage();

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, ~)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%退出
close();


4、参考论文

 

 

以上是关于matlab图像去雾技术GUI界面-全局平衡直方图的主要内容,如果未能解决你的问题,请参考以下文章

matlab全局直方图均衡化和局部直方图均衡化的优缺点

图像增强及直方图均衡化在图像去雾上的应用(附matlab代码)

图像增强及直方图均衡化在图像去雾上的应用(附matlab代码)

图像增强及直方图均衡化在图像去雾上的应用(附matlab代码)

MATLAB可视化实战系列(二十五)-MATLAB基于直方图的图像去雾

基于Retinex的图像去雾算法(MATLAB实现)