图像去雾和界面程序.zip

  • g9_631187
    了解作者
  • 1.2MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-07 09:14
    上传日期
有雾图像会导致系统辨识度低、无法识别等问题,极大地降低系统的工作性能和成像效果。目前的去雾算法有三种,分别是直方图去雾法、何凯明的暗通道法和单尺度同态滤波。同时还包含交互展示界面
图像去雾.zip
  • 图像去雾
  • input
  • bg.jpg
    49.1KB
  • 2.jpg
    51.4KB
  • 1.jpg
    53.6KB
  • 4.jpg
    106.5KB
  • 5.jpg
    91KB
  • 3.jpg
    43.8KB
  • result
  • images2
  • lena2.jpg
    37.1KB
  • lena1.jpg
    37.1KB
  • images1
  • result.jpg
    126.9KB
  • Jdark.jpg
    51.7KB
  • result2.jpg
    25.4KB
  • lena2.jpg
    116.1KB
  • lena1.jpg
    23.8KB
  • images3
  • lena3.jpg
    53.8KB
  • lena4.jpg
    32.3KB
  • In1.jpg
    66.1KB
  • In.jpg
    24.6KB
  • menu_4.fig
    40.7KB
  • menu_2.fig
    74.1KB
  • minfilt2.m
    1.8KB
  • Idark.m
    798B
  • gradient_guidedfilter.m
    1.2KB
  • vanherk.m
    4.7KB
  • ME.m
    8.6KB
  • boxfilter.m
    978B
  • ME.fig
    72.6KB
  • menu_3.m
    8.2KB
  • menu_2.m
    9.8KB
  • menu_3.fig
    43.7KB
  • menu_4.m
    6.2KB
内容介绍
function varargout = menu_2(varargin) % MENU_2 MATLAB code for menu_2.fig % MENU_2, by itself, creates a new MENU_2 or raises the existing % singleton*. % % H = MENU_2 returns the handle to a new MENU_2 or the handle to % the existing singleton*. % % MENU_2('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MENU_2.M with the given input arguments. % % MENU_2('Property','Value',...) creates a new MENU_2 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before menu_2_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to menu_2_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 menu_2 % Last Modified by GUIDE v2.5 21-Mar-2019 10:20:15 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @menu_2_OpeningFcn, ... 'gui_OutputFcn', @menu_2_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 menu_2 is made visible. function menu_2_OpeningFcn(hObject, eventdata, handles, varargin) ha=axes('units','normalized','pos',[0 0 1 1]); uistack(ha,'down'); ii=imread('input\bg.jpg'); %设置程序的背景图为beijing1.jpg image(ii); colormap gray set(ha,'handlevisibility','off','visible','off'); % 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 menu_2 (see VARARGIN) % Choose default command line output for menu_2 handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes menu_2 wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = menu_2_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 button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) axis off %%关闭坐标轴显示 [filename pathname] =uigetfile({'*.jpg';'*.bmp';'*.*'},'打开图片'); global str_1; str_1=[pathname filename]; %%打开图像 img=imread(str_1); %%打开axes1的句柄 进行axes1的操作 axes(handles.axes1); %%在axes1中显示 图像 imshow(img); % 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) % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) %图像处理部分 %图像处理部分 global str_1; J = imread(str_1); J = double(J); J = J ./255 ; % 求暗通道图像 Jdark = min(min()); Jdark = Idark(J); path1='result/images1/'; name2='Jdark.jpg'; imwrite(Jdark,[path1 name2]); str22=[path1 name2]; im22=imread(str22); axes(handles.axes2); imshow(im22); %本代码采用梯度导向滤波对透射率进行细化 Jdark = gradient_guidedfilter(Jdark,Jdark, 0.04); name3='Jdark.jpg'; imwrite(Jdark,[path1 name3]); str33=[path1 name3]; im22=imread(str33); axes(handles.axes3); imshow(im22); % 大气物理模型 J = I*t + A*(1-t) 【直接衰减项】+【大气光照】 % 透射率 t与深度的关系 t=exp(-a*depth) w = 0.95; %雾的保留系数womega Jt = 1 - w*Jdark; %求解透射率 % 求解全局大气光照 % 1.首先对输入的有雾图像I求解其暗通道图像Jdark。 % 2.选择Jdark总像素点个数千分之一(N/1000)个最亮的像素点,记录像素点(x,y)坐标 % 3.根据点的坐标分别在原图像J的三个通道(r,g,b)内找到这些像素点并加和得到(sum_r,sum_g,sum_b). % 4.Ac=[Ar,Ag,Ab]. 其中Ar=sum_r/N; Ag=sum_g/N; Ab=sum_b/N. [m,n,~] = size(J); %向小取整 N = floor( m*n./1000 ); MaxPos = [0,0]; % 初始化 for i=1:1:N MaxValue = max(max(Jdark)); [x,y] = find(Jdark==MaxValue); Jdark(Jdark==MaxValue) = 0; %最大值置零,寻找下一次次大值 %检查长度 MaxPos = vertcat(MaxPos,[x,y]); Cnt = length(MaxPos(1)); if Cnt > N break; end end MaxPosN = MaxPos(2:N+1,:); Rsum = 0; Jr = J(:,:,1); Gsum = 0; Jg = J(:,:,2); Bsum = 0; Jb = J(:,:,3); for j=1:1:N Rsum = Rsum + Jr(MaxPosN(j,1),MaxPosN(j,2)); Gsum = Gsum + Jg(MaxPosN(j,1),MaxPosN(j,2)); Bsum = Bsum + Jb(MaxPosN(j,1),MaxPosN(j,2)); end Ac = [Rsum/N, Gsum/N, Bsum/N]; % 求解清晰的图像 % 根据 J = I*t + A*(1-t) I = (J-A)/Jt + A Iorg = zeros(m,n,3); for i = 1:1:m for j = 1:1:n for k = 1:1:3 Iorg(i,j,k) = (J(i,j,k)-Ac(k)) ./ Jt(i,j) + Ac(k); end end end path1='result/images1/'; name='result.jpg'; imwrite(Iorg,[path1 name]); str1=[path1 name]; im1=imread(str1); axes(handles.axes4); imshow(im1); % 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) % -------------------------------------------------------------------- function ME_Callback(hObject, eventdata, handles) h=gcf; ME; close(h); % hObject handle to ME (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_2_Callback(hObject, eventdata, handles) h=gcf; menu_2; close(h); % hObject handle to menu_2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_3_Callback(hObject, eventdata, handles) h=gcf; menu_3; close(h); % hObject handle to menu_3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_4_Callback(hObject, eventdata, handles) h=gcf; menu_4; close(h); % hObject handle to menu_4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on slider movement. function slider1_Callback(hObject, eventdata, handles) global str_1; J = imread(str_1); J = double(J); J = J ./255 ; % 求暗通道图像 Jdark = min(min()); Jdark = Idark(J); path1='result/images1/'; name2='Jdark.jpg'; imwrite(Jdark,[path1 name2]); str22=[path1 name2]; im22=imread(str22); axes(handles.axes2); imshow(im22); %本代码采用梯度导向滤波对透射率进行细化 Jdark = gradient_guidedfilter(Jdark,Jdark, 0.04); name3='Jdark.jpg'; imwrite(Jdark,[path1 name3]); str33=[path1 name3]; im22=imread(str33); axes(handles.axes3); imshow(im22); % 大气物理模型 J = I*t + A*(1-t) 【直接衰减项】+【大气光照】 % 透射率 t与深度的关系 t=exp(-a*depth) w=get(handles.slider1,'value'); %w = 0.95; %雾的保留系数womega Jt = 1 - w*Jdark; %求解透射率 % 求解全局大气光照 % 1.首先对输入的有雾图像I求解其暗通道图像Jdark。 % 2.选择
评论
    相关推荐