当前位置:网站首页>[chapter 01 image defogging technology based on histogram optimization - full system matlab intelligent driving depth learning]
[chapter 01 image defogging technology based on histogram optimization - full system matlab intelligent driving depth learning]
2022-06-22 01:54:00 【Haibao 7】
There is no doubt about it , In automotive intelligent technology 、 Automobile new energy technology 、 Automotive electronics is a race track for the best . The requirements of intelligent driving technology are also constantly improving .
Intelligent vehicle teaching platform 、 Intelligent network teaching platform 、 Automobile electronic teaching equipment 、 In the loop simulation system , At present, there are many mainstream systems , Common basic parts and algorithm development , Intelligent driving module , It is better to get started matlab platform .
MATLAB/Simulink The two key parts of the are :m The grammar of the language and the various toolkits it carries .
A powerful toolbox covering all areas is MATLAB The core of software , Various function、app、blcoks Are included in these toolkits . therefore MATLAB/Simulink Learning from , The core is the learning of these toolkits . So we are learning MATLAB When , You can learn by using the toolbox as a unit .
and ,matlab It has obvious advantages in resource integration , Great backwardness , Enough to learn the real thing , From entry to mastery 
Histogram technology processing
Common means of image enhancement , But the global square equalization often brings distortion to the image , In order to deal with related problems , This paper adopts the global square equilibrium 、 Local square equilibrium and Retinex Algorithm to process the image .
For the specific functions and the application of their syntax , stay matlab Of Help documents can be searched by themselves , Case study and application .
Let's start with an example :
The effect of processing vehicle tires is shown in the figure .
demo.m
clc; clear all; close all;
I = imread('tire.tif');
J = histeq(I);
figure;
subplot(2, 2, 1); imshow(I, []); title(' Original picture ');
subplot(2, 2, 2); imshow(J, []); title(' Image after original image equalization ');
subplot(2, 2, 3); imhist(I, 64); title(' Histogram of the original image ');
subplot(2, 2, 4); imhist(J, 64); title(' Histogram after equalization ');
image file , The effect of the original image is shown in the figure 
Image defogging technology system based on histogram optimization
GUI The interface is as shown in the figure :
Image defogging system , First load the image and display , Then select the defogging algorithm , Finally, you can observe the histogram contrast effect
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', ...
' Image defogging system , First load the image and display , Then select the defogging algorithm , Finally, you can observe the histogram contrast effect .');
Screenshot function
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' },' Save the screenshot ',...
'.\\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(' The snapshot file was saved successfully !', ' Prompt information ');
Image saving subfunction :
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' },' Save the screenshot ',...
'.\\results\\result.jpg');
if isequal(FileName, 0) || isequal(PathName, 0)
return;
end
fileStr = fullfile(PathName, FileName);
imwrite(Img, fileStr);
msgbox(' Processing results saved successfully !', ' Prompt information ');
use Retinex Of MSR Realize image defogging operation .
Subfunctions RemoveFogByRetinex.m
function In = RemoveFogByRetinex(f, flag)
% use Retinex Of MSR Realize image defogging
% Input parameters :
% f—— Image matrix
% flag—— show marks
% Output parameters :
% In—— The resulting image
if nargin < 2
flag = 1;
end
% Extract the R、G、B component
fr = f(:, :, 1);
fg = f(:, :, 2);
fb = f(:, :, 3);
% Data type normalization
mr = mat2gray(im2double(fr));
mg = mat2gray(im2double(fg));
mb = mat2gray(im2double(fb));
% Definition alpha Parameters
alpha = 1200;
% Define template size
n = 128;
% Computing Center
n1 = floor((n+1)/2);
for i = 1:n
for j = 1:n
% Gauss function
b(i,j) = exp(-((i-n1)^2+(j-n1)^2)/(4*alpha))/(pi*alpha);
end
end
% Convolution filtering
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;
% Definition beta Parameters
beta = 55;
% Define template size
x = 32;
% Computing Center
x1 = floor((n+1)/2);
for i = 1:n
for j = 1:n
% Gauss function
a(i,j) = exp(-((i-n1)^2+(j-n1)^2)/(4*beta))/(6*pi*beta);
end
end
% Convolution filtering
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;
% Definition eta Parameters
eta = 13944.5;
% Define template size
l = 500;
% Computing Center
l1 = floor((n+1)/2);
for i = 1:n
for j = 1:n
% Gauss function
e(i,j) = exp(-((i-n1)^2+(j-n1)^2)/(4*eta))/(4*pi*eta);
end
end
% Convolution filtering
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);
% Integrate the processed components to obtain the result image
In = cat(3, cr, cg, cb);
% Results show
if flag
figure;
subplot(2, 2, 1); imshow(f); title(' Original image ', 'FontWeight', 'Bold');
subplot(2, 2, 2); imshow(In); title(' Processed image ', 'FontWeight', 'Bold');
% Graying , Used to calculate histogram
Q = rgb2gray(f);
M = rgb2gray(In);
subplot(2, 2, 3); imhist(Q, 64); title(' Original gray histogram ', 'FontWeight', 'Bold');
subplot(2, 2, 4); imhist(M, 64); title(' Processed gray histogram ', 'FontWeight', 'Bold');
end
Gray histogram and image normalization function :
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(' Original image ', 'FontWeight', 'Bold');
subplot(2, 2, 2); imshow(In); title(' Processed image ', 'FontWeight', 'Bold');
Q = rgb2gray(I);
W = rgb2gray(In);
subplot(2, 2, 3); imhist(Q, 64); title(' Original gray histogram ', 'FontWeight', 'Bold');
subplot(2, 2, 4); imhist(W, 64); title(' Processed gray histogram ', 'FontWeight', 'Bold');
end
All the source code of this article is packaged and sorted out –> Portal
Image defogging technology based on histogram optimization - The whole system –MATLAB Intelligent driving deep learning
The global processing effect is shown in the figure .
The effect of local histogram equalization 
adopt Retinex Comparison of the fog removal effect of the algorithm :

Compare with the corresponding histogram 
Run the main process file
MainForm.fig
Download a full set of source code
边栏推荐
- The way to build the efficiency platform of didi project
- Fabric.js IText 手动设置斜体
- Preliminary competition of noip improvement group III. problem solving exercise set noip1995-noip2018
- 测试apk-异常管控Sensor攻击者开发
- Creating a successful paradigm for cross-border e-commerce: Amazon cloud technology helps sellers lay out the next growth point
- heidisql 插入数据老是出错,怎么办
- 第 18 章 基于GUI搭建通用视频处理工具matlab应用GUI实现
- Localdatetime format time
- Individual problem solution of the 298th round of force deduction
- ASEMI快恢复二极管FR107参数,FR107实物,FR107应用
猜你喜欢

第 18 章 基于GUI搭建通用视频处理工具matlab应用GUI实现

第 03 章 基于多尺度形态学提取眼前节组织-全套系统MATLAB智能驾驶深度学习

Intranet learning notes (3)

heidisql 插入数据老是出错,怎么办

Five years after graduation, I finally became a software testing engineer with a monthly salary of 13000

GAMES-101-个人总结归纳-Shading

Packet capturing tool: Fiddler, a necessary skill for Software Test Engineer

阿里,腾讯,百度软件测试工程师推荐——软件测试模型之瀑布模型

Pyechart drawing word cloud

The Sandbox 与《时代周刊》达成合作,在元宇宙建立“纽约时报广场”
随机推荐
AHA C language Chapter 5 the good play is later (Lecture 24-25)
光照相关 shader
初识Unity3D(项目结构、ProBuilder第三方插件)
【Proteus仿真】INT0和INT1中断计数
The sandbox has reached a cooperation with Time magazine to establish "New York Times Square" in metauniverse
High score schemes have been opened to the public, and the second round of the China "software Cup" remote sensing competition is coming!
GAMES-101-个人总结归纳-Shading
Recommended by Alibaba, Tencent and Baidu Software Test Engineers - rapid prototype model of software test model
Leetcode + 46 - 50
2022年中国手机银行年度专题分析
Intranet learning notes (9)
Test APK exception control sensor attacker development
谁会用pyspark将筛选过后本地数据上传到spark sql
【AMD 综合求职经验分享618】
【第 06 章 MATLAB实现基于分水岭分割进行肺癌诊断】
NOIP初赛 CSP-J1 CSP-S1 第1轮 初赛 信奥中的数学知识(三)
Expenditure budget and adjustment records and use records output use progress construction process records
Commission contract on BSV (2)
全局异常处理
阿里,腾讯,百度软件测试工程师推荐——软件测试模型之瀑布模型