Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
如果我解释为什么,这可能更有意义
我已经通过边缘检测(1 =边缘,0 = noedge)运行了一个测量人员的照片的逻辑矩阵(103x3488)输出。旨在计算员工刻度之间的距离(以像素为单位)。问题,员工在中间下陷。 想法:用户输入法杖两端和下垂中点的坐标(使用ginput或其他方法),然后,如果可以将这些点之间的边缘提取到数组中,则可以轻松找到边缘的位置。 以这种方式从矩阵中提取数组的任何方法? 也开放给其他想法,只使用了matlab一个月,所以我不了解大多数功能。 编辑:链接到图像 它显示了矩阵的一小块区域,因此在此示例1和2中,是我要在其间采样的点,并且我想返回沿红线出现的点。 干杯 回答: 尝试这个 dat=imread('83zlP.png'); figure(1) pcolor(double(dat)) shading flat axis equal % get the line ends gi=floor(ginput(2)) x=gi(:,1); y=gi(:,2); xl=min(x):max(x); % line pixel x coords yl=floor(interp1(x,y,xl)); % line pixel y coords pdat=nan(length(xl),1); for i=1:length(xl) pdat(i)=dat(yl(i),xl(i)); end figure(2) plot(1:length(xl),pdat) peaks=find(pdat>40); % threshhold for peak detection bigpeak=peaks(diff(peaks)>10); % threshold for selecting only edge of peak hold all plot(xl(bigpeak),pdat(bigpeak),'x') meanspacex=mean(diff(xl(bigpeak))); meanspacey=mean(diff(yl(bigpeak))); meanspace=sqrt(meanspacex^2+meanspacey^2); 矩阵pdat给出沿所选线的像素。 meanspace空间是以像素为单位的边缘间距。取决于图像,可能需要调整阈值。 更多&回答... |
![]() |
![]() |