当前位置:网站首页>【第 01 章 基于直方图优化的图像去雾技术-全套系统MATLAB智能驾驶深度学习】
【第 01 章 基于直方图优化的图像去雾技术-全套系统MATLAB智能驾驶深度学习】
2022-06-22 01:02:00 【海宝7号】
毋庸置疑的是,在汽车智能技术、汽车新能源技术、汽车电子这个群雄逐鹿的赛道。智能驾驶技术的要求也在不断的提升。
智能车辆教学平台、智能网联教学平台、汽车电子教学设备、在环仿真系统,目前主流的系统有很多,常用的基础部分和算法开发,智能驾驶模块,入门较好的还是matlab平台。
MATLAB/Simulink中比较关键的两部分是:m语言的语法和搭载的各种工具箱。
覆盖各个领域的强大工具箱是MATLAB软件的核心,各种function、app、blcoks均包含在这些工具箱内。因此MATLAB/Simulink的学习,核心是对这些工具箱的学习。因此我们在学MATLAB的时候,可以以工具箱为单位进行学习。
而且,matlab在资源整合这块优势明显,后发力大,足够学到真东西,从入门到精通
直方图技术处理
图像增强的常用手段,但全局直方均衡经常会给图像带来失真等问题,为了处理相关问题,本文采取了全局直方均衡、局部直方均衡和Retinex算法来对图像进行处理。
对于其中的具体函数及其语法的应用,在matlab的 帮助文档可以自行搜查,进行案例式学习和应用。
首先举例:
处理车轮胎效果如图。
demo.m
clc; clear all; close all;
I = imread('tire.tif');
J = histeq(I);
figure;
subplot(2, 2, 1); imshow(I, []); title('原图');
subplot(2, 2, 2); imshow(J, []); title('原图均衡化后的图像');
subplot(2, 2, 3); imhist(I, 64); title('原图的直方图');
subplot(2, 2, 4); imhist(J, 64); title('均衡化后的直方图');
image文件,原始图像效果如图
基于直方图优化的图像去雾技术系统
GUI界面如图所示:
图像去雾系统,首先载入图像并显示,然后选择去雾算法,最后可以观察直方图对比效果
Initfig.m
function InitFig(hObject,handles)
axes(handles.axes1); cla; set(gca, 'Color', [0.8039 0.8784 0.9686]);
axes(handles.axes2); cla; axis on; box on; set(gca, 'Color', [0.8039 0.8784 0.9686]);
set(gca, 'XTickLabel', [], 'YTickLabel', [], 'XTick', [], 'YTick', []);
set(handles.textInfo, 'String', ...
'图像去雾系统,首先载入图像并显示,然后选择去雾算法,最后可以观察直方图对比效果。');
截图函数
SnapImage.m
function SnapImage()
imagesPath = '.\\snap_images';
if ~exist(imagesPath, 'dir')
mkdir(imagesPath);
end
[FileName,PathName,FilterIndex] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files' },'保存截图',...
'.\\snap_images\\temp.jpg');
if isequal(FileName, 0) || isequal(PathName, 0)
return;
end
fileStr = fullfile(PathName, FileName);
f = getframe(gcf);
f = frame2im(f);
imwrite(f, fileStr);
msgbox('抓图文件保存成功!', '提示信息');
图像保存子函数:
SaveImage.m
function SaveImage(Img)
imagesPath = '.\\results';
if ~exist(imagesPath, 'dir')
mkdir(imagesPath);
end
[FileName,PathName,FilterIndex] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files' },'保存截图',...
'.\\results\\result.jpg');
if isequal(FileName, 0) || isequal(PathName, 0)
return;
end
fileStr = fullfile(PathName, FileName);
imwrite(Img, fileStr);
msgbox('处理结果保存成功!', '提示信息');
用Retinex的MSR实现图像去雾操作。
子函数RemoveFogByRetinex.m
function In = RemoveFogByRetinex(f, flag)
% 用Retinex的MSR实现图像去雾
% 输入参数:
% f——图像矩阵
% flag——显示标记
% 输出参数:
% In——结果图像
if nargin < 2
flag = 1;
end
%提取图像的R、G、B分量
fr = f(:, :, 1);
fg = f(:, :, 2);
fb = f(:, :, 3);
%数据类型归一化
mr = mat2gray(im2double(fr));
mg = mat2gray(im2double(fg));
mb = mat2gray(im2double(fb));
%定义alpha参数
alpha = 1200;
%定义模板大小
n = 128;
%计算中心
n1 = floor((n+1)/2);
for i = 1:n
for j = 1:n
%高斯函数
b(i,j) = exp(-((i-n1)^2+(j-n1)^2)/(4*alpha))/(pi*alpha);
end
end
%卷积滤波
nr1 = imfilter(mr,b,'conv', 'replicate');
ng1 = imfilter(mg,b,'conv', 'replicate');
nb1 = imfilter(mb,b,'conv', 'replicate');
ur1 = log(nr1);
ug1 = log(ng1);
ub1 = log(nb1);
tr1 = log(mr);
tg1 = log(mg);
tb1 = log(mb);
yr1 = (tr1-ur1)/3;
yg1 = (tg1-ug1)/3;
yb1 = (tb1-ub1)/3;
%定义beta参数
beta = 55;
%定义模板大小
x = 32;
%计算中心
x1 = floor((n+1)/2);
for i = 1:n
for j = 1:n
%高斯函数
a(i,j) = exp(-((i-n1)^2+(j-n1)^2)/(4*beta))/(6*pi*beta);
end
end
%卷积滤波
nr2 = imfilter(mr,a,'conv', 'replicate');
ng2 = imfilter(mg,a,'conv', 'replicate');
nb2 = imfilter(mb,a,'conv', 'replicate');
ur2 = log(nr2);
ug2 = log(ng2);
ub2 = log(nb2);
tr2 = log(mr);
tg2 = log(mg);
tb2 = log(mb);
yr2 = (tr2-ur2)/3;
yg2 = (tg2-ug2)/3;
yb2 = (tb2-ub2)/3;
%定义eta参数
eta = 13944.5;
%定义模板大小
l = 500;
%计算中心
l1 = floor((n+1)/2);
for i = 1:n
for j = 1:n
%高斯函数
e(i,j) = exp(-((i-n1)^2+(j-n1)^2)/(4*eta))/(4*pi*eta);
end
end
%卷积滤波
nr3 = imfilter(mr,e,'conv', 'replicate');
ng3 = imfilter(mg,e,'conv', 'replicate');
nb3 = imfilter(mb,e,'conv', 'replicate');
ur3 = log(nr3);
ug3 = log(ng3);
ub3 = log(nb3);
tr3 = log(mr);
tg3 = log(mg);
tb3 = log(mb);
yr3 = (tr3-ur3)/3;
yg3 = (tg3-ug3)/3;
yb3 = (tb3-ub3)/3;
dr = yr1+yr2+yr3;
dg = yg1+yg2+yg3;
db = yb1+yb2+yb3;
cr = im2uint8(dr);
cg = im2uint8(dg);
cb = im2uint8(db);
% 集成处理后的分量得到结果图像
In = cat(3, cr, cg, cb);
%结果显示
if flag
figure;
subplot(2, 2, 1); imshow(f); title('原图像', 'FontWeight', 'Bold');
subplot(2, 2, 2); imshow(In); title('处理后的图像', 'FontWeight', 'Bold');
% 灰度化,用于计算直方图
Q = rgb2gray(f);
M = rgb2gray(In);
subplot(2, 2, 3); imhist(Q, 64); title('原灰度直方图', 'FontWeight', 'Bold');
subplot(2, 2, 4); imhist(M, 64); title('处理后的灰度直方图', 'FontWeight', 'Bold');
end
灰度直方图及图像归一化函数:
RemoveFogByGlobalHisteq.m
function In = RemoveFogByGlobalHisteq(I, flag)
if nargin < 2
flag = 1;
end
R = I(:,:,1);
G = I(:,:,2);
B = I(:,:,3);
M = histeq(R);
N = histeq(G);
L = histeq(B);
In = cat(3, M, N, L);
if flag
figure;
subplot(2, 2, 1); imshow(I); title('原图像', 'FontWeight', 'Bold');
subplot(2, 2, 2); imshow(In); title('处理后的图像', 'FontWeight', 'Bold');
Q = rgb2gray(I);
W = rgb2gray(In);
subplot(2, 2, 3); imhist(Q, 64); title('原灰度直方图', 'FontWeight', 'Bold');
subplot(2, 2, 4); imhist(W, 64); title('处理后的灰度直方图', 'FontWeight', 'Bold');
end
本文全部文件源代码打包整理–>传送门
基于直方图优化的图像去雾技术-全套系统–MATLAB智能驾驶深度学习
全局处理效果如图所示。
局部直方图均衡化实现效果
通过Retinex算法去雾处理效果对比:

与之对应的直方图对比
运行主流程文件
MainForm.fig
全套源码下载
边栏推荐
猜你喜欢

2022年Q1手机银行用户规模达6.5亿,加强ESG个人金融产品创新
![[noi simulation] interval distance (block and convolution)](/img/1f/d2f3ed8a80e2a4fca9669dcfc55a30.png)
[noi simulation] interval distance (block and convolution)

SQL操作:WITH表达式及其应用

Show you how to distinguish several kinds of parallelism

Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference

将列表分箱,并通过Pyechart绘制柱状图

Machine learning pytoch implementation case LSTM case (flight number prediction)

机器学习 Pytorch实现案例 LSTM案例(航班人数预测)

【第 06 章 MATLAB实现基于分水岭分割进行肺癌诊断】

Divide the list into boxes and draw a histogram through pyechart
随机推荐
Scuba China trip - Suzhou station, online and offline limited time registration channel has been opened!
LCP 17. Quick calculation robot
Huawei cloud releases desktop ide codearts
Creating a successful paradigm for cross-border e-commerce: Amazon cloud technology helps sellers lay out the next growth point
Riscv cache
出现IOError: No translation files found for default language zh-cn.的解决方法
【第 13 章 基于霍夫曼图像压缩重建--Matlab深度学习实战图像处理应用】
[bit operation] leetcode1009 Complement of Base 10 Integer
I just learned a cool 3D pyramid stereoscopic effect. Come and have a look
数学知识复习:三重积分
[number theory] leetcode1010 Pairs of Songs With Total Durations Divisible by 60
2022年Q1手机银行用户规模达6.5亿,加强ESG个人金融产品创新
Google multi user anti Association tool
curl在服务器命令行请求
机器学习 Pytorch实现案例 LSTM案例(航班人数预测)
第 24 章 基于 Simulink 进行图像和视频处理--matlab深度学习实战整理
. Several methods of obtaining hinstance in. Net
Use of listctl virtual mode under wince
Virtual variables and formatting characters in debugging
亚马逊测评系统哪个好?