首页 > 行业资讯 > 【图像检测】基于形态学实现图像目标尺寸测量系统附matlab代码

【图像检测】基于形态学实现图像目标尺寸测量系统附matlab代码

时间:2022-06-27 来源: 浏览:

【图像检测】基于形态学实现图像目标尺寸测量系统附matlab代码

天天Matlab 天天Matlab
天天Matlab

TT_Matlab

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,完整matlab代码或者程序定制加qq1575304183。

收录于合集 #图像处理matlab源码 708个

1 简介

介绍了一种基于机器视觉技术的目标外观尺寸检测系统.,通过数字图像处理技术获取柚子的纵径,横径,表面积等外观尺寸参数.

2 部分代码

coin_width= 1.1000 ; coin_height= 1.1000 ; I=imread( ’666.jpg’ ); figure( 1 ),imshow(I);title( ’原图像’ ); %转换为灰度图像 I1=rgb2gray(I); %figure( 2 );imshow(I1);title( ’灰度图像’ ); sigma = 1 ; gausFilter=fspecial( ’gaussian’ ,[ 5 5 ],sigma); I2= imfilter(I1, gausFilter, ’replicate’ ); %figure( 2 );imshow(I2);title( ’高斯滤波后图像’ ); ength/coin_height; pixels_width_rate=width/coin_width; :num [r c]=find(labelpic==v); [rectx,recty,area,perimeter]=minboundrect(c,r, ’p’ ); [ length width] = minboxing(rectx( 1 :end- 1 ),recty( 1 :end- 1 )); % 绘制目标检测框 line(rectx,recty, ’color’ , ’y’ , ’linewidth’ , 2 ); midpointx( 1 )=(rectx( 1 )+rectx( 2 ))/ 2 ; midpointx( 2 )=(rectx( 3 )+rectx( 4 ))/ 2 ; midpointx( 3 )=(rectx( 2 )+rectx( 3 ))/ 2 ; midpointx( 4 )=(rectx( 4 )+rectx( 1 ))/ 2 ; midpointy( 1 )=(recty( 1 )+recty( 2 ))/ 2 ; midpointy( 2 )=(recty( 3 )+recty( 4 ))/ 2 ; midpointy( 3 )=(recty( 2 )+recty( 3 ))/ 2 ; midpointy( 4 )=(recty( 4 )+recty( 1 ))/ 2 ; % 绘制目标长宽中点间连线 line(midpointx,midpointy, ’color’ , ’m’ , ’linewidth’ , 2 ); target_float_length= length /pixels_length_rate; target_length=num2str(target_float_length); target_float_width=width/pixels_width_rate; target_width=num2str(target_float_width); % 显示目标物体长宽信息 if ((rectx( 2 )-rectx( 1 ))<=(recty( 2 )-recty( 1 ))) text(midpointx( 1 ),midpointy( 1 )- 10 ,target_length, ’Color’ , ’white’ ); text(midpointx( 3 )+ 10 ,midpointy( 3 ),target_width, ’Color’ , ’white’ ); else text(midpointx( 1 ),midpointy( 1 )- 10 ,target_width, ’Color’ , ’white’ ); text(midpointx( 3 )+ 10 ,midpointy( 3 ),target_length, ’Color’ , ’white’ ); end end

3 仿真结果

4 参考文献

[1]王娟, 周金芝. 基于Matlab的形态学图像处理研究[J]. 现代交际:下半月, 2010.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

版权:如无特殊注明,文章转载自网络,侵权请联系cnmhg168#163.com删除!文件均为网友上传,仅供研究和学习使用,务必24小时内删除。
相关推荐