当前位置:网站首页>【图像检测】基于形态学实现图像目标尺寸测量系统附matlab代码
【图像检测】基于形态学实现图像目标尺寸测量系统附matlab代码
2022-06-26 06:43:00 【Matlab科研工作室】
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');elsetext(midpointx(1),midpointy(1)-10,target_width,'Color','white');text(midpointx(3)+10,midpointy(3),target_length,'Color','white');endend
3 仿真结果

4 参考文献
[1]王娟, 周金芝. 基于Matlab的形态学图像处理研究[J]. 现代交际:下半月, 2010.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
边栏推荐
- Unsatisfied dependency expressed through field ‘baseMapper‘; nested exceptio
- Mysql delete in 不走索引的
- Kotlin Compose 状态恢复 rememberSaveable 与 remember
- 分析 NFT 项目的 5 个指标
- LabVIEW Arduino TCP/IP远程智能家居系统(项目篇—5)
- typescript的type
- 浏览器的四大内核:Trident,Gecko,Webkit,Blink
- On a classical problem
- Customer Stories | Netease spring breeze: the "spring breeze" of the fun industry, reaching out to all areas through in-depth interaction
- SecureCRT运行SparkShell 删除键出现乱码的解法
猜你喜欢

寶塔服務器搭建及數據庫遠程連接

Reasons why MySQL indexes are not effective

Differences, advantages and disadvantages between synchronous communication and asynchronous communication

If you meet a female driver who drives didi as an amateur, you can earn 500 yuan a day!

Go language learning notes 1.1

I use flask to write the website "II"

Load balancer does not have available server for client: userservice problem solving

Jasminum plug-in of Zotero document management tool
The sysdig 2022 cloud native security and usage report found that more than 75% of the running containers have serious vulnerabilities

SecureCRT运行SparkShell 删除键出现乱码的解法
随机推荐
Guide to "avoid dismissal during probation period"
我在腾讯做测试的这几年...
On a classical problem
Open source demo| you draw and I guess -- make your life more interesting
Research Report on market supply and demand and strategy of China's microneedle device industry
Simple use of typescript's class interface
MYSQL触发器要如何设置,简单教程新手一看就会
ts中枚举类型(enum)简单使用
DS18B20 details
SHOW语句用法补充
SQL基础
[micro service series] protocol buffer dynamic analysis
浏览器的四大内核:Trident,Gecko,Webkit,Blink
Self attention and multi head self attention (MSA) in transformer
Fmt Must the result of println (true) be true?
Unsatisfied dependency expressed through field ‘baseMapper‘; nested exceptio
How to transfer database data to check box
成水最多的容器
Research Report on market supply and demand and strategy of Chinese amyl cinnamaldehyde (ACA) industry
Decision tree learning notes