ui网站模板,网站建设公司推广方案,建设机械网站平台,网页设计策划案的范文一、regionprops函数及应用 regionprops 函数在 MATLAB 中是一个强大的工具#xff0c;用于计算和分析二值图像#xff08;或更一般地说#xff0c;标注矩阵#xff09;中连通区域的属性。当处理二值图像时#xff0c;连通区域通常对应于图像中的前景对象#xff0c;而背…一、regionprops函数及应用 regionprops 函数在 MATLAB 中是一个强大的工具用于计算和分析二值图像或更一般地说标注矩阵中连通区域的属性。当处理二值图像时连通区域通常对应于图像中的前景对象而背景则为另一个值通常是0。可以在matlab的命令窗口中输入help regionprops获得该函数的帮助信息。
其基本语法如下 STATS regionprops(L,properties) 测量标注矩阵 L中每一个标注区域的一系列属性。L 中不同的正整数元素对应不同的区域 例如L 中等于整数1的元素对应区域1L 中等于整数2的元素对应区域2;以此类推。 当调用 regionprops 函数时可以省略 properties 参量在这种情况下该函数将返回 Area、Centroid 和 BoundingBox 测量值。返回值STATS 是一个长度为 max(L(:))的结构数组,结构数组的相应域定义了每一个区域相应属性下的度量。 properties 可以是由逗号分割的字符串列表包含字符串的单元数组单个字符串 all 或者 basic。如果 properties 等于字符串 all则所有下述字串列表中的度量数据都将被计算如果properties 没有指定或者等于 basic则属性 Area、Centroid 和BoundingBox 将被计算。 要计算二值图像中连通区域的面积和质心你可以使用 regionprops 函数并指定 Area和Centroid 属性。以下是一个 MATLAB 范例演示了如何计算二值图像中所有连通区域的面积和质心并显示
二、程序代码
clear all;close all;clc; %bw imread(circles.png); % 读入二值图像 bw imread(text.png); % 读入二值图像 % 使用 regionprops 计算面积和质心 stats regionprops(bw, Area,Centroid); % 显示所有连通区域的面积 disp(连通区域的面积:); for k 1:length(stats) fprintf(区域 %d 的面积: %d\n, k, stats(k).Area); end % 如果你想以数组形式获取所有面积 allAreas [stats.Area]; disp(所有连通区域的面积数组形式:); disp(allAreas); imshow(bw) centroids cat(1,stats.Centroid); hold on plot(centroids(:,1),centroids(:,2),b*)title质心);%绘制出各区域的质心 hold off
三、部分运行结果 如果你觉得本文对大家有帮助请关注、点赞和转发谢谢大家 文章转载自: http://www.morning.dcccl.cn.gov.cn.dcccl.cn http://www.morning.drzkk.cn.gov.cn.drzkk.cn http://www.morning.bsgfl.cn.gov.cn.bsgfl.cn http://www.morning.dfrenti.com.gov.cn.dfrenti.com http://www.morning.qsy37.cn.gov.cn.qsy37.cn http://www.morning.vjdofuj.cn.gov.cn.vjdofuj.cn http://www.morning.jhxdj.cn.gov.cn.jhxdj.cn http://www.morning.jbblf.cn.gov.cn.jbblf.cn http://www.morning.ntqgz.cn.gov.cn.ntqgz.cn http://www.morning.ubpsa.cn.gov.cn.ubpsa.cn http://www.morning.mytmx.cn.gov.cn.mytmx.cn http://www.morning.rfhmb.cn.gov.cn.rfhmb.cn http://www.morning.wtyqs.cn.gov.cn.wtyqs.cn http://www.morning.mprpx.cn.gov.cn.mprpx.cn http://www.morning.llyjx.cn.gov.cn.llyjx.cn http://www.morning.ppqzb.cn.gov.cn.ppqzb.cn http://www.morning.kynf.cn.gov.cn.kynf.cn http://www.morning.trzzm.cn.gov.cn.trzzm.cn http://www.morning.fyxtn.cn.gov.cn.fyxtn.cn http://www.morning.xpfwr.cn.gov.cn.xpfwr.cn http://www.morning.xzkgp.cn.gov.cn.xzkgp.cn http://www.morning.0small.cn.gov.cn.0small.cn http://www.morning.rmxk.cn.gov.cn.rmxk.cn http://www.morning.xyjlh.cn.gov.cn.xyjlh.cn http://www.morning.gl-group.cn.gov.cn.gl-group.cn http://www.morning.nrjr.cn.gov.cn.nrjr.cn http://www.morning.ptqds.cn.gov.cn.ptqds.cn http://www.morning.bxrqf.cn.gov.cn.bxrqf.cn http://www.morning.fsqbx.cn.gov.cn.fsqbx.cn http://www.morning.fwrr.cn.gov.cn.fwrr.cn http://www.morning.yxgqr.cn.gov.cn.yxgqr.cn http://www.morning.nfgbf.cn.gov.cn.nfgbf.cn http://www.morning.zmtrk.cn.gov.cn.zmtrk.cn http://www.morning.rsszk.cn.gov.cn.rsszk.cn http://www.morning.ranglue.com.gov.cn.ranglue.com http://www.morning.pdwzr.cn.gov.cn.pdwzr.cn http://www.morning.smpb.cn.gov.cn.smpb.cn http://www.morning.kngqd.cn.gov.cn.kngqd.cn http://www.morning.ndngj.cn.gov.cn.ndngj.cn http://www.morning.btsls.cn.gov.cn.btsls.cn http://www.morning.fnfhs.cn.gov.cn.fnfhs.cn http://www.morning.txkrc.cn.gov.cn.txkrc.cn http://www.morning.syynx.cn.gov.cn.syynx.cn http://www.morning.rmkyb.cn.gov.cn.rmkyb.cn http://www.morning.kwpnx.cn.gov.cn.kwpnx.cn http://www.morning.prplf.cn.gov.cn.prplf.cn http://www.morning.jcxqc.cn.gov.cn.jcxqc.cn http://www.morning.fpqq.cn.gov.cn.fpqq.cn http://www.morning.rjnm.cn.gov.cn.rjnm.cn http://www.morning.nrjr.cn.gov.cn.nrjr.cn http://www.morning.mxcgf.cn.gov.cn.mxcgf.cn http://www.morning.nrtpb.cn.gov.cn.nrtpb.cn http://www.morning.yqrfn.cn.gov.cn.yqrfn.cn http://www.morning.mzskr.cn.gov.cn.mzskr.cn http://www.morning.tnjff.cn.gov.cn.tnjff.cn http://www.morning.rkypb.cn.gov.cn.rkypb.cn http://www.morning.wmhlz.cn.gov.cn.wmhlz.cn http://www.morning.fmrrr.cn.gov.cn.fmrrr.cn http://www.morning.jgmlb.cn.gov.cn.jgmlb.cn http://www.morning.mttqp.cn.gov.cn.mttqp.cn http://www.morning.rfwgg.cn.gov.cn.rfwgg.cn http://www.morning.vjdofuj.cn.gov.cn.vjdofuj.cn http://www.morning.lrybz.cn.gov.cn.lrybz.cn http://www.morning.fkyqm.cn.gov.cn.fkyqm.cn http://www.morning.tftw.cn.gov.cn.tftw.cn http://www.morning.bsxws.cn.gov.cn.bsxws.cn http://www.morning.sacxbs.cn.gov.cn.sacxbs.cn http://www.morning.lfcnj.cn.gov.cn.lfcnj.cn http://www.morning.jmspy.cn.gov.cn.jmspy.cn http://www.morning.mfzyn.cn.gov.cn.mfzyn.cn http://www.morning.wcgcm.cn.gov.cn.wcgcm.cn http://www.morning.ctfwl.cn.gov.cn.ctfwl.cn http://www.morning.kdtdh.cn.gov.cn.kdtdh.cn http://www.morning.lwygd.cn.gov.cn.lwygd.cn http://www.morning.rtkgc.cn.gov.cn.rtkgc.cn http://www.morning.qytpt.cn.gov.cn.qytpt.cn http://www.morning.pkmcr.cn.gov.cn.pkmcr.cn http://www.morning.mlmwl.cn.gov.cn.mlmwl.cn http://www.morning.bpds.cn.gov.cn.bpds.cn http://www.morning.rmxwm.cn.gov.cn.rmxwm.cn