💥💥💥💥💥💥💞💞💞💞💞💞💞💞欢迎来到海神之光博客之家💞💞💞💞💞💞💞💞💥💥💥💥💥💥
✅博主简介:热爱科研的Matlab仿真开发者,修心和技术同步精进;
🍎个人主页:海神之光
🏆代码获取方式:
海神之光Matlab王者学习之路—代码获取方式
⛳️座右铭:行百里者,半于九十。
更多Matlab图像处理仿真内容点击👇
①Matlab图像处理(进阶版)
②付费专栏Matlab图像处理(初级版)
⛳️关注优快云海神之光,更多资源等你来!!
⛄一、图像处理简介
图像处理知识点:
1 数字图像处理及matlab实现知识点总结1-4
2 数字图像处理及matlab实现知识点总结 5-10
⛄二、部分源代码
function varargout = GUI_part(varargin)
% GUI_PART MATLAB code for GUI_part.fig
% GUI_PART, by itself, creates a new GUI_PART or raises the existing
% singleton*.
%
% H = GUI_PART returns the handle to a new GUI_PART or the handle to
% the existing singleton*.
%
% GUI_PART(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in GUI_PART.M with the given input arguments.
%
% GUI_PART(‘Property’,‘Value’,…) creates a new GUI_PART or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI_part_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI_part_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 GUI_part
% Last Modified by GUIDE v2.5 16-Apr-2014 18:09:28
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @GUI_part_OpeningFcn, …
‘gui_OutputFcn’, @GUI_part_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 GUI_part is made visible.
function GUI_part_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 GUI_part (see VARARGIN)
% Choose default command line output for GUI_part
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI_part wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% — Outputs from this function are returned to the command line.
function varargout = GUI_part_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 UI_Load.
function UI_Load_Callback(hObject, eventdata, handles)
% hObject handle to UI_Load (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clc;
global IMG;
[filename, pathname] = uigetfile({‘.tif’; '.jpg’; ‘.bmp’;'.*’},‘File Selector’);
if isequal(filename,0)
msgbox(sprintf(‘Please select image 😃’),‘No Image Selected’,‘warn’);
return;
end
IMG =imread(filename);
axes(handles.UI_origin);
imshow(IMG);
% — Executes on button press in UI_process.
function UI_process_Callback(hObject, eventdata, handles)
% hObject handle to UI_process (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global IMG;
%generate detected image and tag image
[Img, Img_tag] = GeneratorCore(IMG); %use Hough transform to detect rain and tag area
axes(handles.UI_hough);
imshow(Img);
axes(handles.UI_mask);
imshow(Img_tag);
mu = 20;
[xlen,ylen, ~] =size(Img_tag);
IMG2= imresize(IMG,[max(xlen,ylen),max(xlen,ylen)]);
for i = 1:3
IMGt = IMG2(:,:,i)
Origin_resize = double(imresize(IMGt,[max(size(IMGt)),max(size(IMGt))]));
[x,y] = size(Origin_resize);
Structure_img(:,:,i) = uint8(reshape(SB_ATV(Origin_resize, mu), x, y)); %use PDE to get structure information
Texture_img(:,:,i) = uint8(Origin_resize-double(Structure_img(:,:,i)));
end
% figure;subplot(1,2,1);
axes(handles.UI_PDE_low);
imshow(Structure_img);
% title(‘Structure Image’);
% Texture_img = Origin_resize-Structure_img;
% subplot(1,2,2);
axes(handles.UI_PDE_high);
imshow(Texture_img);
% title(‘Texture Image’);
mask = imresize(Img_tag,[max(xlen,ylen),max(xlen,ylen)]);
%Use texture patch to repair image
for i = 1:3
New_i(:,:,i)= Texture_core(double(Structure_img(:,:,i)),double(mask));
New_i(:,:,i) = medfilt2(New_i(:,:,i),[5,5]);
end
% figure;
axes(handles.UI_final);
imshow(uint8(New_i),[0,255]);
% — Executes on button press in UI_hough_step.
function UI_hough_step_Callback(hObject, eventdata, handles)
% hObject handle to UI_hough_step (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,‘Value’) returns toggle state of UI_hough_step
global IMG;
if( get(hObject,‘Value’) == 1)
[Img, Img_tag] = GeneratorCore(IMG); %use Hough transform to detect rain and tag area
figure;
subplot(1,2,1);
imshow(Img);
subplot(1,2,2);
imshow(Img_tag);
end
% — Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
unction B=inpaint_nans(A,method)
% INPAINT_NANS: in-paints over nans in an array
% usage: B=INPAINT_NANS(A) % default method
% usage: B=INPAINT_NANS(A,method) % specify method used
%
% Solves approximation to one of several pdes to
% interpolate and extrapolate holes in an array
%
% arguments (input):
% A - nxm array with some NaNs to be filled in
%
% method - (OPTIONAL) scalar numeric flag - specifies
% which approach (or physical metaphor to use
% for the interpolation.) All methods are capable
% of extrapolation, some are better than others.
% There are also speed differences, as well as
% accuracy differences for smooth surfaces.
%
% methods {0,1,2} use a simple plate metaphor.
% method 3 uses a better plate equation,
% but may be much slower and uses
% more memory.
% method 4 uses a spring metaphor.
% method 5 is an 8 neighbor average, with no
% rationale behind it compared to the
% other methods. I do not recommend
% its use.
%
% method == 0 --> (DEFAULT) see method 1, but
% this method does not build as large of a
% linear system in the case of only a few
% NaNs in a large array.
% Extrapolation behavior is linear.
%
% method == 1 --> simple approach, applies del^2
% over the entire array, then drops those parts
% of the array which do not have any contact with
% NaNs. Uses a least squares approach, but it
% does not modify known values.
% In the case of small arrays, this method is
% quite fast as it does very little extra work.
% Extrapolation behavior is linear.
%
% method == 2 --> uses del^2, but solving a direct
% linear system of equations for nan elements.
% This method will be the fastest possible for
% large systems since it uses the sparsest
% possible system of equations. Not a least
% squares approach, so it may be least robust
% to noise on the boundaries of any holes.
% This method will also be least able to
% interpolate accurately for smooth surfaces.
% Extrapolation behavior is linear.
%
% Note: method 2 has problems in 1-d, so this
% method is disabled for vector inputs.
%
% method == 3 --+ See method 0, but uses del^4 for
% the interpolating operator. This may result
% in more accurate interpolations, at some cost
% in speed.
%
% method == 4 --+ Uses a spring metaphor. Assumes
% springs (with a nominal length of zero)
% connect each node with every neighbor
% (horizontally, vertically and diagonally)
% Since each node tries to be like its neighbors,
% extrapolation is as a constant function where
% this is consistent with the neighboring nodes.
%
% method == 5 --+ See method 2, but use an average
% of the 8 nearest neighbors to any element.
% This method is NOT recommended for use.
%
%
% arguments (output):
% B - nxm array with NaNs replaced
%
%
% Example:
% [x,y] = meshgrid(0:.01:1);
% z0 = exp(x+y);
% znan = z0;
% znan(20:50,40:70) = NaN;
% znan(30:90,5:10) = NaN;
% znan(70:75,40:90) = NaN;
%
% z = inpaint_nans(znan);
%
%
% See also: griddata, interp1
%
% Author: John D’Errico
% e-mail address: woodchips@rochester.rr.com
% Release: 2
% Release date: 4/15/06
% I always need to know which elements are NaN,
% and what size the array is for any method
[n,m]=size(A);
A=A(😃;
nm=n*m;
k=isnan(A(😃);
% list the nodes which are known, and which will
% be interpolated
nan_list=find(k);
known_list=find(~k);
% how many nans overall
nan_count=length(nan_list);
% convert NaN indices to (r,c) form
% nan_list==find(k) are the unrolled (linear) indices
% (row,column) form
[nr,nc]=ind2sub([n,m],nan_list);
% both forms of index in one array:
% column 1 == unrolled index
% column 2 == row index
% column 3 == column index
nan_list=[nan_list,nr,nc];
% supply default method
if (nargin<2) || isempty(method)
method = 0;
elseif ~ismember(method,0:5)
error ‘If supplied, method must be one of: {0,1,2,3,4,5}.’
end
% for different methods
switch method
case 0
% The same as method == 1, except only work on those
% elements which are NaN, or at least touch a NaN.
% is it 1-d or 2-d?
if (m == 1) || (n == 1)
% really a 1-d case
work_list = nan_list(:,1);
work_list = unique([work_list;work_list - 1;work_list + 1]);
work_list(work_list <= 1) = [];
work_list(work_list >= nm) = [];
nw = numel(work_list);
u = (1:nw)';
fda = sparse(repmat(u,1,3),bsxfun(@plus,work_list,-1:1), ...
repmat([1 -2 1],nw,1),nw,nm);
else
% a 2-d case
% horizontal and vertical neighbors only
talks_to = [-1 0;0 -1;1 0;0 1];
neighbors_list=identify_neighbors(n,m,nan_list,talks_to);
% list of all nodes we have identified
all_list=[nan_list;neighbors_list];
% generate sparse array with second partials on row
% variable for each element in either list, but only
% for those nodes which have a row index > 1 or < n
L = find((all_list(:,2) > 1) & (all_list(:,2) < n));
nl=length(L);
if nl>0
fda=sparse(repmat(all_list(L,1),1,3), ...
repmat(all_list(L,1),1,3)+repmat([-1 0 1],nl,1), ...
repmat([1 -2 1],nl,1),nm,nm);
else
fda=spalloc(n*m,n*m,size(all_list,1)*5);
end
⛄三、运行结果
⛄四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1]陈舒曼,陈玮,尹钟.单幅图像去雨算法研究现状及展望[J].计算机应用研究. 2022,39(01)
3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除
🍅 仿真咨询
1 各类智能优化算法改进及应用
生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化
2 机器学习和深度学习方面
卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断
3 图像处理方面
图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知
4 路径规划方面
旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化
5 无人机应用方面
无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配
6 无线传感器定位及布局方面
传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化
7 信号处理方面
信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化
8 电力系统方面
微电网优化、无功优化、配电网重构、储能配置
9 元胞自动机方面
交通流 人群疏散 病毒扩散 晶体生长
10 雷达方面
卡尔曼滤波跟踪、航迹关联、航迹融合