✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,代码获取、论文复现及科研仿真合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab完整代码及仿真定制内容点击👇
🔥 内容介绍
DIP(双列直插式封装)芯片广泛应用于电子行业,其质量直接影响电子产品的性能和可靠性。传统的 DIP 芯片缺陷检测主要依靠人工目检,效率低、准确性差,无法满足现代化生产的需求。机器视觉技术以其非接触、高效、高精度的优势,为 DIP 芯片缺陷检测提供了新的解决方案。
机器视觉原理
机器视觉是一种计算机视觉技术,通过图像传感器获取目标图像,并利用计算机算法对图像进行处理和分析,从而提取目标特征并进行缺陷检测。DIP 芯片缺陷检测的机器视觉系统主要包括以下几个模块:
-
**图像采集:**使用工业相机或显微镜获取 DIP 芯片的图像。
-
**图像预处理:**对图像进行降噪、增强、分割等预处理操作,以提高缺陷检测的准确性。
-
**特征提取:**提取 DIP 芯片图像中的特征,如边缘、纹理、缺陷等。
-
**缺陷分类:**根据提取的特征,对缺陷进行分类,如缺口、划痕、引脚弯曲等。
缺陷检测算法
DIP 芯片缺陷检测算法主要有以下几种:
-
**模板匹配:**将标准 DIP 芯片图像作为模板,与待检测图像进行匹配,找出差异区域。
-
**边缘检测:**利用 Sobel、Canny 等边缘检测算法,检测 DIP 芯片图像中的边缘,并分析边缘的连续性和完整性。
-
**纹理分析:**分析 DIP 芯片图像的纹理特征,找出纹理异常区域,如划痕、凹陷等。
-
**深度学习:**利用卷积神经网络(CNN)等深度学习算法,训练模型对 DIP 芯片缺陷进行分类。
系统设计
DIP 芯片缺陷检测机器视觉系统的设计需要考虑以下几个方面:
-
**照明:**采用环形光或漫反射光源,均匀照射 DIP 芯片,避免阴影和眩光。
-
**镜头:**选择具有合适焦距和景深的镜头,以获得清晰的图像。
-
**相机:**选择具有高分辨率和高帧率的工业相机,满足缺陷检测的需求。
-
**软件:**开发图像处理和缺陷检测算法,并集成到软件平台中。
应用案例
DIP 芯片缺陷检测机器视觉系统已广泛应用于电子制造行业,如:
-
**半导体封装:**检测 DIP 芯片的引脚弯曲、缺口、划痕等缺陷。
-
**电子组装:**检测 DIP 芯片在电路板上的错位、虚焊等缺陷。
-
**质量控制:**对 DIP 芯片进行批量检测,筛选出不合格产品。
优势
基于机器视觉的 DIP 芯片缺陷检测具有以下优势:
-
**高效:**机器视觉系统可以高速检测 DIP 芯片,大大提高检测效率。
-
**准确:**机器视觉算法能够准确识别和分类缺陷,避免漏检和误检。
-
**非接触:**机器视觉检测不接触 DIP 芯片,避免对芯片造成损坏。
-
**自动化:**机器视觉系统可以实现自动化检测,减少人工参与,降低生产成本。
结论
基于机器视觉的 DIP 芯片缺陷检测技术为电子制造行业提供了高效、准确、非接触的检测解决方案。随着机器视觉技术的不断发展,DIP 芯片缺陷检测的准确性和效率将进一步提高,为电子产品质量控制提供强有力的保障。
📣 部分代码
function [rectx,recty,area,perimeter] = minboundrect(x,y,metric)
% minboundrect: Compute the minimal bounding rectangle of points in the plane
% usage: [rectx,recty,area,perimeter] = minboundrect(x,y,metric)
%
% arguments: (input)
% x,y - vectors of points, describing points in the plane as
% (x,y) pairs. x and y must be the same lengths.
%
% metric - (OPTIONAL) - single letter character flag which
% denotes the use of minimal area or perimeter as the
% metric to be minimized. metric may be either 'a' or 'p',
% capitalization is ignored. Any other contraction of 'area'
% or 'perimeter' is also accepted.
%
% DEFAULT: 'a' ('area')
%
% arguments: (output)
% rectx,recty - 5x1 vectors of points that define the minimal
% bounding rectangle.
%
% area - (scalar) area of the minimal rect itself.
%
% perimeter - (scalar) perimeter of the minimal rect as found
%
%
% Note: For those individuals who would prefer the rect with minimum
% perimeter or area, careful testing convinces me that the minimum area
% rect was generally also the minimum perimeter rect on most problems
% (with one class of exceptions). This same testing appeared to verify my
% assumption that the minimum area rect must always contain at least
% one edge of the convex hull. The exception I refer to above is for
% problems when the convex hull is composed of only a few points,
% most likely exactly 3. Here one may see differences between the
% two metrics. My thanks to Roger Stafford for pointing out this
% class of counter-examples.
%
% Thanks are also due to Roger for pointing out a proof that the
% bounding rect must always contain an edge of the convex hull, in
% both the minimal perimeter and area cases.
%
%
% See also: minboundcircle, minboundtri, minboundsphere
%
%
% default for metric
if (nargin<3) || isempty(metric)
metric = 'a';
elseif ~ischar(metric)
error 'metric must be a character flag if it is supplied.'
else
% check for 'a' or 'p'
metric = lower(metric(:)');
ind = strmatch(metric,{'area','perimeter'});
if isempty(ind)
error 'metric does not match either ''area'' or ''perimeter'''
end
% just keep the first letter.
metric = metric(1);
end
% preprocess data
x=x(:);
y=y(:);
% not many error checks to worry about
n = length(x);
if n~=length(y)
error 'x and y must be the same sizes'
end
% if var(x)==0
% start out with the convex hull of the points to
% reduce the problem dramatically. Note that any
% points in the interior of the convex hull are
% never needed, so we drop them.
if n>3
%%%%%%%%%%%%%%%%%%%%%%%%%
if (var(x)== 0|| var(y)==0)
if var(x)== 0
x = [x-1;x(1); x+1 ];
y = [y ;y(1);y];
flag = 1;
else
y = [y-1;y(1); y+1 ];
x = [x ;x(1);x];
flag = 1;
end
else
flag = 0;
%%%%%%%%%%%%%%%%%%%%%%
edges = convhull(x,y); % 'Pp' will silence the warnings
end
% exclude those points inside the hull as not relevant
% also sorts the points into their convex hull as a
% closed polygon
%%%%%%%%%%%%%%%%%%%%
if flag == 0
%%%%%%%%%%%%%%%%%%%%
x = x(edges);
y = y(edges);
%%%%%%%%%%%%%%%%%%
end
%%%%%%%%%%%%%
% probably fewer points now, unless the points are fully convex
nedges = length(x) - 1;
elseif n>1
% n must be 2 or 3
nedges = n;
x(end+1) = x(1);
y(end+1) = y(1);
else
% n must be 0 or 1
nedges = n;
end
% now we must find the bounding rectangle of those
% that remain.
% special case small numbers of points. If we trip any
% of these cases, then we are done, so return.
switch nedges
case 0
% empty begets empty
rectx = [];
recty = [];
area = [];
perimeter = [];
return
case 1
% with one point, the rect is simple.
rectx = repmat(x,1,5);
recty = repmat(y,1,5);
area = 0;
perimeter = 0;
return
case 2
% only two points. also simple.
rectx = x([1 2 2 1 1]);
recty = y([1 2 2 1 1]);
area = 0;
perimeter = 2*sqrt(diff(x).^2 + diff(y).^2);
return
end
% 3 or more points.
% will need a 2x2 rotation matrix through an angle theta
Rmat = @(theta) [cos(theta) sin(theta);-sin(theta) cos(theta)];
% get the angle of each edge of the hull polygon.
ind = 1:(length(x)-1);
edgeangles = atan2(y(ind+1) - y(ind),x(ind+1) - x(ind));
% move the angle into the first quadrant.
edgeangles = unique(mod(edgeangles,pi/2));
% now just check each edge of the hull
nang = length(edgeangles);
area = inf;
perimeter = inf;
met = inf;
xy = [x,y];
for i = 1:nang
% rotate the data through -theta
rot = Rmat(-edgeangles(i));
xyr = xy*rot;
xymin = min(xyr,[],1);
xymax = max(xyr,[],1);
% The area is simple, as is the perimeter
A_i = prod(xymax - xymin);
P_i = 2*sum(xymax-xymin);
if metric=='a'
M_i = A_i;
else
M_i = P_i;
end
% new metric value for the current interval. Is it better?
if M_i<met
% keep this one
met = M_i;
area = A_i;
perimeter = P_i;
rect = [xymin;[xymax(1),xymin(2)];xymax;[xymin(1),xymax(2)];xymin];
rect = rect*rot';
rectx = rect(:,1);
recty = rect(:,2);
end
end
% get the final rect
% all done
end % mainline end
⛳️ 运行结果
🔗 参考文献
[1]胡飞飞.基于嵌入式机器视觉的干电池缺陷检测系统的研究[D].广东工业大学[2024-03-24].
🎈 部分理论引用网络文献,若有侵权联系博主删除
🎁 关注我领取海量matlab电子书和数学建模资料
👇 私信完整代码和数据获取及论文数模仿真定制
1 各类智能优化算法改进及应用
生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化、背包问题、 风电场布局、时隙分配优化、 最佳分布式发电单元分配、多阶段管道维修、 工厂-中心-需求点三级选址问题、 应急生活物质配送中心选址、 基站选址、 道路灯柱布置、 枢纽节点部署、 输电线路台风监测装置、 集装箱船配载优化、 机组优化、 投资优化组合、云服务器组合优化、 天线线性阵列分布优化
2 机器学习和深度学习方面
2.1 bp时序、回归预测和分类
2.2 ENS声神经网络时序、回归预测和分类
2.3 SVM/CNN-SVM/LSSVM/RVM支持向量机系列时序、回归预测和分类
2.4 CNN/TCN卷积神经网络系列时序、回归预测和分类
2.5 ELM/KELM/RELM/DELM极限学习机系列时序、回归预测和分类
2.6 GRU/Bi-GRU/CNN-GRU/CNN-BiGRU门控神经网络时序、回归预测和分类
2.7 ELMAN递归神经网络时序、回归\预测和分类
2.8 LSTM/BiLSTM/CNN-LSTM/CNN-BiLSTM/长短记忆神经网络系列时序、回归预测和分类
2.9 RBF径向基神经网络时序、回归预测和分类